public
Description: A Ruby-based parsing DSL based on parsing expression grammars.
Homepage: http://treetop.rubyforge.org
Clone URL: git://github.com/nathansobo/treetop.git
Expire the ranges crossing 0-length intervals with no length change
Nathan Sobo (author)
Fri Jan 25 12:04:12 -0800 2008
commit  3c71141d329c1037c8a4aed142472994b2885af1
tree    610851115f59b27ca73248d44a76cc4ea74208ca
parent  10a4864bedbd97221617c1debf5eb7e4dec74cb3
...
12
13
14
 
 
 
 
 
 
15
16
17
...
12
13
14
15
16
17
18
19
20
21
22
23
0
@@ -12,6 +12,12 @@ class IntervalSkipList
0
     head.forward[0].nil?
0
   end
0
 
0
+ def expire(range, length_change)
0
+ containing(range.first).each do |marker|
0
+ delete(marker)
0
+ end
0
+ end
0
+
0
   def containing(n)
0
     containing = []
0
     cur_node = head
...
2
3
4
5
 
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
...
2
3
4
 
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
0
@@ -2,7 +2,113 @@ require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
0
 require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
0
 
0
 describe IntervalSkipList do
0
- describe "#expire_range" do
0
+ it_should_behave_like "the palindromic fixture"
0
 
0
+ describe "when 7..7 is expired with a length change of 0" do
0
+ before do
0
+ list.expire(7..7, 0)
0
+ end
0
+
0
+ describe " #nodes" do
0
+ attr_reader :nodes, :node
0
+
0
+ before do
0
+ @nodes = list.nodes
0
+ end
0
+
0
+ it "has a size of 4" do
0
+ nodes.size.should == 4
0
+ end
0
+
0
+ describe "[0]" do
0
+ before do
0
+ @node = nodes[0]
0
+ end
0
+
0
+ it "has a key of 1 and a height of 3" do
0
+ node.key.should == 1
0
+ node.height.should == 3
0
+ end
0
+
0
+ it "has no forward markers at level 0" do
0
+ node.forward_markers[0].should be_empty
0
+ end
0
+
0
+ it "has :a and :b as its only forward markers on level 1" do
0
+ node.forward_markers[1].should have_markers(:a, :b)
0
+ end
0
+
0
+ it "has :c as its only forward marker on level 2" do
0
+ node.forward_markers[2].should have_markers(:c)
0
+ end
0
+
0
+ it "has no markers" do
0
+ node.markers.should be_empty
0
+ end
0
+ end
0
+
0
+ describe "[1]" do
0
+ before do
0
+ @node = nodes[1]
0
+ end
0
+
0
+ it "has a key of 3 and a height of 2" do
0
+ node.key.should == 3
0
+ node.height.should == 2
0
+ end
0
+
0
+ it "has :b as its only forward marker on level 0" do
0
+ node.forward_markers[0].should have_markers(:b)
0
+ end
0
+
0
+ it "has no forward markers on level 1" do
0
+ node.forward_markers[1].should be_empty
0
+ end
0
+
0
+ it "has :a and :b as its only markers" do
0
+ node.markers.should have_markers(:a, :b)
0
+ end
0
+ end
0
+
0
+ describe "[2]" do
0
+ before do
0
+ @node = nodes[2]
0
+ end
0
+
0
+ it "has a key of 5 and a height of 1" do
0
+ node.key.should == 5
0
+ node.height.should == 1
0
+ end
0
+
0
+ it "has no forward markers on level 0" do
0
+ node.forward_markers[0].should be_empty
0
+ end
0
+
0
+ it "has :b as its only marker" do
0
+ node.markers.should have_markers(:b)
0
+ end
0
+ end
0
+
0
+ describe "[3]" do
0
+ before do
0
+ @node = nodes[3]
0
+ end
0
+
0
+ it "has a key of 7 and a height of 3" do
0
+ node.key.should == 7
0
+ node.height.should == 3
0
+ end
0
+
0
+ it "has no forward markers at any level" do
0
+ node.forward_markers[0].should be_empty
0
+ node.forward_markers[1].should be_empty
0
+ node.forward_markers[2].should be_empty
0
+ end
0
+
0
+ it "has :c as its only marker" do
0
+ node.markers.should have_markers(:c)
0
+ end
0
+ end
0
+ end
0
   end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.