Skip to content

Commit

Permalink
Renaming markers to forward markers
Browse files Browse the repository at this point in the history
  • Loading branch information
nathansobo committed Jan 20, 2008
1 parent 725c589 commit edc61f8
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 58 deletions.
16 changes: 8 additions & 8 deletions lib/treetop/runtime/interval_skip_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def containing(n)
cur_node = next_node
return containing if cur_node.key == n
end
containing.concat(cur_node.markers[cur_level])
containing.concat(cur_node.forward_markers[cur_level])
end
containing
end
Expand Down Expand Up @@ -104,7 +104,7 @@ def next_node_at_level_outside_range?(node, level, range)
end

def mark_forward_path_at_level(node, level, marker)
node.markers[level].push(marker)
node.forward_markers[level].push(marker)
next_node = node.forward[level]
next_node.eq_markers.push(marker)
node = next_node
Expand All @@ -121,12 +121,12 @@ def nodes
end

class HeadNode
attr_reader :height, :forward, :markers
attr_reader :height, :forward, :forward_markers

def initialize(height)
@height = height
@forward = Array.new(height, nil)
@markers = Array.new(height) {|i| []}
@forward_markers = Array.new(height) {|i| []}
end
end

Expand Down Expand Up @@ -161,23 +161,23 @@ def promote_markers(path)
promoted = []
new_promoted = []
0.upto(height - 1) do |i|
incoming_markers = path[i].markers[i]
incoming_markers = path[i].forward_markers[i]
eq_markers.concat(incoming_markers)

incoming_markers.each do |marker|
if can_be_promoted_higher?(marker, i)
new_promoted.push(marker)
delete_marker_from_path(marker, i, forward[i+i])
else
markers[i].push(marker)
forward_markers[i].push(marker)
end
end

promoted.each do |marker|
if can_be_promoted_higher?(marker, i)
new_promoted.push(marker)
else
markers[i].push(marker)
forward_markers[i].push(marker)
end
end

Expand All @@ -193,7 +193,7 @@ def can_be_promoted_higher?(marker, level)
def delete_marker_from_path(marker, level, terminus)
cur_node = forward[level]
until cur_node == terminus
cur_node.markers[level].delete(marker)
cur_node.forward_markers[level].delete(marker)
cur_node.eq_markers.delete(marker)
cur_node = cur_node.forward[level]
end
Expand Down
100 changes: 50 additions & 50 deletions spec/runtime/interval_skip_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ def confirm_containing_intervals(range, *markers)
end

it "has :a as its only marker at level 1" do
node.markers[1].should have_marker(:a)
node.forward_markers[1].should have_marker(:a)
end

it "has no markers at level 0" do
node.markers[0].should be_empty
it "has no forward_markers at level 0" do
node.forward_markers[0].should be_empty
end

it "has no eq_markers" do
Expand All @@ -101,10 +101,10 @@ def confirm_containing_intervals(range, *markers)
node.height.should == 3
end

it "has no markers at any level" do
node.markers[0].should be_empty
node.markers[1].should be_empty
node.markers[2].should be_empty
it "has no forward markers at any level" do
node.forward_markers[0].should be_empty
node.forward_markers[1].should be_empty
node.forward_markers[2].should be_empty
end

it "has :a as its only eq_marker" do
Expand Down Expand Up @@ -143,12 +143,12 @@ def confirm_containing_intervals(range, *markers)
node.height.should == 2
end

it "has :a and :b as its only markers at level 1" do
node.markers[1].should have_markers(:a, :b)
it "has :a and :b as its only forward markers at level 1" do
node.forward_markers[1].should have_markers(:a, :b)
end

it "has no markers at level 0" do
node.markers[0].should be_empty
it "has no forward markers at level 0" do
node.forward_markers[0].should be_empty
end

it "has no eq_markers" do
Expand All @@ -167,11 +167,11 @@ def confirm_containing_intervals(range, *markers)
end

it "has :a as its only marker at level 1" do
node.markers[1].should have_marker(:a)
node.forward_markers[1].should have_marker(:a)
end

it "has no markers at level 0" do
node.markers[0].should be_empty
it "has no forward markers at level 0" do
node.forward_markers[0].should be_empty
end

it "has :a and :b as its only eq_markers" do
Expand All @@ -189,10 +189,10 @@ def confirm_containing_intervals(range, *markers)
node.height.should == 3
end

it "has no markers at any level" do
node.markers[0].should be_empty
node.markers[1].should be_empty
node.markers[2].should be_empty
it "has no forward markers at any level" do
node.forward_markers[0].should be_empty
node.forward_markers[1].should be_empty
node.forward_markers[2].should be_empty
end

