ds 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.rdoc +490 -0
- data/Rakefile +1 -1
- data/lib/ds.rb +17 -19
- data/lib/ds/ext/array_x.rb +35 -0
- data/lib/ds/graphs/graph.rb +36 -32
- data/lib/ds/graphs/graph_as_matrix.rb +22 -23
- data/lib/ds/graphs/graph_as_tri_matrix.rb +1 -2
- data/lib/ds/lists/list.rb +18 -21
- data/lib/ds/matrixes/array_2d.rb +4 -0
- data/lib/ds/pair.rb +14 -0
- data/lib/ds/queues/priority_queue.rb +36 -0
- data/lib/ds/queues/queue.rb +1 -1
- data/lib/ds/sets/ordered_set.rb +32 -0
- data/lib/ds/trees/binary_heap.rb +45 -14
- data/lib/ds/trees/binary_search_tree.rb +3 -1
- data/lib/ds/trees/binary_tree.rb +11 -5
- data/lib/ds/trees/complete_binary_tree.rb +24 -16
- data/lib/ds/trees/tree.rb +3 -3
- data/lib/ds/trees/tree_walker.rb +7 -6
- data/lib/ds/trees/trie.rb +14 -20
- data/lib/ds/version.rb +1 -1
- data/test/help.rb +12 -3
- data/test/test_array2d.rb +14 -4
- data/test/test_array_x.rb +27 -7
- data/test/test_binary_heap.rb +19 -1
- data/test/test_binary_search_tree.rb +8 -1
- data/test/test_binary_tree.rb +7 -1
- data/test/test_complete_binary_tree.rb +34 -6
- data/test/test_digraph.rb +1 -1
- data/test/test_graph.rb +10 -1
- data/test/test_list.rb +59 -2
- data/test/test_ordered_set.rb +28 -0
- data/test/test_pair.rb +26 -0
- data/test/test_priority_queue.rb +134 -0
- data/test/test_queue.rb +3 -3
- data/test/test_stack.rb +0 -2
- data/test/test_tree.rb +32 -9
- data/test/test_tree_walker.rb +22 -0
- data/test/test_trie.rb +20 -2
- metadata +13 -81
- data/doc/Array.html +0 -264
- data/doc/DS.html +0 -292
- data/doc/DS/Array2D.html +0 -345
- data/doc/DS/BinaryHeap.html +0 -493
- data/doc/DS/BinarySearchTree.html +0 -313
- data/doc/DS/BinaryTree.html +0 -433
- data/doc/DS/CompleteBinaryTree.html +0 -550
- data/doc/DS/CyclicList.html +0 -234
- data/doc/DS/Digraph.html +0 -299
- data/doc/DS/Edge.html +0 -283
- data/doc/DS/ExpandableArray.html +0 -316
- data/doc/DS/Graph.html +0 -739
- data/doc/DS/GraphAsList.html +0 -361
- data/doc/DS/GraphAsMatrix.html +0 -633
- data/doc/DS/GraphAsTriMatrix.html +0 -274
- data/doc/DS/List.html +0 -1263
- data/doc/DS/ListElement.html +0 -344
- data/doc/DS/Queue.html +0 -517
- data/doc/DS/Ring.html +0 -323
- data/doc/DS/Stack.html +0 -407
- data/doc/DS/Tree.html +0 -770
- data/doc/DS/TreeWalker.html +0 -561
- data/doc/DS/TriMatrix.html +0 -338
- data/doc/created.rid +0 -25
- data/doc/ds/graphs/digraph_rb.html +0 -52
- data/doc/ds/graphs/edge_rb.html +0 -52
- data/doc/ds/graphs/graph_as_list_rb.html +0 -52
- data/doc/ds/graphs/graph_as_matrix_rb.html +0 -52
- data/doc/ds/graphs/graph_as_tri_matrix_rb.html +0 -52
- data/doc/ds/graphs/graph_rb.html +0 -52
- data/doc/ds/lists/cyclic_list_rb.html +0 -52
- data/doc/ds/lists/list_element_rb.html +0 -52
- data/doc/ds/lists/list_rb.html +0 -52
- data/doc/ds/lists/ring_rb.html +0 -52
- data/doc/ds/matrixes/array_2d_rb.html +0 -52
- data/doc/ds/matrixes/expandable_array_rb.html +0 -52
- data/doc/ds/matrixes/tri_matrix_rb.html +0 -52
- data/doc/ds/queues/queue_rb.html +0 -52
- data/doc/ds/stacks/stack_rb.html +0 -52
- data/doc/ds/trees/binary_heap_rb.html +0 -52
- data/doc/ds/trees/binary_search_tree_rb.html +0 -52
- data/doc/ds/trees/binary_tree_rb.html +0 -52
- data/doc/ds/trees/complete_binary_tree_rb.html +0 -52
- data/doc/ds/trees/tree_rb.html +0 -52
- data/doc/ds/trees/tree_walker_rb.html +0 -52
- data/doc/ds/version_rb.html +0 -52
- data/doc/ds_rb.html +0 -98
- data/doc/ext/ext_rb.html +0 -52
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +0 -375
- data/doc/js/darkfish.js +0 -116
- data/doc/js/jquery.js +0 -32
- data/doc/js/quicksearch.js +0 -114
- data/doc/js/thickbox-compressed.js +0 -10
- data/doc/rdoc.css +0 -763
- data/lib/ds/ext/ext.rb +0 -36
- data/lib/ds/graphs/graph_as_list.rb +0 -48
data/test/test_queue.rb
CHANGED
@@ -21,11 +21,11 @@ describe Queue do
|
|
21
21
|
describe "Not empty queue" do
|
22
22
|
|
23
23
|
before do
|
24
|
-
@queue = Queue.new
|
24
|
+
@queue = DS::Queue.new
|
25
25
|
@queue.enqueue 1
|
26
26
|
@queue.enqueue 2
|
27
27
|
|
28
|
-
@queue2 = Queue.create
|
28
|
+
@queue2 = DS::Queue.create
|
29
29
|
@queue2.enqueue 1
|
30
30
|
@queue2.enqueue 2
|
31
31
|
end
|
@@ -104,7 +104,7 @@ describe Queue do
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
|
-
|
108
107
|
end
|
108
|
+
|
109
109
|
end
|
110
110
|
end
|
data/test/test_stack.rb
CHANGED
data/test/test_tree.rb
CHANGED
@@ -19,24 +19,47 @@ describe Tree do
|
|
19
19
|
@tree.to_a.must_equal [2,5,8,9,4,10,3]
|
20
20
|
end
|
21
21
|
|
22
|
-
it "
|
23
|
-
@tree
|
22
|
+
it "<< should add new subtree to tree." do
|
23
|
+
subtree = @tree << 7
|
24
|
+
subtree.must_be_kind_of Tree
|
25
|
+
@tree.children.size.must_equal 4
|
24
26
|
end
|
25
27
|
|
26
|
-
it "#
|
27
|
-
@tree.
|
28
|
+
it "#leaf? should check if node is a leaf." do
|
29
|
+
refute @tree.leaf?
|
30
|
+
assert @tree.children.last.leaf?
|
31
|
+
end
|
32
|
+
|
33
|
+
it "#get_leaves should return list of tree leaves." do
|
34
|
+
leaves = @tree.get_leaves
|
35
|
+
leaves.must_be_kind_of List
|
36
|
+
leaves.to_a.collect{ |e| e.data }.must_equal [4,10,3,9]
|
28
37
|
end
|
29
38
|
|
30
39
|
it "#leaf_count should return number of tree leaves." do
|
31
40
|
@tree.leaf_count.must_equal 4
|
32
41
|
end
|
33
|
-
|
34
|
-
it "#
|
35
|
-
@tree.
|
42
|
+
|
43
|
+
it "#levels should return number of nodes on each tree level." do
|
44
|
+
@tree.levels.must_equal 1 => 1, 2 => 3, 3 => 3
|
36
45
|
end
|
37
46
|
|
38
|
-
|
39
|
-
|
47
|
+
|
48
|
+
it "#height should return tree height." do
|
49
|
+
@tree.height.must_equal 3
|
50
|
+
end
|
51
|
+
|
52
|
+
it "Tree.h should return subtree height." do
|
53
|
+
Tree.h(@tree.children.last).must_equal 1
|
54
|
+
end
|
55
|
+
|
56
|
+
it "#width should return tree width." do
|
57
|
+
@tree.width.must_equal 3
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
it "#lowest_height should return node which lies closest to the root." do
|
62
|
+
@tree.lowest_height.data.must_equal 9
|
40
63
|
end
|
41
64
|
|
42
65
|
it "#mirror! should mirror tree." do
|
data/test/test_tree_walker.rb
CHANGED
@@ -48,20 +48,42 @@ describe TreeWalker do
|
|
48
48
|
|
49
49
|
it "should traverse in BFS order." do
|
50
50
|
@bin_walker.traverse(:bfs).must_equal [2,5,8,9,11,12,14]
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should traverse in preorder." do
|
55
|
+
@bin_walker.traverse(:preorder).must_equal [2,5,9,11,8,12,14]
|
56
|
+
|
57
|
+
arr = []
|
58
|
+
@bin_walker.traverse(:preorder){|t| arr << t.data}
|
59
|
+
arr.must_equal [2,5,9,11,8,12,14]
|
51
60
|
end
|
52
61
|
|
62
|
+
|
53
63
|
it "should traverse in postorder." do
|
54
64
|
@bin_walker.traverse(:postorder).must_equal [9,11,5,12,14,8,2]
|
65
|
+
|
66
|
+
arr = []
|
67
|
+
@bin_walker.traverse(:postorder){|t| arr << t.data}
|
68
|
+
arr.must_equal [9,11,5,12,14,8,2]
|
55
69
|
end
|
56
70
|
|
57
71
|
it "should traverse in inorder." do
|
58
72
|
@bin_walker.traverse(:inorder).must_equal [9,5,11,2,12,8,14]
|
73
|
+
|
74
|
+
arr = []
|
75
|
+
@bin_walker.traverse(:inorder){|t| arr << t.data}
|
76
|
+
arr.must_equal [9,5,11,2,12,8,14]
|
59
77
|
end
|
60
78
|
|
61
79
|
it "#summarize should transform tree." do
|
62
80
|
@bin_walker.summarize(:bottomup).to_a.must_equal [61,25,34,9,11,12,14]
|
63
81
|
end
|
64
82
|
|
83
|
+
it "recalculate! should change values of tree nodes." do
|
84
|
+
@bin_walker.summarize(:inorder).to_a.must_equal [2,5,10,9,16,14,24]
|
85
|
+
end
|
86
|
+
|
65
87
|
end
|
66
88
|
end
|
67
89
|
|
data/test/test_trie.rb
CHANGED
@@ -4,11 +4,29 @@ describe Trie do
|
|
4
4
|
|
5
5
|
before do
|
6
6
|
@trie = Trie.new
|
7
|
+
@dict = Trie.new
|
8
|
+
@dict.insert("hello")
|
7
9
|
end
|
8
10
|
|
9
11
|
it "#insert should add new string to trie." do
|
10
|
-
@trie.insert("thing"
|
11
|
-
assert @trie.find("thing")
|
12
|
+
@trie.insert("thing");
|
13
|
+
assert @trie.find("thing")
|
14
|
+
|
15
|
+
@trie.insert("think")
|
16
|
+
assert @trie.find("thing")
|
17
|
+
|
18
|
+
@trie.insert("math")
|
19
|
+
assert @trie.find("math")
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should not find not added word." do
|
24
|
+
@dict.find("blah").must_be_nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should raise error if character is not in trie alphabet." do
|
28
|
+
proc {@dict.find("m%$r")}.must_raise ArgumentError
|
29
|
+
proc {@dict.insert("m%$r")}.must_raise ArgumentError
|
12
30
|
end
|
13
31
|
|
14
32
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- knife
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-02-26 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: Data structures (lists,stacks, trees, heaps, graphs..) in pure Ruby.
|
@@ -30,88 +30,14 @@ extra_rdoc_files: []
|
|
30
30
|
files:
|
31
31
|
- .gitignore
|
32
32
|
- Gemfile
|
33
|
+
- README.rdoc
|
33
34
|
- Rakefile
|
34
|
-
- doc/Array.html
|
35
|
-
- doc/DS.html
|
36
|
-
- doc/DS/Array2D.html
|
37
|
-
- doc/DS/BinaryHeap.html
|
38
|
-
- doc/DS/BinarySearchTree.html
|
39
|
-
- doc/DS/BinaryTree.html
|
40
|
-
- doc/DS/CompleteBinaryTree.html
|
41
|
-
- doc/DS/CyclicList.html
|
42
|
-
- doc/DS/Digraph.html
|
43
|
-
- doc/DS/Edge.html
|
44
|
-
- doc/DS/ExpandableArray.html
|
45
|
-
- doc/DS/Graph.html
|
46
|
-
- doc/DS/GraphAsList.html
|
47
|
-
- doc/DS/GraphAsMatrix.html
|
48
|
-
- doc/DS/GraphAsTriMatrix.html
|
49
|
-
- doc/DS/List.html
|
50
|
-
- doc/DS/ListElement.html
|
51
|
-
- doc/DS/Queue.html
|
52
|
-
- doc/DS/Ring.html
|
53
|
-
- doc/DS/Stack.html
|
54
|
-
- doc/DS/Tree.html
|
55
|
-
- doc/DS/TreeWalker.html
|
56
|
-
- doc/DS/TriMatrix.html
|
57
|
-
- doc/created.rid
|
58
|
-
- doc/ds/graphs/digraph_rb.html
|
59
|
-
- doc/ds/graphs/edge_rb.html
|
60
|
-
- doc/ds/graphs/graph_as_list_rb.html
|
61
|
-
- doc/ds/graphs/graph_as_matrix_rb.html
|
62
|
-
- doc/ds/graphs/graph_as_tri_matrix_rb.html
|
63
|
-
- doc/ds/graphs/graph_rb.html
|
64
|
-
- doc/ds/lists/cyclic_list_rb.html
|
65
|
-
- doc/ds/lists/list_element_rb.html
|
66
|
-
- doc/ds/lists/list_rb.html
|
67
|
-
- doc/ds/lists/ring_rb.html
|
68
|
-
- doc/ds/matrixes/array_2d_rb.html
|
69
|
-
- doc/ds/matrixes/expandable_array_rb.html
|
70
|
-
- doc/ds/matrixes/tri_matrix_rb.html
|
71
|
-
- doc/ds/queues/queue_rb.html
|
72
|
-
- doc/ds/stacks/stack_rb.html
|
73
|
-
- doc/ds/trees/binary_heap_rb.html
|
74
|
-
- doc/ds/trees/binary_search_tree_rb.html
|
75
|
-
- doc/ds/trees/binary_tree_rb.html
|
76
|
-
- doc/ds/trees/complete_binary_tree_rb.html
|
77
|
-
- doc/ds/trees/tree_rb.html
|
78
|
-
- doc/ds/trees/tree_walker_rb.html
|
79
|
-
- doc/ds/version_rb.html
|
80
|
-
- doc/ds_rb.html
|
81
|
-
- doc/ext/ext_rb.html
|
82
|
-
- doc/images/brick.png
|
83
|
-
- doc/images/brick_link.png
|
84
|
-
- doc/images/bug.png
|
85
|
-
- doc/images/bullet_black.png
|
86
|
-
- doc/images/bullet_toggle_minus.png
|
87
|
-
- doc/images/bullet_toggle_plus.png
|
88
|
-
- doc/images/date.png
|
89
|
-
- doc/images/find.png
|
90
|
-
- doc/images/loadingAnimation.gif
|
91
|
-
- doc/images/macFFBgHack.png
|
92
|
-
- doc/images/package.png
|
93
|
-
- doc/images/page_green.png
|
94
|
-
- doc/images/page_white_text.png
|
95
|
-
- doc/images/page_white_width.png
|
96
|
-
- doc/images/plugin.png
|
97
|
-
- doc/images/ruby.png
|
98
|
-
- doc/images/tag_green.png
|
99
|
-
- doc/images/wrench.png
|
100
|
-
- doc/images/wrench_orange.png
|
101
|
-
- doc/images/zoom.png
|
102
|
-
- doc/index.html
|
103
|
-
- doc/js/darkfish.js
|
104
|
-
- doc/js/jquery.js
|
105
|
-
- doc/js/quicksearch.js
|
106
|
-
- doc/js/thickbox-compressed.js
|
107
|
-
- doc/rdoc.css
|
108
35
|
- ds.gemspec
|
109
36
|
- lib/ds.rb
|
110
|
-
- lib/ds/ext/
|
37
|
+
- lib/ds/ext/array_x.rb
|
111
38
|
- lib/ds/graphs/digraph.rb
|
112
39
|
- lib/ds/graphs/edge.rb
|
113
40
|
- lib/ds/graphs/graph.rb
|
114
|
-
- lib/ds/graphs/graph_as_list.rb
|
115
41
|
- lib/ds/graphs/graph_as_matrix.rb
|
116
42
|
- lib/ds/graphs/graph_as_tri_matrix.rb
|
117
43
|
- lib/ds/lists/cyclic_list.rb
|
@@ -121,7 +47,10 @@ files:
|
|
121
47
|
- lib/ds/matrixes/array_2d.rb
|
122
48
|
- lib/ds/matrixes/expandable_array.rb
|
123
49
|
- lib/ds/matrixes/tri_matrix.rb
|
50
|
+
- lib/ds/pair.rb
|
51
|
+
- lib/ds/queues/priority_queue.rb
|
124
52
|
- lib/ds/queues/queue.rb
|
53
|
+
- lib/ds/sets/ordered_set.rb
|
125
54
|
- lib/ds/stacks/stack.rb
|
126
55
|
- lib/ds/trees/binary_heap.rb
|
127
56
|
- lib/ds/trees/binary_search_tree.rb
|
@@ -143,6 +72,9 @@ files:
|
|
143
72
|
- test/test_graph.rb
|
144
73
|
- test/test_list.rb
|
145
74
|
- test/test_list_element.rb
|
75
|
+
- test/test_ordered_set.rb
|
76
|
+
- test/test_pair.rb
|
77
|
+
- test/test_priority_queue.rb
|
146
78
|
- test/test_queue.rb
|
147
79
|
- test/test_ring.rb
|
148
80
|
- test/test_stack.rb
|
@@ -179,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
111
|
requirements: []
|
180
112
|
|
181
113
|
rubyforge_project: ds
|
182
|
-
rubygems_version: 1.
|
114
|
+
rubygems_version: 1.8.11
|
183
115
|
signing_key:
|
184
116
|
specification_version: 3
|
185
117
|
summary: Some common data structures.
|
data/doc/Array.html
DELETED
@@ -1,264 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
-
<head>
|
6
|
-
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
7
|
-
|
8
|
-
<title>Class: Array</title>
|
9
|
-
|
10
|
-
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
|
11
|
-
|
12
|
-
<script src="./js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
13
|
-
<script src="./js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
|
14
|
-
<script src="./js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
15
|
-
<script src="./js/darkfish.js" type="text/javascript" charset="utf-8"></script>
|
16
|
-
|
17
|
-
</head>
|
18
|
-
<body id="top" class="class">
|
19
|
-
|
20
|
-
<div id="metadata">
|
21
|
-
<div id="home-metadata">
|
22
|
-
<div id="home-section" class="section">
|
23
|
-
<h3 class="section-header">
|
24
|
-
<a href="./index.html">Home</a>
|
25
|
-
<a href="./index.html#classes">Classes</a>
|
26
|
-
<a href="./index.html#methods">Methods</a>
|
27
|
-
</h3>
|
28
|
-
</div>
|
29
|
-
</div>
|
30
|
-
|
31
|
-
<div id="file-metadata">
|
32
|
-
<div id="file-list-section" class="section">
|
33
|
-
<h3 class="section-header">In Files</h3>
|
34
|
-
<div class="section-body">
|
35
|
-
<ul>
|
36
|
-
|
37
|
-
<li><a href="./ext/ext_rb.html?TB_iframe=true&height=550&width=785"
|
38
|
-
class="thickbox" title="ext/ext.rb">ext/ext.rb</a></li>
|
39
|
-
|
40
|
-
</ul>
|
41
|
-
</div>
|
42
|
-
</div>
|
43
|
-
|
44
|
-
|
45
|
-
</div>
|
46
|
-
|
47
|
-
<div id="class-metadata">
|
48
|
-
|
49
|
-
<!-- Parent Class -->
|
50
|
-
<div id="parent-class-section" class="section">
|
51
|
-
<h3 class="section-header">Parent</h3>
|
52
|
-
|
53
|
-
<p class="link">Object</p>
|
54
|
-
|
55
|
-
</div>
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
<!-- Method Quickref -->
|
64
|
-
<div id="method-list-section" class="section">
|
65
|
-
<h3 class="section-header">Methods</h3>
|
66
|
-
<ul class="link-list">
|
67
|
-
|
68
|
-
<li><a href="#method-i-push_uniq">#push_uniq</a></li>
|
69
|
-
|
70
|
-
<li><a href="#method-i-sorted-3F">#sorted?</a></li>
|
71
|
-
|
72
|
-
</ul>
|
73
|
-
</div>
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
</div>
|
78
|
-
|
79
|
-
<div id="project-metadata">
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
<div id="classindex-section" class="section project-section">
|
84
|
-
<h3 class="section-header">Class/Module Index
|
85
|
-
<span class="search-toggle"><img src="./images/find.png"
|
86
|
-
height="16" width="16" alt="[+]"
|
87
|
-
title="show/hide quicksearch" /></span></h3>
|
88
|
-
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
89
|
-
<fieldset>
|
90
|
-
<legend>Quicksearch</legend>
|
91
|
-
<input type="text" name="quicksearch" value=""
|
92
|
-
class="quicksearch-field" />
|
93
|
-
</fieldset>
|
94
|
-
</form>
|
95
|
-
|
96
|
-
<ul class="link-list">
|
97
|
-
|
98
|
-
<li><a href="./DS.html">DS</a></li>
|
99
|
-
|
100
|
-
<li><a href="./DS/Array2D.html">DS::Array2D</a></li>
|
101
|
-
|
102
|
-
<li><a href="./DS/BinaryHeap.html">DS::BinaryHeap</a></li>
|
103
|
-
|
104
|
-
<li><a href="./DS/BinarySearchTree.html">DS::BinarySearchTree</a></li>
|
105
|
-
|
106
|
-
<li><a href="./DS/BinaryTree.html">DS::BinaryTree</a></li>
|
107
|
-
|
108
|
-
<li><a href="./DS/CompleteBinaryTree.html">DS::CompleteBinaryTree</a></li>
|
109
|
-
|
110
|
-
<li><a href="./DS/CyclicList.html">DS::CyclicList</a></li>
|
111
|
-
|
112
|
-
<li><a href="./DS/Digraph.html">DS::Digraph</a></li>
|
113
|
-
|
114
|
-
<li><a href="./DS/Edge.html">DS::Edge</a></li>
|
115
|
-
|
116
|
-
<li><a href="./DS/ExpandableArray.html">DS::ExpandableArray</a></li>
|
117
|
-
|
118
|
-
<li><a href="./DS/Graph.html">DS::Graph</a></li>
|
119
|
-
|
120
|
-
<li><a href="./DS/GraphAsList.html">DS::GraphAsList</a></li>
|
121
|
-
|
122
|
-
<li><a href="./DS/GraphAsMatrix.html">DS::GraphAsMatrix</a></li>
|
123
|
-
|
124
|
-
<li><a href="./DS/GraphAsTriMatrix.html">DS::GraphAsTriMatrix</a></li>
|
125
|
-
|
126
|
-
<li><a href="./DS/List.html">DS::List</a></li>
|
127
|
-
|
128
|
-
<li><a href="./DS/ListElement.html">DS::ListElement</a></li>
|
129
|
-
|
130
|
-
<li><a href="./DS/Queue.html">DS::Queue</a></li>
|
131
|
-
|
132
|
-
<li><a href="./DS/Ring.html">DS::Ring</a></li>
|
133
|
-
|
134
|
-
<li><a href="./DS/Stack.html">DS::Stack</a></li>
|
135
|
-
|
136
|
-
<li><a href="./DS/Tree.html">DS::Tree</a></li>
|
137
|
-
|
138
|
-
<li><a href="./DS/TreeWalker.html">DS::TreeWalker</a></li>
|
139
|
-
|
140
|
-
<li><a href="./DS/TriMatrix.html">DS::TriMatrix</a></li>
|
141
|
-
|
142
|
-
<li><a href="./Array.html">Array</a></li>
|
143
|
-
|
144
|
-
</ul>
|
145
|
-
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
146
|
-
</div>
|
147
|
-
|
148
|
-
|
149
|
-
</div>
|
150
|
-
</div>
|
151
|
-
|
152
|
-
<div id="documentation">
|
153
|
-
<h1 class="class">Array</h1>
|
154
|
-
|
155
|
-
<div id="description" class="description">
|
156
|
-
|
157
|
-
</div><!-- description -->
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
<div id="5Buntitled-5D" class="documentation-section">
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
<!-- Methods -->
|
172
|
-
|
173
|
-
<div id="public-instance-method-details" class="method-section section">
|
174
|
-
<h3 class="section-header">Public Instance Methods</h3>
|
175
|
-
|
176
|
-
|
177
|
-
<div id="push_uniq-method" class="method-detail ">
|
178
|
-
<a name="method-i-push_uniq"></a>
|
179
|
-
|
180
|
-
|
181
|
-
<div class="method-heading">
|
182
|
-
<span class="method-name">push_uniq</span><span
|
183
|
-
class="method-args">(e)</span>
|
184
|
-
<span class="method-click-advice">click to toggle source</span>
|
185
|
-
</div>
|
186
|
-
|
187
|
-
|
188
|
-
<div class="method-description">
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
<div class="method-source-code" id="push_uniq-source">
|
195
|
-
<pre>
|
196
|
-
<span class="ruby-comment"># File ext/ext.rb, line 7</span>
|
197
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">push_uniq</span> <span class="ruby-identifier">e</span>
|
198
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">include?</span> <span class="ruby-identifier">e</span>
|
199
|
-
<span class="ruby-identifier">index</span> <span class="ruby-identifier">e</span>
|
200
|
-
<span class="ruby-keyword">else</span>
|
201
|
-
<span class="ruby-identifier">push</span> <span class="ruby-identifier">e</span>
|
202
|
-
<span class="ruby-identifier">size</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>
|
203
|
-
<span class="ruby-keyword">end</span>
|
204
|
-
<span class="ruby-keyword">end</span></pre>
|
205
|
-
</div><!-- push_uniq-source -->
|
206
|
-
|
207
|
-
</div>
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
</div><!-- push_uniq-method -->
|
213
|
-
|
214
|
-
|
215
|
-
<div id="sorted-3F-method" class="method-detail ">
|
216
|
-
<a name="method-i-sorted-3F"></a>
|
217
|
-
|
218
|
-
|
219
|
-
<div class="method-heading">
|
220
|
-
<span class="method-name">sorted?</span><span
|
221
|
-
class="method-args">(order = :growing)</span>
|
222
|
-
<span class="method-click-advice">click to toggle source</span>
|
223
|
-
</div>
|
224
|
-
|
225
|
-
|
226
|
-
<div class="method-description">
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
<div class="method-source-code" id="sorted-3F-source">
|
233
|
-
<pre>
|
234
|
-
<span class="ruby-comment"># File ext/ext.rb, line 2</span>
|
235
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">sorted?</span>(<span class="ruby-identifier">order</span> = <span class="ruby-value">:growing</span>)
|
236
|
-
(<span class="ruby-identifier">size</span><span class="ruby-operator">-</span><span class="ruby-value">2</span>).<span class="ruby-identifier">times</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>[<span class="ruby-identifier">i</span>] <span class="ruby-operator">></span> <span class="ruby-keyword">self</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">+</span><span class="ruby-value">1</span>] }
|
237
|
-
<span class="ruby-keyword">true</span>
|
238
|
-
<span class="ruby-keyword">end</span></pre>
|
239
|
-
</div><!-- sorted-3F-source -->
|
240
|
-
|
241
|
-
</div>
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
</div><!-- sorted-3F-method -->
|
247
|
-
|
248
|
-
|
249
|
-
</div><!-- public-instance-method-details -->
|
250
|
-
|
251
|
-
</div><!-- 5Buntitled-5D -->
|
252
|
-
|
253
|
-
|
254
|
-
</div><!-- documentation -->
|
255
|
-
|
256
|
-
<div id="validator-badges">
|
257
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
258
|
-
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
259
|
-
Rdoc Generator</a> 2</small>.</p>
|
260
|
-
</div>
|
261
|
-
|
262
|
-
</body>
|
263
|
-
</html>
|
264
|
-
|