Skip to content

Commit

Permalink
Randomized node heights and the beginnings of a test to drive out cor…
Browse files Browse the repository at this point in the history
…ner cases which seem to exist with duplicate markers returned from stabbing queries
  • Loading branch information
nathansobo committed Jan 26, 2008
1 parent 1169099 commit 98df058
Show file tree
Hide file tree
Showing 6 changed files with 2,406 additions and 2,625 deletions.
9 changes: 8 additions & 1 deletion lib/treetop/runtime/interval_skip_list/interval_skip_list.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
class IntervalSkipList
attr_reader :probability

def initialize
@head = HeadNode.new(max_height)
@ranges = {}
@probability = 0.5
end

def max_height
Expand Down Expand Up @@ -144,7 +147,11 @@ def make_path
end

def next_node_height
nil
height = 1
while rand < probability && height < max_height
height += 1
end
height
end

def can_ascend_from?(node, level)
Expand Down
Loading

0 comments on commit 98df058

Please sign in to comment.