Class: LRUHash::Node

Inherits:
Struct
  • Object
show all
Defined in:
lib/bio/system/lruhash.rb

Overview

A single node in the doubly linked LRU list of nodes

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



201
202
203
# File 'lib/bio/system/lruhash.rb', line 201

def key
  @key
end

#predObject

Returns the value of attribute pred

Returns:

  • (Object)

    the current value of pred



201
202
203
# File 'lib/bio/system/lruhash.rb', line 201

def pred
  @pred
end

#succObject

Returns the value of attribute succ

Returns:

  • (Object)

    the current value of succ



201
202
203
# File 'lib/bio/system/lruhash.rb', line 201

def succ
  @succ
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



201
202
203
# File 'lib/bio/system/lruhash.rb', line 201

def value
  @value
end

Instance Method Details

#insert_after(node) ⇒ Object



209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/bio/system/lruhash.rb', line 209

def insert_after(node)
  raise 'Cannot insert after self' if equal? node
  return self if node.succ.equal? self

  unlink

  self.succ = node.succ
  self.pred = node

  node.succ.pred = self if node.succ
  node.succ = self

  self
end


202
203
204
205
206
207
# File 'lib/bio/system/lruhash.rb', line 202

def unlink
  pred.succ = succ if pred
  succ.pred = pred if succ
  self.succ = self.pred = nil
  self
end