algorithms 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/Manifest +9 -14
- data/README.markdown +92 -0
- data/Rakefile +3 -2
- data/algorithms.gemspec +6 -6
- data/benchmarks/deque.rb +17 -0
- data/benchmarks/sorts.rb +3 -2
- data/benchmarks/treemaps.rb +36 -0
- data/ext/containers/deque/deque.c +18 -4
- data/ext/containers/{tree_map → rbtree_map}/extconf.rb +0 -0
- data/ext/containers/{tree_map → rbtree_map}/rbtree.c +42 -12
- data/ext/containers/{bst → splaytree_map}/extconf.rb +1 -1
- data/ext/containers/splaytree_map/splaytree.c +370 -0
- data/lib/algorithms.rb +6 -5
- data/lib/containers/deque.rb +5 -10
- data/lib/containers/splay_tree_map.rb +14 -19
- data/spec/deque_gc_mark_spec.rb +18 -0
- data/spec/heap_spec.rb +110 -103
- data/spec/kd_tree_spec.rb +1 -86
- data/spec/priority_queue_spec.rb +62 -62
- data/spec/rb_tree_map_gc_mark_spec.rb +25 -0
- data/spec/splay_tree_map_spec.rb +26 -26
- metadata +19 -25
- data/README +0 -90
- data/benchmark.rb +0 -51
- data/benchmarks/rbench.rb +0 -16
- data/benchmarks/rbench/column.rb +0 -26
- data/benchmarks/rbench/group.rb +0 -43
- data/benchmarks/rbench/report.rb +0 -53
- data/benchmarks/rbench/runner.rb +0 -109
- data/benchmarks/rbench/summary.rb +0 -51
- data/ext/containers/bst/bst.c +0 -205
- data/lib/graphs/graph.rb +0 -25
- data/spec/bst_spec.rb +0 -31
data/lib/graphs/graph.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
class Graph
|
2
|
-
def initialize(string=nil, &block)
|
3
|
-
p block if block
|
4
|
-
@nodes = []
|
5
|
-
end
|
6
|
-
|
7
|
-
def -(other)
|
8
|
-
@nodes << other
|
9
|
-
end
|
10
|
-
|
11
|
-
def >(other)
|
12
|
-
@nodes << other
|
13
|
-
end
|
14
|
-
end
|
15
|
-
a = Graph.new
|
16
|
-
b = []
|
17
|
-
d = []
|
18
|
-
|
19
|
-
a - b
|
20
|
-
a > d
|
21
|
-
|
22
|
-
Graph.new do
|
23
|
-
d - c
|
24
|
-
g - s
|
25
|
-
end
|
data/spec/bst_spec.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
$: << File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib')
|
2
|
-
require "algorithms"
|
3
|
-
|
4
|
-
begin
|
5
|
-
Containers::CBst
|
6
|
-
describe "binary search tree" do
|
7
|
-
it "should let user insert new elements with key" do
|
8
|
-
@bst = Containers::CBst.new
|
9
|
-
100.times { |x| @bst.insert(x, "hello : #{x}") }
|
10
|
-
@bst.size.should eql(100)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should allow users to delete elements" do
|
14
|
-
@bst = Containers::CBst.new
|
15
|
-
@bst.insert(10, "hello world")
|
16
|
-
@bst.insert(11, "hello world")
|
17
|
-
@bst.delete(11)
|
18
|
-
@bst.size.should eql(1)
|
19
|
-
@bst.delete(10)
|
20
|
-
@bst.size.should eql(0)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should throw exception on invalid key delete" do
|
24
|
-
@bst = Containers::CBst.new
|
25
|
-
@bst.insert(10,"Hello world")
|
26
|
-
lambda { @bst.delete(20) }.should raise_error(ArgumentError)
|
27
|
-
@bst.size.should eql(1)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
rescue Exception
|
31
|
-
end
|