grosser-algorithms 0.4.0 → 0.4.1

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.
Files changed (47) hide show
  1. data/Manifest +45 -0
  2. data/VERSION +1 -0
  3. data/ext/containers/bst/bst.c +249 -0
  4. data/ext/containers/bst/extconf.rb +4 -0
  5. data/grosser-algorithms.gemspec +4 -4
  6. data/rdoc/classes/Algorithms.html +221 -0
  7. data/rdoc/classes/Algorithms/Algorithms.html +115 -0
  8. data/rdoc/classes/Algorithms/Algorithms/Sort.html +569 -0
  9. data/rdoc/classes/Algorithms/Containers.html +162 -0
  10. data/rdoc/classes/Algorithms/Containers/Heap.html +690 -0
  11. data/rdoc/classes/Algorithms/Containers/KDTree.html +195 -0
  12. data/rdoc/classes/Algorithms/Containers/MaxHeap.html +238 -0
  13. data/rdoc/classes/Algorithms/Containers/MinHeap.html +238 -0
  14. data/rdoc/classes/Algorithms/Containers/PriorityQueue.html +456 -0
  15. data/rdoc/classes/Algorithms/Containers/Queue.html +363 -0
  16. data/rdoc/classes/Algorithms/Containers/RubyDeque.html +617 -0
  17. data/rdoc/classes/Algorithms/Containers/RubyRBTreeMap.html +662 -0
  18. data/rdoc/classes/Algorithms/Containers/RubySplayTreeMap.html +623 -0
  19. data/rdoc/classes/Algorithms/Containers/Stack.html +363 -0
  20. data/rdoc/classes/Algorithms/Containers/SuffixArray.html +246 -0
  21. data/rdoc/classes/Algorithms/Containers/Trie.html +555 -0
  22. data/rdoc/classes/Algorithms/Search.html +273 -0
  23. data/rdoc/created.rid +1 -0
  24. data/rdoc/files/History_txt.html +281 -0
  25. data/rdoc/files/README_markdown.html +248 -0
  26. data/rdoc/files/lib/algorithms/search_rb.html +108 -0
  27. data/rdoc/files/lib/algorithms/sort_rb.html +108 -0
  28. data/rdoc/files/lib/algorithms/string_rb.html +115 -0
  29. data/rdoc/files/lib/algorithms_rb.html +252 -0
  30. data/rdoc/files/lib/containers/deque_rb.html +119 -0
  31. data/rdoc/files/lib/containers/heap_rb.html +124 -0
  32. data/rdoc/files/lib/containers/kd_tree_rb.html +135 -0
  33. data/rdoc/files/lib/containers/priority_queue_rb.html +108 -0
  34. data/rdoc/files/lib/containers/queue_rb.html +108 -0
  35. data/rdoc/files/lib/containers/rb_tree_map_rb.html +109 -0
  36. data/rdoc/files/lib/containers/splay_tree_map_rb.html +109 -0
  37. data/rdoc/files/lib/containers/stack_rb.html +108 -0
  38. data/rdoc/files/lib/containers/suffix_array_rb.html +113 -0
  39. data/rdoc/files/lib/containers/trie_rb.html +117 -0
  40. data/rdoc/fr_class_index.html +43 -0
  41. data/rdoc/fr_file_index.html +42 -0
  42. data/rdoc/fr_method_index.html +147 -0
  43. data/rdoc/index.html +24 -0
  44. data/rdoc/rdoc-style.css +208 -0
  45. data/spec/bst_gc_mark_spec.rb +25 -0
  46. data/spec/bst_spec.rb +25 -0
  47. metadata +50 -3
data/Manifest CHANGED
@@ -2,18 +2,22 @@ History.txt
2
2
  Manifest
3
3
  README.markdown
4
4
  Rakefile
5
+ VERSION
5
6
  algorithms.gemspec
6
7
  benchmarks/deque.rb
7
8
  benchmarks/sorts.rb
8
9
  benchmarks/treemaps.rb
9
10
  ext/algorithms/string/extconf.rb
