Class: Texd::Cache::LinkedList
- Inherits:
-
Object
- Object
- Texd::Cache::LinkedList
- Defined in:
- lib/texd/cache.rb
Instance Attribute Summary collapse
-
#head ⇒ Object
readonly
Returns the value of attribute head.
Instance Method Summary collapse
Instance Attribute Details
#head ⇒ Object (readonly)
Returns the value of attribute head.
8 9 10 |
# File 'lib/texd/cache.rb', line 8 def head @head end |
Instance Method Details
#add(node) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/texd/cache.rb', line 10 def add(node) if @head node.next = @head node.prev = @head.prev @head.prev.next = node @head.prev = node else node.next = node node.prev = node end @head = node end |
#remove(node) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/texd/cache.rb', line 24 def remove(node) if node.next == node # remove last element, should never happen @head = nil else node.prev.next = node.next node.next.prev = node.prev @head = node.next if node == @head end end |