Class: SkipList::Node
- Inherits:
-
Object
- Object
- SkipList::Node
- Defined in:
- lib/skiplist.rb
Overview
Node of SkipList, inner use only
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#toplevel ⇒ Object
Returns the value of attribute toplevel.
-
#val ⇒ Object
Returns the value of attribute val.
Instance Method Summary collapse
- #[](level) ⇒ Object
- #[]=(level, node) ⇒ Object
-
#initialize(toplevel, key, val) ⇒ Node
constructor
A new instance of Node.
- #print_debug ⇒ Object
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
#key ⇒ Object
Returns the value of attribute key.
53 54 55 |
# File 'lib/skiplist.rb', line 53 def key @key end |
#toplevel ⇒ Object
Returns the value of attribute toplevel.
53 54 55 |
# File 'lib/skiplist.rb', line 53 def toplevel @toplevel end |
#val ⇒ Object
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 |
#print_debug ⇒ Object
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 |