Class: IntervalSkipList::Node

Inherits:
HeadNode show all
Defined in:
lib/gems/treetop-1.2.4/lib/treetop/runtime/interval_skip_list/node.rb

Instance Attribute Summary collapse

Attributes inherited from HeadNode

#forward, #forward_markers, #height

Instance Method Summary collapse

Methods inherited from HeadNode

#top_level

Constructor Details

#initialize(key, height, path) ⇒ Node

Returns a new instance of Node.



6
7
8
9
10
11
12
13
# File 'lib/gems/treetop-1.2.4/lib/treetop/runtime/interval_skip_list/node.rb', line 6

def initialize(key, height, path)
  super(height)
  @key = key
  @markers = []
  @endpoint_of = []
  update_forward_pointers(path)
  promote_markers(path)
end

Instance Attribute Details

#endpoint_ofObject (readonly)

Returns the value of attribute endpoint_of.



4
5
6
# File 'lib/gems/treetop-1.2.4/lib/treetop/runtime/interval_skip_list/node.rb', line 4

def endpoint_of
  @endpoint_of
end

#keyObject

Returns the value of attribute key.



3
4
5
# File 'lib/gems/treetop-1.2.4/lib/treetop/runtime/interval_skip_list/node.rb', line 3

def key
  @key
end

#markersObject (readonly)

Returns the value of attribute markers.



4
5
6
# File 'lib/gems/treetop-1.2.4/lib/treetop/runtime/interval_skip_list/node.rb', line 4

def markers
  @markers
end

Instance Method Details

#all_forward_markersObject



15
16
17
# File 'lib/gems/treetop-1.2.4/lib/treetop/runtime/interval_skip_list/node.rb', line 15

def all_forward_markers
  markers.flatten
end

#delete(path) ⇒ Object



19
20
21
22
23
24
# File 'lib/gems/treetop-1.2.4/lib/treetop/runtime/interval_skip_list/node.rb', line 19

def delete(path)
  0.upto(top_level) do |i|
    path[i].forward[i] = forward[i]
  end
  demote_markers(path)
end

#propagate_length_change(length_change) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/gems/treetop-1.2.4/lib/treetop/runtime/interval_skip_list/node.rb', line 26

def propagate_length_change(length_change)
  cur_node = self
  while cur_node do
    cur_node.key += length_change
    cur_node = cur_node.forward[0]
  end
end