Class: ThreadSafeLru::ListNode

Inherits:
Object
  • Object
show all
Defined in:
lib/threadsafe-lru/DoubleLinkedList.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ ListNode

Returns a new instance of ListNode.



3
4
5
# File 'lib/threadsafe-lru/DoubleLinkedList.rb', line 3

def initialize value
  @value=value
end

Instance Attribute Details

#nextObject

Returns the value of attribute next.



23
24
25
# File 'lib/threadsafe-lru/DoubleLinkedList.rb', line 23

def next
  @next
end

#prevObject

Returns the value of attribute prev.



24
25
26
# File 'lib/threadsafe-lru/DoubleLinkedList.rb', line 24

def prev
  @prev
end

#valueObject (readonly)

Returns the value of attribute value.



22
23
24
# File 'lib/threadsafe-lru/DoubleLinkedList.rb', line 22

def value
  @value
end

Instance Method Details

#insert_between(prev_node, next_node) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/threadsafe-lru/DoubleLinkedList.rb', line 7

def insert_between prev_node, next_node      
  self.next=next_node
  self.prev=prev_node
  prev_node.next=self
  next_node.prev=self      
  self
end

#removeObject



15
16
17
18
19
20
# File 'lib/threadsafe-lru/DoubleLinkedList.rb', line 15

def remove
  self.prev.next=self.next
  self.next.prev=self.prev
  self.next=nil
  self.prev=nil
end