10
11
  ext/algorithms/string/string.c
12
+ ext/containers/bst/bst.c
13
+ ext/containers/bst/extconf.rb
11
14
  ext/containers/deque/deque.c
12
15
  ext/containers/deque/extconf.rb
13
16
  ext/containers/rbtree_map/extconf.rb
14
17
  ext/containers/rbtree_map/rbtree.c
15
18
  ext/containers/splaytree_map/extconf.rb
16
19
  ext/containers/splaytree_map/splaytree.c
20
+ grosser-algorithms.gemspec
17
21
  lib/algorithms.rb
18
22
  lib/algorithms/search.rb
19
23
  lib/algorithms/sort.rb
@@ -28,6 +32,47 @@ lib/containers/splay_tree_map.rb
28
32
  lib/containers/stack.rb
29
33
  lib/containers/suffix_array.rb
30
34
  lib/containers/trie.rb
35
+ rdoc/classes/Algorithms.html
36
+ rdoc/classes/Algorithms/Algorithms.html
37
+ rdoc/classes/Algorithms/Algorithms/Sort.html
38
+ rdoc/classes/Algorithms/Containers.html
39
+ rdoc/classes/Algorithms/Containers/Heap.html
40
+ rdoc/classes/Algorithms/Containers/KDTree.html
41
+ rdoc/classes/Algorithms/Containers/MaxHeap.html
42
+ rdoc/classes/Algorithms/Containers/MinHeap.html
43
+ rdoc/classes/Algorithms/Containers/PriorityQueue.html
44
+ rdoc/classes/Algorithms/Containers/Queue.html
45
+ rdoc/classes/Algorithms/Containers/RubyDeque.html
46
+ rdoc/classes/Algorithms/Containers/RubyRBTreeMap.html
47
+ rdoc/classes/Algorithms/Containers/RubySplayTreeMap.html
48
+ rdoc/classes/Algorithms/Containers/Stack.html
49
+ rdoc/classes/Algorithms/Containers/SuffixArray.html
50
+ rdoc/classes/Algorithms/Containers/Trie.html
51
+ rdoc/classes/Algorithms/Search.html
52
+ rdoc/created.rid
53
+ rdoc/files/History_txt.html
54
+ rdoc/files/README_markdown.html
55
+ rdoc/files/lib/algorithms/search_rb.html
56
+ rdoc/files/lib/algorithms/sort_rb.html
57
+ rdoc/files/lib/algorithms/string_rb.html
58
+ rdoc/files/lib/algorithms_rb.html
59
+ rdoc/files/lib/containers/deque_rb.html
60
+ rdoc/files/lib/containers/heap_rb.html
61
+ rdoc/files/lib/containers/kd_tree_rb.html
62
+ rdoc/files/lib/containers/priority_queue_rb.html
63
+ rdoc/files/lib/containers/queue_rb.html
64
+ rdoc/files/lib/containers/rb_tree_map_rb.html
65
+ rdoc/files/lib/containers/splay_tree_map_rb.html
66
+ rdoc/files/lib/containers/stack_rb.html
67
+ rdoc/files/lib/containers/suffix_array_rb.html
68
+ rdoc/files/lib/containers/trie_rb.html
69
+ rdoc/fr_class_index.html
70
+ rdoc/fr_file_index.html
71
+ rdoc/fr_method_index.html
72
+ rdoc/index.html
73
+ rdoc/rdoc-style.css
74
+ spec/bst_gc_mark_spec.rb
75
+ spec/bst_spec.rb
31
76
  spec/deque_gc_mark_spec.rb
32
77
  spec/deque_spec.rb
