Class: DSA::SkipListNode

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value = nil) ⇒ SkipListNode

Returns a new instance of SkipListNode.



4
5
6
7
8
9
10
11
# File 'lib/DSA/skip_list.rb', line 4

def initialize(key, value = nil)
  @key = key
  @value = value
  @prev = nil
  @next = nil
  @up = nil
  @down = nil
end

Instance Attribute Details

#downObject

Returns the value of attribute down.



3
4
5
# File 'lib/DSA/skip_list.rb', line 3

def down
  @down
end

#keyObject

Returns the value of attribute key.



3
4
5
# File 'lib/DSA/skip_list.rb', line 3

def key
  @key
end

#nextObject

Returns the value of attribute next.



3
4
5
# File 'lib/DSA/skip_list.rb', line 3

def next
  @next
end

#prevObject

Returns the value of attribute prev.



3
4
5
# File 'lib/DSA/skip_list.rb', line 3

def prev
  @prev
end

#upObject

Returns the value of attribute up.



3
4
5
# File 'lib/DSA/skip_list.rb', line 3

def up
  @up
end

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/DSA/skip_list.rb', line 3

def value
  @value
end

Instance Method Details

#is_sentinel?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/DSA/skip_list.rb', line 13

def is_sentinel?
  @key.equal? SkipListLevel::SENTINEL
end