it "has :a its only eq_marker" do
Expand All @@ -215,12 +215,12 @@ def confirm_containing_intervals(range, *markers)
node.height.should == 2
end

it "has :a, :b, :c as its only markers at level 1" do
node.markers[1].should have_markers(:a, :b, :c)
it "has :a, :b, :c as its only forward markers at level 1" do
node.forward_markers[1].should have_markers(:a, :b, :c)
end

it "has no markers at level 0" do
node.markers[0].should be_empty
it "has no forward markers at level 0" do
node.forward_markers[0].should be_empty
end

it "has no eq_markers" do
Expand All @@ -239,15 +239,15 @@ def confirm_containing_intervals(range, *markers)
end

it "has :a as its only marker at level 2" do
node.markers[2].should have_marker(:a)
node.forward_markers[2].should have_marker(:a)
end

it "has :b as its only marker at level 1" do
node.markers[1].should have_marker(:b)
node.forward_markers[1].should have_marker(:b)
end

it "has no markers at level 0" do
node.markers[0].should be_empty
it "has no forward markers at level 0" do
node.forward_markers[0].should be_empty
end

it "has :a, :b, and :c as its only eq_markers" do
Expand All @@ -265,9 +265,9 @@ def confirm_containing_intervals(range, *markers)
node.height.should == 2
end

it "has no markers at any level" do
node.markers[0].should be_empty
node.markers[1].should be_empty
it "has no forward markers at any level" do
node.forward_markers[0].should be_empty
node.forward_markers[1].should be_empty
end

it "has :b as its only eq_markers" do
Expand All @@ -285,10 +285,10 @@ def confirm_containing_intervals(range, *markers)
node.height.should == 3
end

it "has no markers at any level" do
node.markers[0].should be_empty
node.markers[1].should be_empty
node.markers[2].should be_empty
it "has no forward markers at any level" do
node.forward_markers[0].should be_empty
node.forward_markers[1].should be_empty
node.forward_markers[2].should be_empty
end

it "has :a as its only eq_marker" do
Expand All @@ -311,12 +311,12 @@ def confirm_containing_intervals(range, *markers)
node.height.should == 2
end

it "has :a, :b, :c, :d as its only markers at level 1" do
node.markers[1].should have_markers(:a, :b, :c, :d)
it "has :a, :b, :c, :d as its only forward markers at level 1" do
node.forward_markers[1].should have_markers(:a, :b, :c, :d)
end

it "has no markers at level 0" do
node.markers[0].should be_empty
it "has no forward markers at level 0" do
node.forward_markers[0].should be_empty
end

it "has no eq_markers" do
Expand All @@ -334,16 +334,16 @@ def confirm_containing_intervals(range, *markers)
node.height.should == 3
end

it "has :a and :d as its only markers at level 2" do
node.markers[2].should have_markers(:a, :d)
it "has :a and :d as its only forward markers at level 2" do
node.forward_markers[2].should have_markers(:a, :d)
end

it "has :b as its only marker at level 1" do
node.markers[1].should have_marker(:b)
node.forward_markers[1].should have_marker(:b)
end

it "has no markers at level 0" do
node.markers[0].should be_empty
it "has no forward markers at level 0" do
node.forward_markers[0].should be_empty
end

it "has :a, :b, :c, :d as its only eq_markers" do
Expand All @@ -362,8 +362,8 @@ def confirm_containing_intervals(range, *markers)
end

it "has no markers on any level" do
node.markers[0].should be_empty
node.markers[1].should be_empty
node.forward_markers[0].should be_empty
node.forward_markers[1].should be_empty
end

it "has :b as its only eq_marker" do
Expand All @@ -382,12 +382,12 @@ def confirm_containing_intervals(range, *markers)
end

it "has :d as its only marker at level 0" do
node.markers[0].should have_marker(:d)
node.forward_markers[0].should have_marker(:d)
end

it "has no markers at levels 1 and 2" do
node.markers[1].should be_empty
node.markers[2].should be_empty
it "has no forward markers at levels 1 and 2" do
node.forward_markers[1].should be_empty
node.forward_markers[2].should be_empty
end

it "has :a, :d as its only eq_markers" do
Expand All @@ -405,8 +405,8 @@ def confirm_containing_intervals(range, *markers)
node.height.should == 1
end

it "has no markers at level 0" do
node.markers[0].should be_empty
it "has no forward markers at level 0" do
node.forward_markers[0].should be_empty
end

it "has :d as its only eq_marker" do
Expand Down

0 comments on commit edc61f8

Please sign in to comment.