33
78
  spec/heap_spec.rb
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.4.1
@@ -0,0 +1,249 @@
1
+ #include "ruby.h"
2
+
3
+ typedef struct struct_bst_node {
4
+ VALUE key;
5
+ VALUE value;
6
+ struct struct_bst_node *left;
7
+ struct struct_bst_node *right;
8
+ struct struct_bst_node *parent;
9
+ } bst_node;
10
+
11
+ typedef struct struct_bst {
12
+ bst_node *root;
13
+ int (*compare_function)(VALUE key1, VALUE key2);
14
+ unsigned int size;
15
+ } bst;
16
+
17
+ static VALUE bst_initialize(VALUE self) {
18
+ return self;
19
+ }
20
+
21
+ static bst* get_bst_from_self(VALUE self) {
22
+ bst *tree;
23
+ Data_Get_Struct(self, bst, tree);
24
+ return tree;
25
+ }
26
+
27
+ static bst* bst_each_node(bst *tree, bst_node *node, void (*each)(bst *tree_, bst_node *node_, void* args), void* arguments) {
28
+ if (!node)
29
+ return NULL;
30
+
31
+ if (node->left)
32
+ bst_each_node(tree, node->left, each, arguments);
33
+
34
+ (*each)(tree, node, arguments);
35
+
36
+ if (node->right)
37
+ bst_each_node(tree, node->right, each, arguments);
38
+ return tree;
39
+ }
40
+
41
+ static bst* bst_each(bst *tree, void (*each)(bst *tree, bst_node *node, void *args), void* arguments) {
42
+ if (tree->root)
43
+ bst_each_node(tree, tree->root, each, arguments);
44
+ return tree;
45
+ }
46
+
47
+ static int id_compare_operator;
48
+
49
+ static int bst_compare_function(VALUE a, VALUE b) {
50
+ if (a == b) return 0;
51
+ if (FIXNUM_P(a) && FIXNUM_P(b)) {
52
+ long x = FIX2LONG(a), y = FIX2LONG(b);
53
+ if (x == y) return 0;
54
+ if (x > y) return 1;
55
+ return -1;
56
+ }
57
+ if (TYPE(a) == T_STRING && rb_obj_is_kind_of(a, rb_cString) &&
58
+ TYPE(b) == T_STRING && rb_obj_is_kind_of(b, rb_cString)) {
59
+ return rb_str_cmp(a, b);
60
+ }
61
+ return FIX2INT(rb_funcall((VALUE) a, id_compare_operator, 1, (VALUE) b));
62
+ }
63
+
64
+ static void insert_element(bst *tree, bst_node **t,bst_node *newElement) {
65
+ int cmp;
66
+ bst_node *y = NULL;
67
+ bst_node *x = *t;
68
+ while (x != NULL) {
69
+ y = x;
70
+ cmp = tree->compare_function(newElement->key, x->key);
71
+ if (cmp < 0) x = x->left;
72
+ else x = x->right;
73
+ }
74
+ newElement->parent = y;
75
+ if (y == NULL) *t = newElement;
76
+ else {
77
+ cmp = tree->compare_function(newElement->key, y->key);
78
+ if (cmp < 0)
79
+ y->left = newElement;
80
+ else
81
+ y->right = newElement;
82
+ }
83
+ }
84
+
85
+
86
+ static bst_node* create_node(VALUE key_value,VALUE value) {
87
+ bst_node *new_node = ALLOC(bst_node);
88
+ new_node->value = value;
89
+ new_node->key = key_value;
90
+ new_node->left = NULL;
91
+ new_node->right = NULL;
92
+ new_node->parent = NULL;
93
+ return new_node;
94
+ }
95
+
96
+ static bst_node* tree_minimum (bst_node *tree) {
97
+ bst_node *x = tree;
98
+ while (x->left) x = x->left;
99
+ return x;
100
+ }
101
+
102
+ static bst_node* tree_maximum (bst_node *tree) {
103
+ bst_node *x = tree;
104
+ while (x->right) x = x->right;
105
+ return x;
106
+ }
107
+
108
+ static bst_node* node_successor (bst_node *tree,bst_node *x) {
109
+ if (x->right) return tree_minimum(x->right);
110
+ bst_node *y = x->parent;
111
+ while (y && x == y->right) {
112
+ x = y;
113
+ y = x->parent;
114
+ }
115
+ return y;
116
+ }
117
+
118
+
119
+ static bst_node* delete_node (bst_node **tree,bst_node *tobeDeleted) {
120
+ bst_node *y,*x;
121
+
122
+ if ((tobeDeleted->left == NULL) || (tobeDeleted->right == NULL)) y = tobeDeleted;
123
+ else y = node_successor(*tree,tobeDeleted);
124
+
125
+ if (y->left) x = y->left;
126
+ else x = y->right;
127
+
128
+ if (x) x->parent = y->parent;
129
+
130
+ if (y->parent == NULL) {
131
+ *tree = x;
132
+ return y;
133
+ } else if (y == y->parent->left) {
134
+ y->parent->left = x;
135
+ } else {
136
+ y->parent->right = x;
137
+ }
138
+
139
+ if (tobeDeleted != y) tobeDeleted->key = y->key;
140
+ return y;
141
+ }
142
+
143
+ static bst_node* search_node(bst *tree, bst_node *node, VALUE key) {
144
+ bst_node *x = node;
145
+ int cmp;
146
+
147
+ while(x) {
148
+ cmp = tree->compare_function(key, x->key);
149
+ if (cmp == 0) return x;
150
+ else if (cmp < 0) { x = x->left; }
151
+ else { x = x->right; }
152
+ }
153
+ return NULL;
154
+ }
155
+
156
+ static void recursively_mark_nodes(bst_node *node) {
157
+ if(node) {
158
+ rb_gc_mark(node->key);
159
+ rb_gc_mark(node->value);
160
+ recursively_mark_nodes(node->left);
161
+ recursively_mark_nodes(node->right);
162
+ }
163
+ }
164
+
165
+ static void bst_mark(bst *tree) {
166
+ if (tree) {
167
+ recursively_mark_nodes(tree->root);
168
+ }
169
+ }
170
+
171
+ static void recursively_free_nodes(bst_node *node) {
172
+ if(node) {
173
+ recursively_free_nodes(node->left);
174
+ recursively_free_nodes(node->right);
175
+ free(node);
176
+ }
177
+ }
178
+
179
+ static void bst_free(bst *tree) {
180
+ if (tree) {
181
+ recursively_free_nodes(tree->root);
182
+ }
183
+ }
184
+
185
+ static bst* create_bst(int (*compare_function)(VALUE, VALUE)) {
186
+ bst *tree = ALLOC(bst);
187
+ tree->compare_function = compare_function;
188
+ tree->root = NULL;
189
+ tree->size = 0;
190
+ return tree;
191
+ }
192
+
193
+ static VALUE bst_alloc(VALUE klass) {
194
+ bst *tree = create_bst(&bst_compare_function);
195
+ return Data_Wrap_Struct(klass, bst_mark, bst_free, tree);
196
+ }
197
+
198
+ static VALUE rb_bst_push_value(VALUE self, VALUE key, VALUE value) {
199
+ bst *tree = get_bst_from_self(self);
200
+ insert_element(tree, &(tree->root), create_node(key,value));
201
+ tree->size++;
202
+ return self;
203
+ }
204
+
205
+ static void bst_each_helper(bst *tree, bst_node *node, void *args) {
206
+ rb_yield(rb_ary_new3(2, node->key, node->value));
207
+ };
208
+
209
+ static VALUE rb_bst_each(VALUE self) {
210
+ bst *tree = get_bst_from_self(self);
211
+ bst_each(tree, &bst_each_helper, NULL);
212
+ return self;
213
+ }
214
+
215
+ static VALUE rb_bst_delete(VALUE self, VALUE key) {
216
+ bst *tree = get_bst_from_self(self);
217
+ bst_node *tobeDeleted = search_node(tree, tree->root, key);
218
+ if(tobeDeleted) {
219
+ tree->size -= 1;
220
+ bst_node *deletedNode = delete_node(&(tree->root),tobeDeleted);
221
+ return deletedNode->value;
222
+ }
223
+ return Qnil;
224
+ }
225
+
226
+ static VALUE rb_bst_size(VALUE self) {
227
+ bst *tree;
228
+ Data_Get_Struct(self,bst,tree);
229
+ return INT2FIX(tree->size);
230
+ }
231
+
232
+ static VALUE CBst;
233
+ static VALUE mContainers;
234
+ static VALUE namespace;
235
+
236
+ void Init_CBst() {
237
+ id_compare_operator = rb_intern("<=>");
238
+
239
+ namespace = rb_define_module("Algorithms");
240
+ mContainers = rb_define_module_under(namespace,"Containers");
241
+ CBst = rb_define_class_under(mContainers, "CBst", rb_cObject);
242
+ rb_define_alloc_func(CBst, bst_alloc);
243
+ rb_define_method(CBst, "initialize", bst_initialize, 0);
244
+ rb_define_method(CBst, "push", rb_bst_push_value, 2);
245
+ rb_define_alias(CBst, "[]=", "push");
246
+ rb_define_method(CBst, "each", rb_bst_each, 0);
247
+ rb_define_method(CBst, "delete", rb_bst_delete, 1);
248
+ rb_define_method(CBst, "size", rb_bst_size, 0);
249
+ }
@@ -0,0 +1,4 @@
1
+ require 'mkmf'
2
+ extension_name = "CBst"
3
+ dir_config(extension_name)
4
+ create_makefile(extension_name)
@@ -2,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{grosser-algorithms}
5
- s.version = "0.4.0"
5
+ s.version = "0.4.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Kanwei Li"]
9
9
  s.date = %q{2010-08-10}
