public
Fork of nathansobo/treetop
Description: A Ruby-based parsing DSL based on parsing expression grammars.
Homepage: http://treetop.rubyforge.org
Clone URL: git://github.com/juretta/treetop.git
Randomized node heights and the beginnings of a test to drive out corner 
cases which seem to exist with duplicate markers returned from stabbing 
queries
Nathan Sobo (author)
Fri Jan 25 18:04:00 -0800 2008
commit  98df05870a656da0a9cd93431cc46223d3375d21
tree    0d438a93329ed7f5655f2943b08db54a757b275f
parent  1169099ff175559ecdea213cb2b285c502e11f2c
...
1
 
 
2
3
4
 
5
6
7
...
144
145
146
147
 
 
 
 
 
148
149
150
...
1
2
3
4
5
6
7
8
9
10
...
147
148
149
 
150
151
152
153
154
155
156
157
0
@@ -1,7 +1,10 @@
0
 class IntervalSkipList
0
+ attr_reader :probability
0
+
0
   def initialize
0
     @head = HeadNode.new(max_height)
0
     @ranges = {}
0
+ @probability = 0.5
0
   end
0
 
0
   def max_height
0
@@ -144,7 +147,11 @@ class IntervalSkipList
0
   end
0
 
0
   def next_node_height
0
- nil
0
+ height = 1
0
+ while rand < probability && height < max_height
0
+ height += 1
0
+ end
0
+ height
0
   end
0
 
0
   def can_ascend_from?(node, level)
...
1
2
3
4
...
 
1
2
3
0
@@ -1,4 +1,3 @@
0
-require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
0
 require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
0
 
0
 describe IntervalSkipList do
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
0
 
0
 class IntervalSkipList
0
- public :insert_node, :delete_node, :nodes, :head
0
+ public :insert_node, :delete_node, :nodes, :head, :next_node_height
0
 end
0
 
0
 describe "#next_node_height is deterministic", :shared => true do

Comments

    No one has commented yet.