Skip to content

Commit

Permalink
simple_skiplist + reverse: passing all specs without serialization an…
Browse files Browse the repository at this point in the history
…d C optimizations
  • Loading branch information
Oleg Andreev committed Apr 28, 2008
1 parent 060a1dc commit 1c48086
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/strokedb/data_structures/simple_skiplist.rb
Expand Up @@ -22,6 +22,10 @@ def initialize(raw_list = nil, options = {})
@mutex = Mutex.new
end

def inspect
"#<#{self.class}:0x#{object_id.to_s(16)} items: #{to_a.inspect}, maxlevel: #{@maxlevel}, probability: #{@probability}>"
end

# Marshal API
def marshal_dump
raw_list = serialize_list(@head)
Expand Down Expand Up @@ -328,7 +332,7 @@ def to_a
arr
end
end

private

def serialize_list(head)
Expand Down
5 changes: 4 additions & 1 deletion spec/lib/strokedb/data_structures/simple_skiplist_spec.rb
Expand Up @@ -77,7 +77,10 @@
it "should correctly insert keys in an ascending level order" do
1.upto(@maxlevel) do |i|
k = "x#{i}"
@list.insert(k, k, i).should == @list
r = @list.insert(k, k, i)
r.object_id.should == @list.object_id
r.should == @list

@list.find("").should == nil
@list.find(k).should == k
@list.find("-").should == nil
Expand Down

0 comments on commit 1c48086

Please sign in to comment.