Class: StrokeDB::InvertedList::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/strokedb/data_structures/inverted_list.rb

Direct Known Subclasses

HeadNode, TailNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level, key, value) ⇒ Node

Returns a new instance of Node.



216
217
218
219
# File 'lib/strokedb/data_structures/inverted_list.rb', line 216

def initialize(level, key, value)
	@key, @values = key, [value]
	@forward = Array.new(level)
end

Instance Attribute Details

#_serialized_indexObject

Returns the value of attribute _serialized_index.



215
216
217
# File 'lib/strokedb/data_structures/inverted_list.rb', line 215

def _serialized_index
  @_serialized_index
end

#forwardObject

Returns the value of attribute forward.



214
215
216
# File 'lib/strokedb/data_structures/inverted_list.rb', line 214

def forward
  @forward
end

#keyObject

Returns the value of attribute key.



214
215
216
# File 'lib/strokedb/data_structures/inverted_list.rb', line 214

def key
  @key
end

#valuesObject

Returns the value of attribute values.



214
215
216
# File 'lib/strokedb/data_structures/inverted_list.rb', line 214

def values
  @values
end

Instance Method Details

#<(key) ⇒ Object



228
229
230
# File 'lib/strokedb/data_structures/inverted_list.rb', line 228

def <(key)
 @key < key
end

#<=(key) ⇒ Object



231
232
233
# File 'lib/strokedb/data_structures/inverted_list.rb', line 231

def <=(key)
 @key <= key
end

#free(list) ⇒ Object

this is called when node is thrown out of the list note, that node.value is called immediately after node.free



222
223
224
# File 'lib/strokedb/data_structures/inverted_list.rb', line 222

def free(list)
  # do nothing
end

#levelObject

do nothing



225
226
227
# File 'lib/strokedb/data_structures/inverted_list.rb', line 225

def level
  @forward.size
end

#nextObject



234
235
236
# File 'lib/strokedb/data_structures/inverted_list.rb', line 234

def next
  forward[0]
end

#to_sObject



237
238
239
# File 'lib/strokedb/data_structures/inverted_list.rb', line 237

def to_s
  "[#{level}]#{@key}: #{@values.inspect}"
end