grosser-algorithms 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +45 -0
- data/VERSION +1 -0
- data/ext/containers/bst/bst.c +249 -0
- data/ext/containers/bst/extconf.rb +4 -0
- data/grosser-algorithms.gemspec +4 -4
- data/rdoc/classes/Algorithms.html +221 -0
- data/rdoc/classes/Algorithms/Algorithms.html +115 -0
- data/rdoc/classes/Algorithms/Algorithms/Sort.html +569 -0
- data/rdoc/classes/Algorithms/Containers.html +162 -0
- data/rdoc/classes/Algorithms/Containers/Heap.html +690 -0
- data/rdoc/classes/Algorithms/Containers/KDTree.html +195 -0
- data/rdoc/classes/Algorithms/Containers/MaxHeap.html +238 -0
- data/rdoc/classes/Algorithms/Containers/MinHeap.html +238 -0
- data/rdoc/classes/Algorithms/Containers/PriorityQueue.html +456 -0
- data/rdoc/classes/Algorithms/Containers/Queue.html +363 -0
- data/rdoc/classes/Algorithms/Containers/RubyDeque.html +617 -0
- data/rdoc/classes/Algorithms/Containers/RubyRBTreeMap.html +662 -0
- data/rdoc/classes/Algorithms/Containers/RubySplayTreeMap.html +623 -0
- data/rdoc/classes/Algorithms/Containers/Stack.html +363 -0
- data/rdoc/classes/Algorithms/Containers/SuffixArray.html +246 -0
- data/rdoc/classes/Algorithms/Containers/Trie.html +555 -0
- data/rdoc/classes/Algorithms/Search.html +273 -0
- data/rdoc/created.rid +1 -0
- data/rdoc/files/History_txt.html +281 -0
- data/rdoc/files/README_markdown.html +248 -0
- data/rdoc/files/lib/algorithms/search_rb.html +108 -0
- data/rdoc/files/lib/algorithms/sort_rb.html +108 -0
- data/rdoc/files/lib/algorithms/string_rb.html +115 -0
- data/rdoc/files/lib/algorithms_rb.html +252 -0
- data/rdoc/files/lib/containers/deque_rb.html +119 -0
- data/rdoc/files/lib/containers/heap_rb.html +124 -0
- data/rdoc/files/lib/containers/kd_tree_rb.html +135 -0
- data/rdoc/files/lib/containers/priority_queue_rb.html +108 -0
- data/rdoc/files/lib/containers/queue_rb.html +108 -0
- data/rdoc/files/lib/containers/rb_tree_map_rb.html +109 -0
- data/rdoc/files/lib/containers/splay_tree_map_rb.html +109 -0
- data/rdoc/files/lib/containers/stack_rb.html +108 -0
- data/rdoc/files/lib/containers/suffix_array_rb.html +113 -0
- data/rdoc/files/lib/containers/trie_rb.html +117 -0
- data/rdoc/fr_class_index.html +43 -0
- data/rdoc/fr_file_index.html +42 -0
- data/rdoc/fr_method_index.html +147 -0
- data/rdoc/index.html +24 -0
- data/rdoc/rdoc-style.css +208 -0
- data/spec/bst_gc_mark_spec.rb +25 -0
- data/spec/bst_spec.rb +25 -0
- metadata +50 -3
@@ -0,0 +1,115 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>File: string.rb</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="fileHeader">
|
50
|
+
<h1>string.rb</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>lib/algorithms/string.rb
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Tue Aug 10 13:58:23 +0200 2010</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
This module implements string algorithms. Documentation is provided for
|
74
|
+
each algorithm.
|
75
|
+
</p>
|
76
|
+
|
77
|
+
</div>
|
78
|
+
|
79
|
+
<div id="requires-list">
|
80
|
+
<h3 class="section-bar">Required files</h3>
|
81
|
+
|
82
|
+
<div class="name-list">
|
83
|
+
CString
|
84
|
+
</div>
|
85
|
+
</div>
|
86
|
+
|
87
|
+
</div>
|
88
|
+
|
89
|
+
|
90
|
+
</div>
|
91
|
+
|
92
|
+
|
93
|
+
<!-- if includes -->
|
94
|
+
|
95
|
+
<div id="section">
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
<!-- if method_list -->
|
105
|
+
|
106
|
+
|
107
|
+
</div>
|
108
|
+
|
109
|
+
|
110
|
+
<div id="validator-badges">
|
111
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
112
|
+
</div>
|
113
|
+
|
114
|
+
</body>
|
115
|
+
</html>
|
@@ -0,0 +1,252 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>File: algorithms.rb</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="fileHeader">
|
50
|
+
<h1>algorithms.rb</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>lib/algorithms.rb
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Tue Aug 10 14:28:08 +0200 2010</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
The ‘<a href="../../classes/Algorithms.html">Algorithms</a> and
|
74
|
+
Containers’ library is an effort to provide a set of commonly used
|
75
|
+
algorithms and containers to Ruby programmers.
|
76
|
+
</p>
|
77
|
+
<p>
|
78
|
+
This is a Google Summer of Code 2008 project
|
79
|
+
</p>
|
80
|
+
<p>
|
81
|
+
Written by Kanwei Li, mentored by Austin Ziegler
|
82
|
+
</p>
|
83
|
+
<p>
|
84
|
+
To avoid typing Algorithms::Containers::xxx to initialize containers,
|
85
|
+
include the <a href="../../classes/Algorithms.html">Algorithms</a>
|
86
|
+
namespace and Containers module.
|
87
|
+
</p>
|
88
|
+
<pre>
|
89
|
+
require 'algorithms'
|
90
|
+
include Algorithms
|
91
|
+
include Containers
|
92
|
+
|
93
|
+
tree = RBTreeMap.new
|
94
|
+
</pre>
|
95
|
+
<p>
|
96
|
+
instead of:
|
97
|
+
</p>
|
98
|
+
<pre>
|
99
|
+
require 'algorithms'
|
100
|
+
|
101
|
+
tree = Algorithms::Containers::RBTreeMap.new
|
102
|
+
</pre>
|
103
|
+
<p>
|
104
|
+
Done so far:
|
105
|
+
</p>
|
106
|
+
<ul>
|
107
|
+
<li>Heaps - <a
|
108
|
+
href="../../classes/Algorithms/Containers/Heap.html">Algorithms::Containers::Heap</a>,
|
109
|
+
<a
|
110
|
+
href="../../classes/Algorithms/Containers/MaxHeap.html">Algorithms::Containers::MaxHeap</a>,
|
111
|
+
<a
|
112
|
+
href="../../classes/Algorithms/Containers/MinHeap.html">Algorithms::Containers::MinHeap</a>
|
113
|
+
|
114
|
+
</li>
|
115
|
+
<li>Priority Queue - <a
|
116
|
+
href="../../classes/Algorithms/Containers/PriorityQueue.html">Algorithms::Containers::PriorityQueue</a>
|
117
|
+
|
118
|
+
</li>
|
119
|
+
<li>Stack - <a
|
120
|
+
href="../../classes/Algorithms/Containers/Stack.html">Algorithms::Containers::Stack</a>
|
121
|
+
|
122
|
+
</li>
|
123
|
+
<li>Queue - <a
|
124
|
+
href="../../classes/Algorithms/Containers/Queue.html">Algorithms::Containers::Queue</a>
|
125
|
+
|
126
|
+
</li>
|
127
|
+
<li>Deque - Algorithms::Containers::Deque, Algorithms::Containers::CDeque (C
|
128
|
+
extension), <a
|
129
|
+
href="../../classes/Algorithms/Containers/RubyDeque.html">Algorithms::Containers::RubyDeque</a>
|
130
|
+
|
131
|
+
</li>
|
132
|
+
<li>Red-Black Trees - Algorithms::Containers::RBTreeMap,
|
133
|
+
Algorithms::Containers::CRBTreeMap (C extension), <a
|
134
|
+
href="../../classes/Algorithms/Containers/RubyRBTreeMap.html">Algorithms::Containers::RubyRBTreeMap</a>
|
135
|
+
|
136
|
+
</li>
|
137
|
+
<li>Splay Trees - Algorithms::Containers::SplayTreeMap
|
138
|
+
|
139
|
+
</li>
|
140
|
+
<li>Tries - <a
|
141
|
+
href="../../classes/Algorithms/Containers/Trie.html">Algorithms::Containers::Trie</a>
|
142
|
+
|
143
|
+
</li>
|
144
|
+
<li>Suffix Array - <a
|
145
|
+
href="../../classes/Algorithms/Containers/SuffixArray.html">Algorithms::Containers::SuffixArray</a>
|
146
|
+
|
147
|
+
</li>
|
148
|
+
<li>kd Tree - <a
|
149
|
+
href="../../classes/Algorithms/Containers/KDTree.html">Algorithms::Containers::KDTree</a>
|
150
|
+
|
151
|
+
</li>
|
152
|
+
<li>Search algorithms
|
153
|
+
|
154
|
+
<ul>
|
155
|
+
<li>Binary Search - Algorithms::Algorithms::Search.binary_search
|
156
|
+
|
157
|
+
</li>
|
158
|
+
<li>Knuth-Morris-Pratt - Algorithms::Algorithms::Search.kmp_search
|
159
|
+
|
160
|
+
</li>
|
161
|
+
</ul>
|
162
|
+
</li>
|
163
|
+
<li>Sort algorithms
|
164
|
+
|
165
|
+
<ul>
|
166
|
+
<li>Bubble sort - Algorithms::Algorithms::Sort.bubble_sort
|
167
|
+
|
168
|
+
</li>
|
169
|
+
<li>Comb sort - Algorithms::Algorithms::Sort.comb_sort
|
170
|
+
|
171
|
+
</li>
|
172
|
+
<li>Selection sort - Algorithms::Algorithms::Sort.selection_sort
|
173
|
+
|
174
|
+
</li>
|
175
|
+
<li>Heapsort - Algorithms::Algorithms::Sort.heapsort
|
176
|
+
|
177
|
+
</li>
|
178
|
+
<li>Insertion sort - Algorithms::Algorithms::Sort.insertion_sort
|
179
|
+
|
180
|
+
</li>
|
181
|
+
<li>Shell sort - Algorithms::Algorithms::Sort.shell_sort
|
182
|
+
|
183
|
+
</li>
|
184
|
+
<li>Quicksort - Algorithms::Algorithms::Sort.quicksort
|
185
|
+
|
186
|
+
</li>
|
187
|
+
<li>Mergesort - Algorithms::Algorithms::Sort.mergesort
|
188
|
+
|
189
|
+
</li>
|
190
|
+
</ul>
|
191
|
+
</li>
|
192
|
+
<li>String algorithms
|
193
|
+
|
194
|
+
<ul>
|
195
|
+
<li>Levenshtein distance - Algorithms::Algorithms::String.levenshtein_dist
|
196
|
+
|
197
|
+
</li>
|
198
|
+
</ul>
|
199
|
+
</li>
|
200
|
+
</ul>
|
201
|
+
|
202
|
+
</div>
|
203
|
+
|
204
|
+
<div id="requires-list">
|
205
|
+
<h3 class="section-bar">Required files</h3>
|
206
|
+
|
207
|
+
<div class="name-list">
|
208
|
+
algorithms/search
|
209
|
+
algorithms/sort
|
210
|
+
algorithms/string
|
211
|
+
containers/heap
|
212
|
+
containers/stack
|
213
|
+
containers/deque
|
214
|
+
containers/queue
|
215
|
+
containers/priority_queue
|
216
|
+
containers/rb_tree_map
|
217
|
+
containers/splay_tree_map
|
218
|
+
containers/suffix_array
|
219
|
+
containers/trie
|
220
|
+
containers/kd_tree
|
221
|
+
</div>
|
222
|
+
</div>
|
223
|
+
|
224
|
+
</div>
|
225
|
+
|
226
|
+
|
227
|
+
</div>
|
228
|
+
|
229
|
+
|
230
|
+
<!-- if includes -->
|
231
|
+
|
232
|
+
<div id="section">
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
<!-- if method_list -->
|
242
|
+
|
243
|
+
|
244
|
+
</div>
|
245
|
+
|
246
|
+
|
247
|
+
<div id="validator-badges">
|
248
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
249
|
+
</div>
|
250
|
+
|
251
|
+
</body>
|
252
|
+
</html>
|
@@ -0,0 +1,119 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>File: deque.rb</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="fileHeader">
|
50
|
+
<h1>deque.rb</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>lib/containers/deque.rb
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Tue Aug 10 13:58:23 +0200 2010</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
A Deque is a container that allows items to be added and removed from both
|
74
|
+
the front and back, acting as a combination of a Stack and Queue.
|
75
|
+
</p>
|
76
|
+
<p>
|
77
|
+
This implementation uses a doubly-linked list, guaranteeing O(1) complexity
|
78
|
+
for all operations.
|
79
|
+
</p>
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
<div id="requires-list">
|
84
|
+
<h3 class="section-bar">Required files</h3>
|
85
|
+
|
86
|
+
<div class="name-list">
|
87
|
+
CDeque
|
88
|
+
</div>
|
89
|
+
</div>
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
|
97
|
+
<!-- if includes -->
|
98
|
+
|
99
|
+
<div id="section">
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
<!-- if method_list -->
|
109
|
+
|
110
|
+
|
111
|
+
</div>
|
112
|
+
|
113
|
+
|
114
|
+
<div id="validator-badges">
|
115
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
116
|
+
</div>
|
117
|
+
|
118
|
+
</body>
|
119
|
+
</html>
|