dskiplist 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f56c0d3deac75e8d56c87df301557365e8bdfae6
4
- data.tar.gz: 9e991f79a2505c20db7b17e17d64b680d60bc75b
3
+ metadata.gz: 89e285ab3fac883f1ad22f5959e1a85672c9412f
4
+ data.tar.gz: 8ed03b7fda7c621f0f806840958eeaa85e03759f
5
5
  SHA512:
6
- metadata.gz: 976a3493109c67757abc19b3bec4f195217d7ab440839644598a042cf6e25dedde0ad0f98191cea5fbf25cd4e9825ec781c4a0bc77e1a793469ec3958c37c62f
7
- data.tar.gz: d47ebb750ffdbd1dd32f0bec2f9cca91db7862fc0b9fd40b60004a492437f5f49a279f69b40da57f7af043c5b081ec88c9f04c542e7a55bb6f00d14038e8cf90
6
+ metadata.gz: f3f1318ad48db40ee5aff1cde484508a3e8707f0d99a5433088b13a822cfa81010c9ed3ba24c856aa61db1c988104141edcb18bacec79c019b1f29caccbcac24
7
+ data.tar.gz: 7a218abfea5cc99740a54ba22b15f16ab8b2c8a42200433f8107b6ee2bd4649b4a8daf9fe32edfbf3c44ca7ea341933a46946c418f0e42727e8e3c9a0cbf0510
Binary file
Binary file
data/dskiplist.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
-
19
+ spec.add_development_dependency "rspec"
20
20
  spec.add_development_dependency "bundler", "~> 1.5"
21
21
  spec.add_development_dependency "rake"
22
22
  end
Binary file
@@ -1,3 +1,3 @@
1
1
  module Dskiplist
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/dskiplist.rb CHANGED
@@ -92,7 +92,7 @@ class DSkipList
92
92
  x = x.forward[0]
93
93
  if x and x.key == search_key
94
94
  0.upto(x.forward.length - 1) do |i|
95
- update[i].forward[i] = x.forward[i] if x.forward[i]
95
+ update[i].forward[i] = x.forward[i]
96
96
  end
97
97
  return true
98
98
  else
@@ -0,0 +1,66 @@
1
+ require 'rspec'
2
+ require 'dskiplist'
3
+ #Checks for stray links in the upper levels. There may be a more exhaustive way to check integrity.
4
+ def check_integrity(list)
5
+ complete = list.to_a
6
+ 1.upto(list.level) do |l|
7
+ #if anything in the higher layer wasn't in layer 0
8
+ difference = list.to_a(nil,nil,nil,l) - complete
9
+ puts "stray node found in level: #{l} which is #{list.to_a(nil,nil,nil,l)}" if !difference.empty?
10
+ expect(difference).to match_array([])
11
+ end
12
+ end
13
+
14
+ describe "The skiplist" do
15
+ before :each do
16
+ @list = DSkipList.new
17
+ 100.times {|n| @list[n] = n}
18
+ end
19
+ after :each do
20
+ check_integrity(@list)
21
+ end
22
+
23
+ it "should lookup value correctly" do
24
+ expect(@list[30]).to eq(30)
25
+ end
26
+
27
+ it "should overwrite value with identical key" do
28
+ @list[25] = "walrus"
29
+ expect(@list[25]).to eq("walrus")
30
+ end
31
+
32
+ it "should count correctly" do
33
+ expect(@list.count).to eq(100)
34
+ expect(@list.count(50,99)).to eq(50)
35
+ expect(@list.count(1,1)).to eq(1)
36
+ end
37
+
38
+ it "should convert to array" do
39
+ entire = @list.to_a
40
+ expect(entire.count).to eq(100)
41
+ subset = @list.to_a(26,50)
42
+ expect(subset.count).to eq(25)
43
+ 26.upto(50) do |n|
44
+ expect(subset.include? n).to eq(true)
45
+ end
46
+ end
47
+
48
+ it "should convert to hash" do
49
+ expect(@list.to_h.count).to eq(100)
50
+ expect(@list.to_h(51,75).count).to eq(25)
51
+ subset = @list.to_h(25,50)
52
+ 25.upto(50) do |n|
53
+ expect(subset[n]).to eq(n)
54
+ end
55
+ end
56
+
57
+ it "should delete one element properly" do
58
+ @list.delete 25
59
+ expect(@list[25]).to eq(nil)
60
+ end
61
+
62
+ it "should delete multiple elements properly" do
63
+ (25..75).each {|n| @list.delete n}
64
+ (25..75).each {|n| expect(@list[n]).to eq(nil)}
65
+ end
66
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dskiplist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Forrest Allison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-11 00:00:00.000000000 Z
11
+ date: 2014-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -45,6 +59,7 @@ executables: []
45
59
  extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
62
+ - ".dskiplist.gemspec.swo"
48
63
  - ".git-new/HEAD"
49
64
  - ".git-new/config"
50
65
  - ".git-new/description"
@@ -67,14 +82,17 @@ files:
67
82
  - ".git-new/objects/ae/ee3428c017916e5cc0e57d387224f33ed0b990"
68
83
  - ".git-new/objects/d8/7d4be66f458acd52878902bbf1391732ad21e1"
69
84
  - ".gitignore"
85
+ - ".skiplist-test.rb.swo"
70
86
  - Gemfile
71
87
  - LICENSE.txt
72
88
  - README.md
73
89
  - Rakefile
74
90
  - dskiplist.gemspec
91
+ - lib/.dskiplist.rb.swo
75
92
  - lib/dskiplist.rb
76
93
  - lib/dskiplist/version.rb
77
94
  - skiplist-test.rb
95
+ - test/skiplist_spec.rb
78
96
  homepage: https://github.com/light24bulbs/dynamic-skiplist/
79
97
  licenses:
80
98
  - MIT
@@ -99,4 +117,5 @@ rubygems_version: 2.2.2
99
117
  signing_key:
100
118
  specification_version: 4
101
119
  summary: High speed skiplist gem
102
- test_files: []
120
+ test_files:
121
+ - test/skiplist_spec.rb