10
10
  s.description = %q{A library of algorithms and containers.}
11
11
  s.email = %q{kanwei@gmail.com}
12
- s.extensions = ["ext/algorithms/string/extconf.rb", "ext/containers/deque/extconf.rb", "ext/containers/rbtree_map/extconf.rb", "ext/containers/splaytree_map/extconf.rb"]
13
- s.extra_rdoc_files = ["README.markdown", "ext/algorithms/string/extconf.rb", "ext/algorithms/string/string.c", "ext/containers/deque/deque.c", "ext/containers/deque/extconf.rb", "ext/containers/rbtree_map/extconf.rb", "ext/containers/rbtree_map/rbtree.c", "ext/containers/splaytree_map/extconf.rb", "ext/containers/splaytree_map/splaytree.c", "lib/algorithms.rb", "lib/algorithms/search.rb", "lib/algorithms/sort.rb", "lib/algorithms/string.rb", "lib/containers/deque.rb", "lib/containers/heap.rb", "lib/containers/kd_tree.rb", "lib/containers/priority_queue.rb", "lib/containers/queue.rb", "lib/containers/rb_tree_map.rb", "lib/containers/splay_tree_map.rb", "lib/containers/stack.rb", "lib/containers/suffix_array.rb", "lib/containers/trie.rb"]
14
- s.files = ["History.txt", "Manifest", "README.markdown", "Rakefile", "algorithms.gemspec", "benchmarks/deque.rb", "benchmarks/sorts.rb", "benchmarks/treemaps.rb", "ext/algorithms/string/extconf.rb", "ext/algorithms/string/string.c", "ext/containers/deque/deque.c", "ext/containers/deque/extconf.rb", "ext/containers/rbtree_map/extconf.rb", "ext/containers/rbtree_map/rbtree.c", "ext/containers/splaytree_map/extconf.rb", "ext/containers/splaytree_map/splaytree.c", "lib/algorithms.rb", "lib/algorithms/search.rb", "lib/algorithms/sort.rb", "lib/algorithms/string.rb", "lib/containers/deque.rb", "lib/containers/heap.rb", "lib/containers/kd_tree.rb", "lib/containers/priority_queue.rb", "lib/containers/queue.rb", "lib/containers/rb_tree_map.rb", "lib/containers/splay_tree_map.rb", "lib/containers/stack.rb", "lib/containers/suffix_array.rb", "lib/containers/trie.rb", "spec/deque_gc_mark_spec.rb", "spec/deque_spec.rb", "spec/heap_spec.rb", "spec/kd_expected_out.txt", "spec/kd_test_in.txt", "spec/kd_tree_spec.rb", "spec/map_gc_mark_spec.rb", "spec/priority_queue_spec.rb", "spec/queue_spec.rb", "spec/rb_tree_map_spec.rb", "spec/search_spec.rb", "spec/sort_spec.rb", "spec/splay_tree_map_spec.rb", "spec/stack_spec.rb", "spec/string_spec.rb", "spec/suffix_array_spec.rb", "spec/trie_spec.rb", "grosser-algorithms.gemspec"]
12
+ s.extensions = ["ext/algorithms/string/extconf.rb", "ext/containers/bst/extconf.rb", "ext/containers/deque/extconf.rb", "ext/containers/rbtree_map/extconf.rb", "ext/containers/splaytree_map/extconf.rb"]
13
+ s.extra_rdoc_files = ["README.markdown", "ext/algorithms/string/extconf.rb", "ext/algorithms/string/string.c", "ext/containers/bst/bst.c", "ext/containers/bst/extconf.rb", "ext/containers/deque/deque.c", "ext/containers/deque/extconf.rb", "ext/containers/rbtree_map/extconf.rb", "ext/containers/rbtree_map/rbtree.c", "ext/containers/splaytree_map/extconf.rb", "ext/containers/splaytree_map/splaytree.c", "lib/algorithms.rb", "lib/algorithms/search.rb", "lib/algorithms/sort.rb", "lib/algorithms/string.rb", "lib/containers/deque.rb", "lib/containers/heap.rb", "lib/containers/kd_tree.rb", "lib/containers/priority_queue.rb", "lib/containers/queue.rb", "lib/containers/rb_tree_map.rb", "lib/containers/splay_tree_map.rb", "lib/containers/stack.rb", "lib/containers/suffix_array.rb", "lib/containers/trie.rb"]
14
+ s.files = ["History.txt", "Manifest", "README.markdown", "Rakefile", "VERSION", "algorithms.gemspec", "benchmarks/deque.rb", "benchmarks/sorts.rb", "benchmarks/treemaps.rb", "ext/algorithms/string/extconf.rb", "ext/algorithms/string/string.c", "ext/containers/bst/bst.c", "ext/containers/bst/extconf.rb", "ext/containers/deque/deque.c", "ext/containers/deque/extconf.rb", "ext/containers/rbtree_map/extconf.rb", "ext/containers/rbtree_map/rbtree.c", "ext/containers/splaytree_map/extconf.rb", "ext/containers/splaytree_map/splaytree.c", "grosser-algorithms.gemspec", "lib/algorithms.rb", "lib/algorithms/search.rb", "lib/algorithms/sort.rb", "lib/algorithms/string.rb", "lib/containers/deque.rb", "lib/containers/heap.rb", "lib/containers/kd_tree.rb", "lib/containers/priority_queue.rb", "lib/containers/queue.rb", "lib/containers/rb_tree_map.rb", "lib/containers/splay_tree_map.rb", "lib/containers/stack.rb", "lib/containers/suffix_array.rb", "lib/containers/trie.rb", "rdoc/classes/Algorithms.html", "rdoc/classes/Algorithms/Algorithms.html", "rdoc/classes/Algorithms/Algorithms/Sort.html", "rdoc/classes/Algorithms/Containers.html", "rdoc/classes/Algorithms/Containers/Heap.html", "rdoc/classes/Algorithms/Containers/KDTree.html", "rdoc/classes/Algorithms/Containers/MaxHeap.html", "rdoc/classes/Algorithms/Containers/MinHeap.html", "rdoc/classes/Algorithms/Containers/PriorityQueue.html", "rdoc/classes/Algorithms/Containers/Queue.html", "rdoc/classes/Algorithms/Containers/RubyDeque.html", "rdoc/classes/Algorithms/Containers/RubyRBTreeMap.html", "rdoc/classes/Algorithms/Containers/RubySplayTreeMap.html", "rdoc/classes/Algorithms/Containers/Stack.html", "rdoc/classes/Algorithms/Containers/SuffixArray.html", "rdoc/classes/Algorithms/Containers/Trie.html", "rdoc/classes/Algorithms/Search.html", "rdoc/created.rid", "rdoc/files/History_txt.html", "rdoc/files/README_markdown.html", "rdoc/files/lib/algorithms/search_rb.html", "rdoc/files/lib/algorithms/sort_rb.html", "rdoc/files/lib/algorithms/string_rb.html", "rdoc/files/lib/algorithms_rb.html", "rdoc/files/lib/containers/deque_rb.html", "rdoc/files/lib/containers/heap_rb.html", "rdoc/files/lib/containers/kd_tree_rb.html", "rdoc/files/lib/containers/priority_queue_rb.html", "rdoc/files/lib/containers/queue_rb.html", "rdoc/files/lib/containers/rb_tree_map_rb.html", "rdoc/files/lib/containers/splay_tree_map_rb.html", "rdoc/files/lib/containers/stack_rb.html", "rdoc/files/lib/containers/suffix_array_rb.html", "rdoc/files/lib/containers/trie_rb.html", "rdoc/fr_class_index.html", "rdoc/fr_file_index.html", "rdoc/fr_method_index.html", "rdoc/index.html", "rdoc/rdoc-style.css", "spec/bst_gc_mark_spec.rb", "spec/bst_spec.rb", "spec/deque_gc_mark_spec.rb", "spec/deque_spec.rb", "spec/heap_spec.rb", "spec/kd_expected_out.txt", "spec/kd_test_in.txt", "spec/kd_tree_spec.rb", "spec/map_gc_mark_spec.rb", "spec/priority_queue_spec.rb", "spec/queue_spec.rb", "spec/rb_tree_map_spec.rb", "spec/search_spec.rb", "spec/sort_spec.rb", "spec/splay_tree_map_spec.rb", "spec/stack_spec.rb", "spec/string_spec.rb", "spec/suffix_array_spec.rb", "spec/trie_spec.rb"]
15
15
  s.homepage = %q{http://rubyforge.org/projects/algorithms/}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Grosser-algorithms", "--main", "README.markdown"]
17
17
  s.require_paths = ["lib", "ext"]
@@ -0,0 +1,221 @@
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>Module: Algorithms</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="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">Algorithms</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/algorithms_rb.html">
59
+ lib/algorithms.rb
60
+ </a>
61
+ <br />
62
+ <a href="../files/lib/algorithms/search_rb.html">
63
+ lib/algorithms/search.rb
64
+ </a>
65
+ <br />
66
+ <a href="../files/lib/algorithms/sort_rb.html">
67
+ lib/algorithms/sort.rb
68
+ </a>
69
+ <br />
70
+ <a href="../files/lib/containers/kd_tree_rb.html">
71
+ lib/containers/kd_tree.rb
72
+ </a>
73
+ <br />
74
+ <a href="../files/lib/containers/splay_tree_map_rb.html">
75
+ lib/containers/splay_tree_map.rb
76
+ </a>
77
+ <br />
78
+ <a href="../files/lib/containers/deque_rb.html">
79
+ lib/containers/deque.rb
80
+ </a>
81
+ <br />
82
+ <a href="../files/lib/containers/heap_rb.html">
83
+ lib/containers/heap.rb
84
+ </a>
85
+ <br />
86
+ <a href="../files/lib/containers/stack_rb.html">
87
+ lib/containers/stack.rb
88
+ </a>
89
+ <br />
90
+ <a href="../files/lib/containers/queue_rb.html">
91
+ lib/containers/queue.rb
92
+ </a>
93
+ <br />
94
+ <a href="../files/lib/containers/rb_tree_map_rb.html">
95
+ lib/containers/rb_tree_map.rb
96
+ </a>
97
+ <br />
98
+ <a href="../files/lib/containers/suffix_array_rb.html">
99
+ lib/containers/suffix_array.rb
100
+ </a>
101
+ <br />
102
+ <a href="../files/lib/containers/priority_queue_rb.html">
103
+ lib/containers/priority_queue.rb
104
+ </a>
105
+ <br />
106
+ <a href="../files/lib/containers/trie_rb.html">
107
+ lib/containers/trie.rb
108
+ </a>
109
+ <br />
110
+ </td>
111
+ </tr>
112
+
113
+ </table>
114
+ </div>
115
+ <!-- banner header -->
116
+
117
+ <div id="bodyContent">
118
+
119
+
120
+
121
+ <div id="contextContent">
122
+
123
+ <div id="description">
124
+ <p>
125
+ A Trie is a data structure that stores key value pairs in a tree-like
126
+ fashion. It allows O(m) lookup speed, where m is the length of the key
127
+ searched, and has no chance of collisions, unlike hash tables. Because of
128
+ its nature, search misses are quickly detected.
129
+ </p>
130
+ <p>
131
+ Tries are often used for longest prefix algorithms, wildcard matching, and
132
+ can be used to implement a radix sort.
133
+ </p>
134
+ <p>
135
+ This implemention is based on a Ternary <a
136
+ href="Algorithms/Search.html">Search</a> Tree.
137
+ </p>
138
+
139
+ </div>
140
+
141
+
142
+ </div>
143
+
144
+
145
+ </div>
146
+
147
+
148
+ <!-- if includes -->
149
+
150
+ <div id="section">
151
+
152
+ <div id="class-list">
153
+ <h3 class="section-bar">Classes and Modules</h3>
154
+
155
+ Module <a href="Algorithms/Algorithms.html" class="link">Algorithms::Algorithms</a><br />
156
+ Module <a href="Algorithms/Containers.html" class="link">Algorithms::Containers</a><br />
157
+ Module <a href="Algorithms/Search.html" class="link">Algorithms::Search</a><br />
158
+
159
+ </div>
160
+
161
+ <div id="constants-list">
162
+ <h3 class="section-bar">Constants</h3>
163
+
164
+ <div class="name-list">
165
+ <table summary="Constants">
166
+ <tr class="top-aligned-row context-row">
167
+ <td class="context-item-name">VERSION</td>
168
+ <td>=</td>
169
+ <td class="context-item-value">File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip</td>
170
+ </tr>
171
+ <tr class="top-aligned-row context-row">
172
+ <td class="context-item-name">SplayTreeMap</td>
173
+ <td>=</td>
174
+ <td class="context-item-value">Containers::CSplayTreeMap</td>
175
+ </tr>
176
+ <tr class="top-aligned-row context-row">
177
+ <td class="context-item-name">SplayTreeMap</td>
178
+ <td>=</td>
179
+ <td class="context-item-value">Containers::RubySplayTreeMap</td>
180
+ </tr>
181
+ <tr class="top-aligned-row context-row">
182
+ <td class="context-item-name">Deque</td>
183
+ <td>=</td>
184
+ <td class="context-item-value">Containers::CDeque</td>
185
+ </tr>
186
+ <tr class="top-aligned-row context-row">
187
+ <td class="context-item-name">Deque</td>
188
+ <td>=</td>
189
+ <td class="context-item-value">Containers::RubyDeque</td>
190
+ </tr>
191
+ <tr class="top-aligned-row context-row">
192
+ <td class="context-item-name">RBTreeMap</td>
193
+ <td>=</td>
194
+ <td class="context-item-value">Containers::CRBTreeMap</td>
195
+ </tr>
196
+ <tr class="top-aligned-row context-row">
197
+ <td class="context-item-name">RBTreeMap</td>
198
+ <td>=</td>
199
+ <td class="context-item-value">Containers::RubyRBTreeMap</td>
200
+ </tr>
201
+ </table>
202
+ </div>
203
+ </div>
204
+
205
+
206
+
207
+
208
+
209
+
210
+ <!-- if method_list -->
211
+
212
+
213
+ </div>
214
+
215
+
216
+ <div id="validator-badges">
217
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
218
+ </div>
219
+
220
+ </body>
221
+ </html>