Class: SkipList::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/skiplist.rb

Overview

Node of SkipList, inner use only

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(toplevel, key, val) ⇒ Node

Returns a new instance of Node.



55
56
57
58
59
60
# File 'lib/skiplist.rb', line 55

def initialize toplevel, key, val
	@toplevel = toplevel
	@key = key
	@val = val
	@links = Array.new(@toplevel + 1)
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



53
54
55
# File 'lib/skiplist.rb', line 53

def key
  @key
end

#toplevelObject

Returns the value of attribute toplevel.



53
54
55
# File 'lib/skiplist.rb', line 53

def toplevel
  @toplevel
end

#valObject

Returns the value of attribute val.



53
54
55
# File 'lib/skiplist.rb', line 53

def val
  @val
end

Instance Method Details

#[](level) ⇒ Object



74
75
76
# File 'lib/skiplist.rb', line 74

def [] level
	@links[level]
end

#[]=(level, node) ⇒ Object



78
79
80
# File 'lib/skiplist.rb', line 78

def []= level, node
	@links[level] = node
end


62
63
64
65
66
67
68
69
70
71
72
# File 'lib/skiplist.rb', line 62

def print_debug
	puts "object_id = 0x%014x" % [object_id]
	puts "@toplevel = #{@toplevel}"
	puts "@key = #{@key}"
	puts "@val = #{@val}"
	puts "@links = "
	@links.each_index{|i|
		print "[#{i}] "
		@links[i].print_debug
	}
end