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.
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
@@ -0,0 +1,662 @@
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>Class: Algorithms::Containers::RubyRBTreeMap</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>Class</strong></td>
53
+ <td class="class-name-in-header">Algorithms::Containers::RubyRBTreeMap</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../files/lib/containers/rb_tree_map_rb.html">
59
+ lib/containers/rb_tree_map.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000011">[]</a>&nbsp;&nbsp;
90
+ <a href="#M000006">[]=</a>&nbsp;&nbsp;
91
+ <a href="#M000014">delete</a>&nbsp;&nbsp;
92
+ <a href="#M000017">delete_max</a>&nbsp;&nbsp;
93
+ <a href="#M000016">delete_min</a>&nbsp;&nbsp;
94
+ <a href="#M000018">each</a>&nbsp;&nbsp;
95
+ <a href="#M000015">empty?</a>&nbsp;&nbsp;
96
+ <a href="#M000010">get</a>&nbsp;&nbsp;
97
+ <a href="#M000009">has_key?</a>&nbsp;&nbsp;
98
+ <a href="#M000008">height</a>&nbsp;&nbsp;
99
+ <a href="#M000013">max_key</a>&nbsp;&nbsp;
100
+ <a href="#M000012">min_key</a>&nbsp;&nbsp;
101
+ <a href="#M000004">new</a>&nbsp;&nbsp;
102
+ <a href="#M000005">push</a>&nbsp;&nbsp;
103
+ <a href="#M000007">size</a>&nbsp;&nbsp;
104
+ </div>
105
+ </div>
106
+
107
+ </div>
108
+
109
+
110
+ <!-- if includes -->
111
+ <div id="includes">
112
+ <h3 class="section-bar">Included Modules</h3>
113
+
114
+ <div id="includes-list">
115
+ <span class="include-name">Enumerable</span>
116
+ </div>
117
+ </div>
118
+
119
+ <div id="section">
120
+
121
+
122
+
123
+
124
+
125
+ <div id="attribute-list">
126
+ <h3 class="section-bar">Attributes</h3>
127
+
128
+ <div class="name-list">
129
+ <table>
130
+ <tr class="top-aligned-row context-row">
131
+ <td class="context-item-name">height_black</td>
132
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
133
+ <td class="context-item-desc"></td>
134
+ </tr>
135
+ </table>
136
+ </div>
137
+ </div>
138
+
139
+
140
+
141
+ <!-- if method_list -->
142
+ <div id="methods">
143
+ <h3 class="section-bar">Public Class methods</h3>
144
+
145
+ <div id="method-M000004" class="method-detail">
146
+ <a name="M000004"></a>
147
+
148
+ <div class="method-heading">
149
+ <a href="#M000004" class="method-signature">
150
+ <span class="method-name">new</span><span class="method-args">()</span>
151
+ </a>
152
+ </div>
153
+
154
+ <div class="method-description">
155
+ <p>
156
+ Create and initialize a <a href="RubyRBTreeMap.html#M000004">new</a> empty
157
+ TreeMap.
158
+ </p>
159
+ <p><a class="source-toggle" href="#"
160
+ onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
161
+ <div class="method-source-code" id="M000004-source">
162
+ <pre>
163
+ <span class="ruby-comment cmt"># File lib/containers/rb_tree_map.rb, line 28</span>
164
+ 28: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
165
+ 29: <span class="ruby-ivar">@root</span> = <span class="ruby-keyword kw">nil</span>
166
+ 30: <span class="ruby-ivar">@height_black</span> = <span class="ruby-value">0</span>
167
+ 31: <span class="ruby-keyword kw">end</span>
168
+ </pre>
169
+ </div>
170
+ </div>
171
+ </div>
172
+
173
+ <h3 class="section-bar">Public Instance methods</h3>
174
+
175
+ <div id="method-M000011" class="method-detail">
176
+ <a name="M000011"></a>
177
+
178
+ <div class="method-heading">
179
+ <span class="method-name">[]</span><span class="method-args">(key)</span>
180
+ </div>
181
+
182
+ <div class="method-description">
183
+ <p>
184
+ Alias for <a href="RubyRBTreeMap.html#M000010">get</a>
185
+ </p>
186
+ </div>
187
+ </div>
188
+
189
+ <div id="method-M000006" class="method-detail">
190
+ <a name="M000006"></a>
191
+
192
+ <div class="method-heading">
193
+ <span class="method-name">[]=</span><span class="method-args">(key, value)</span>
194
+ </div>
195
+
196
+ <div class="method-description">
197
+ <p>
198
+ Alias for <a href="RubyRBTreeMap.html#M000005">push</a>
199
+ </p>
200
+ </div>
201
+ </div>
202
+
203
+ <div id="method-M000014" class="method-detail">
204
+ <a name="M000014"></a>
205
+
206
+ <div class="method-heading">
207
+ <a href="#M000014" class="method-signature">
208
+ <span class="method-name">delete</span><span class="method-args">(key)</span>
209
+ </a>
210
+ </div>
211
+
212
+ <div class="method-description">
213
+ <p>
214
+ Deletes the item and key if it&#8216;s found, and returns the item. Returns
215
+ nil if key is not present.
216
+ </p>
217
+ <p>
218
+ !!! Warning !!! There is a currently a bug in the <a
219
+ href="RubyRBTreeMap.html#M000014">delete</a> method that occurs rarely but
220
+ often enough, especially in large datasets. It is currently under
221
+ investigation.
222
+ </p>
223
+ <p>
224
+ Complexity: O(log n)
225
+ </p>
226
+ <pre>
227
+ map = Algorithms::Containers::TreeMap.new
228
+ map.push(&quot;MA&quot;, &quot;Massachusetts&quot;)
229
+ map.push(&quot;GA&quot;, &quot;Georgia&quot;)
230
+ map.min_key #=&gt; &quot;GA&quot;
231
+ </pre>
232
+ <p><a class="source-toggle" href="#"
233
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
234
+ <div class="method-source-code" id="M000014-source">
235
+ <pre>
236
+ <span class="ruby-comment cmt"># File lib/containers/rb_tree_map.rb, line 132</span>
237
+ 132: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
238
+ 133: <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">nil</span>
239
+ 134: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@root</span>
240
+ 135: <span class="ruby-ivar">@root</span>, <span class="ruby-identifier">result</span> = <span class="ruby-identifier">delete_recursive</span>(<span class="ruby-ivar">@root</span>, <span class="ruby-identifier">key</span>)
241
+ 136: <span class="ruby-ivar">@root</span>.<span class="ruby-identifier">color</span> = <span class="ruby-identifier">:black</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@root</span>
242
+ 137: <span class="ruby-keyword kw">end</span>
243
+ 138: <span class="ruby-identifier">result</span>
244
+ 139: <span class="ruby-keyword kw">end</span>
245
+ </pre>
246
+ </div>
247
+ </div>
248
+ </div>
249
+
250
+ <div id="method-M000017" class="method-detail">
251
+ <a name="M000017"></a>
252
+
253
+ <div class="method-heading">
254
+ <a href="#M000017" class="method-signature">
255
+ <span class="method-name">delete_max</span><span class="method-args">()</span>
256
+ </a>
257
+ </div>
258
+
259
+ <div class="method-description">
260
+ <p>
261
+ Deletes the item with the smallest key and returns the item. Returns nil if
262
+ key is not present.
263
+ </p>
264
+ <p>
265
+ Complexity: O(log n)
266
+ </p>
267
+ <pre>
268
+ map = Algorithms::Containers::TreeMap.new
269
+ map.push(&quot;MA&quot;, &quot;Massachusetts&quot;)
270
+ map.push(&quot;GA&quot;, &quot;Georgia&quot;)
271
+ map.delete_max #=&gt; &quot;Georgia&quot;
272
+ map.size #=&gt; 1
273
+ </pre>
274
+ <p><a class="source-toggle" href="#"
275
+ onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
276
+ <div class="method-source-code" id="M000017-source">
277
+ <pre>
278
+ <span class="ruby-comment cmt"># File lib/containers/rb_tree_map.rb, line 175</span>
279
+ 175: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_max</span>
280
+ 176: <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">nil</span>
281
+ 177: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@root</span>
282
+ 178: <span class="ruby-ivar">@root</span>, <span class="ruby-identifier">result</span> = <span class="ruby-identifier">delete_max_recursive</span>(<span class="ruby-ivar">@root</span>)
283
+ 179: <span class="ruby-ivar">@root</span>.<span class="ruby-identifier">color</span> = <span class="ruby-identifier">:black</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@root</span>
284
+ 180: <span class="ruby-keyword kw">end</span>
285
+ 181: <span class="ruby-identifier">result</span>
286
+ 182: <span class="ruby-keyword kw">end</span>
287
+ </pre>
288
+ </div>
289
+ </div>
290
+ </div>
291
+
292
+ <div id="method-M000016" class="method-detail">
293
+ <a name="M000016"></a>
294
+
295
+ <div class="method-heading">
296
+ <a href="#M000016" class="method-signature">
297
+ <span class="method-name">delete_min</span><span class="method-args">()</span>
298
+ </a>
299
+ </div>
300
+
301
+ <div class="method-description">
302
+ <p>
303
+ Deletes the item with the smallest key and returns the item. Returns nil if
304
+ key is not present.
305
+ </p>
306
+ <p>
307
+ Complexity: O(log n)
308
+ </p>
309
+ <pre>
310
+ map = Algorithms::Containers::TreeMap.new
311
+ map.push(&quot;MA&quot;, &quot;Massachusetts&quot;)
312
+ map.push(&quot;GA&quot;, &quot;Georgia&quot;)
313
+ map.delete_min #=&gt; &quot;Massachusetts&quot;
314
+ map.size #=&gt; 1
315
+ </pre>
316
+ <p><a class="source-toggle" href="#"
317
+ onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
318
+ <div class="method-source-code" id="M000016-source">
319
+ <pre>
320
+ <span class="ruby-comment cmt"># File lib/containers/rb_tree_map.rb, line 156</span>
321
+ 156: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_min</span>
322
+ 157: <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">nil</span>
323
+ 158: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@root</span>
324
+ 159: <span class="ruby-ivar">@root</span>, <span class="ruby-identifier">result</span> = <span class="ruby-identifier">delete_min_recursive</span>(<span class="ruby-ivar">@root</span>)
325
+ 160: <span class="ruby-ivar">@root</span>.<span class="ruby-identifier">color</span> = <span class="ruby-identifier">:black</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@root</span>
326
+ 161: <span class="ruby-keyword kw">end</span>
327
+ 162: <span class="ruby-identifier">result</span>
328
+ 163: <span class="ruby-keyword kw">end</span>
329
+ </pre>
330
+ </div>
331
+ </div>
332
+ </div>
333
+
334
+ <div id="method-M000018" class="method-detail">
335
+ <a name="M000018"></a>
336
+
337
+ <div class="method-heading">
338
+ <a href="#M000018" class="method-signature">
339
+ <span class="method-name">each</span><span class="method-args">() {|cursor.key, cursor.value| ...}</span>
340
+ </a>
341
+ </div>
342
+
343
+ <div class="method-description">
344
+ <p>
345
+ Iterates over the TreeMap from smallest to largest element. Iterative
346
+ approach.
347
+ </p>
348
+ <p><a class="source-toggle" href="#"
349
+ onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
350
+ <div class="method-source-code" id="M000018-source">
351
+ <pre>
352
+ <span class="ruby-comment cmt"># File lib/containers/rb_tree_map.rb, line 185</span>
353
+ 185: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>
354
+ 186: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@root</span>
355
+ 187: <span class="ruby-identifier">stack</span> = <span class="ruby-constant">Stack</span>.<span class="ruby-identifier">new</span>
356
+ 188: <span class="ruby-identifier">cursor</span> = <span class="ruby-ivar">@root</span>
357
+ 189: <span class="ruby-identifier">loop</span> <span class="ruby-keyword kw">do</span>
358
+ 190: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cursor</span>
359
+ 191: <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">cursor</span>)
360
+ 192: <span class="ruby-identifier">cursor</span> = <span class="ruby-identifier">cursor</span>.<span class="ruby-identifier">left</span>
361
+ 193: <span class="ruby-keyword kw">else</span>
362
+ 194: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">empty?</span>
363
+ 195: <span class="ruby-identifier">cursor</span> = <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">pop</span>
364
+ 196: <span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">cursor</span>.<span class="ruby-identifier">key</span>, <span class="ruby-identifier">cursor</span>.<span class="ruby-identifier">value</span>)
365
+ 197: <span class="ruby-identifier">cursor</span> = <span class="ruby-identifier">cursor</span>.<span class="ruby-identifier">right</span>
366
+ 198: <span class="ruby-keyword kw">else</span>
367
+ 199: <span class="ruby-keyword kw">break</span>
368
+ 200: <span class="ruby-keyword kw">end</span>
369
+ 201: <span class="ruby-keyword kw">end</span>
370
+ 202: <span class="ruby-keyword kw">end</span>
371
+ 203: <span class="ruby-keyword kw">end</span>
372
+ </pre>
373
+ </div>
374
+ </div>
375
+ </div>
376
+
377
+ <div id="method-M000015" class="method-detail">
378
+ <a name="M000015"></a>
379
+
380
+ <div class="method-heading">
381
+ <a href="#M000015" class="method-signature">
382
+ <span class="method-name">empty?</span><span class="method-args">()</span>
383
+ </a>
384
+ </div>
385
+
386
+ <div class="method-description">
387
+ <p>
388
+ Returns true if the tree is empty, false otherwise
389
+ </p>
390
+ <p><a class="source-toggle" href="#"
391
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
392
+ <div class="method-source-code" id="M000015-source">
393
+ <pre>
394
+ <span class="ruby-comment cmt"># File lib/containers/rb_tree_map.rb, line 142</span>
395
+ 142: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">empty?</span>
396
+ 143: <span class="ruby-ivar">@root</span>.<span class="ruby-identifier">nil?</span>
397
+ 144: <span class="ruby-keyword kw">end</span>
398
+ </pre>
399
+ </div>
400
+ </div>
401
+ </div>
402
+
403
+ <div id="method-M000010" class="method-detail">
404
+ <a name="M000010"></a>
405
+
406
+ <div class="method-heading">
407
+ <a href="#M000010" class="method-signature">
408
+ <span class="method-name">get</span><span class="method-args">(key)</span>
409
+ </a>
410
+ </div>
411
+
412
+ <div class="method-description">
413
+ <p>
414
+ Return the item associated with the key, or nil if none found.
415
+ </p>
416
+ <p>
417
+ Complexity: O(log n)
418
+ </p>
419
+ <pre>
420
+ map = Algorithms::Containers::TreeMap.new
421
+ map.push(&quot;MA&quot;, &quot;Massachusetts&quot;)
422
+ map.push(&quot;GA&quot;, &quot;Georgia&quot;)
423
+ map.get(&quot;GA&quot;) #=&gt; &quot;Georgia&quot;
424
+ </pre>
425
+ <p><a class="source-toggle" href="#"
426
+ onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
427
+ <div class="method-source-code" id="M000010-source">
428
+ <pre>
429
+ <span class="ruby-comment cmt"># File lib/containers/rb_tree_map.rb, line 91</span>
430
+ 91: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>)
431
+ 92: <span class="ruby-identifier">get_recursive</span>(<span class="ruby-ivar">@root</span>, <span class="ruby-identifier">key</span>)
432
+ 93: <span class="ruby-keyword kw">end</span>
433
+ </pre>
434
+ </div>
435
+ </div>
436
+ </div>
437
+
438
+ <div id="method-M000009" class="method-detail">
439
+ <a name="M000009"></a>
440
+
441
+ <div class="method-heading">
442
+ <a href="#M000009" class="method-signature">
443
+ <span class="method-name">has_key?</span><span class="method-args">(key)</span>
444
+ </a>
445
+ </div>
446
+
447
+ <div class="method-description">
448
+ <p>
449
+ Return true if key is found in the TreeMap, false otherwise
450
+ </p>
451
+ <p>
452
+ Complexity: O(log n)
453
+ </p>
454
+ <pre>
455
+ map = Algorithms::Containers::TreeMap.new
456
+ map.push(&quot;MA&quot;, &quot;Massachusetts&quot;)
457
+ map.push(&quot;GA&quot;, &quot;Georgia&quot;)
458
+ map.has_key?(&quot;GA&quot;) #=&gt; true
459
+ map.has_key?(&quot;DE&quot;) #=&gt; false
460
+ </pre>
461
+ <p><a class="source-toggle" href="#"
462
+ onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
463
+ <div class="method-source-code" id="M000009-source">
464
+ <pre>
465
+ <span class="ruby-comment cmt"># File lib/containers/rb_tree_map.rb, line 79</span>
466
+ 79: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">key</span>)
467
+ 80: <span class="ruby-operator">!</span><span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>).<span class="ruby-identifier">nil?</span>
468
+ 81: <span class="ruby-keyword kw">end</span>
469
+ </pre>
470
+ </div>
471
+ </div>
472
+ </div>
473
+
474
+ <div id="method-M000008" class="method-detail">
475
+ <a name="M000008"></a>
476
+
477
+ <div class="method-heading">
478
+ <a href="#M000008" class="method-signature">
479
+ <span class="method-name">height</span><span class="method-args">()</span>
480
+ </a>
481
+ </div>
482
+
483
+ <div class="method-description">
484
+ <p>
485
+ Return the <a href="RubyRBTreeMap.html#M000008">height</a> of the tree
486
+ structure in the TreeMap.
487
+ </p>
488
+ <p>
489
+ Complexity: O(1)
490
+ </p>
491
+ <pre>
492
+ map = Algorithms::Containers::TreeMap.new
493
+ map.push(&quot;MA&quot;, &quot;Massachusetts&quot;)
494
+ map.push(&quot;GA&quot;, &quot;Georgia&quot;)
495
+ map.height #=&gt; 2
496
+ </pre>
497
+ <p><a class="source-toggle" href="#"
498
+ onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
499
+ <div class="method-source-code" id="M000008-source">
500
+ <pre>
501
+ <span class="ruby-comment cmt"># File lib/containers/rb_tree_map.rb, line 66</span>
502
+ 66: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">height</span>
503
+ 67: <span class="ruby-ivar">@root</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@root</span>.<span class="ruby-identifier">height</span> <span class="ruby-keyword kw">or</span> <span class="ruby-value">0</span>
504
+ 68: <span class="ruby-keyword kw">end</span>
505
+ </pre>
506
+ </div>
507
+ </div>
508
+ </div>
509
+
510
+ <div id="method-M000013" class="method-detail">
511
+ <a name="M000013"></a>
512
+
513
+ <div class="method-heading">
514
+ <a href="#M000013" class="method-signature">
515
+ <span class="method-name">max_key</span><span class="method-args">()</span>
516
+ </a>
517
+ </div>
518
+
519
+ <div class="method-description">
520
+ <p>
521
+ Return the largest key in the map.
522
+ </p>
523
+ <p>
524
+ Complexity: O(log n)
525
+ </p>
526
+ <pre>
527
+ map = Algorithms::Containers::TreeMap.new
528
+ map.push(&quot;MA&quot;, &quot;Massachusetts&quot;)
529
+ map.push(&quot;GA&quot;, &quot;Georgia&quot;)
530
+ map.max_key #=&gt; &quot;MA&quot;
531
+ </pre>
532
+ <p><a class="source-toggle" href="#"
533
+ onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
534
+ <div class="method-source-code" id="M000013-source">
535
+ <pre>
536
+ <span class="ruby-comment cmt"># File lib/containers/rb_tree_map.rb, line 116</span>
537
+ 116: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">max_key</span>
538
+ 117: <span class="ruby-ivar">@root</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">max_recursive</span>(<span class="ruby-ivar">@root</span>)
539
+ 118: <span class="ruby-keyword kw">end</span>
540
+ </pre>
541
+ </div>
542
+ </div>
543
+ </div>
544
+
545
+ <div id="method-M000012" class="method-detail">
546
+ <a name="M000012"></a>
547
+
548
+ <div class="method-heading">
549
+ <a href="#M000012" class="method-signature">
550
+ <span class="method-name">min_key</span><span class="method-args">()</span>
551
+ </a>
552
+ </div>
553
+
554
+ <div class="method-description">
555
+ <p>
556
+ Return the smallest key in the map.
557
+ </p>
558
+ <p>
559
+ Complexity: O(log n)
560
+ </p>
561
+ <pre>
562
+ map = Algorithms::Containers::TreeMap.new
563
+ map.push(&quot;MA&quot;, &quot;Massachusetts&quot;)
564
+ map.push(&quot;GA&quot;, &quot;Georgia&quot;)
565
+ map.min_key #=&gt; &quot;GA&quot;
566
+ </pre>
567
+ <p><a class="source-toggle" href="#"
568
+ onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
569
+ <div class="method-source-code" id="M000012-source">
570
+ <pre>
571
+ <span class="ruby-comment cmt"># File lib/containers/rb_tree_map.rb, line 104</span>
572
+ 104: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">min_key</span>
573
+ 105: <span class="ruby-ivar">@root</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">min_recursive</span>(<span class="ruby-ivar">@root</span>)
574
+ 106: <span class="ruby-keyword kw">end</span>
575
+ </pre>
576
+ </div>
577
+ </div>
578
+ </div>
579
+
580
+ <div id="method-M000005" class="method-detail">
581
+ <a name="M000005"></a>
582
+
583
+ <div class="method-heading">
584
+ <a href="#M000005" class="method-signature">
585
+ <span class="method-name">push</span><span class="method-args">(key, value)</span>
586
+ </a>
587
+ </div>
588
+
589
+ <div class="method-description">
590
+ <p>
591
+ Insert an item with an associated key into the TreeMap, and returns the
592
+ item inserted
593
+ </p>
594
+ <p>
595
+ Complexity: O(log n)
596
+ </p>
597
+ <p>
598
+ map = Algorithms::Containers::TreeMap.new map.push(&quot;MA&quot;,
599
+ &quot;Massachusetts&quot;) #=&gt; &quot;Massachusetts&quot;
600
+ map.get(&quot;MA&quot;) #=&gt; &quot;Massachusetts&quot;
601
+ </p>
602
+ <p><a class="source-toggle" href="#"
603
+ onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
604
+ <div class="method-source-code" id="M000005-source">
605
+ <pre>
606
+ <span class="ruby-comment cmt"># File lib/containers/rb_tree_map.rb, line 40</span>
607
+ 40: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">push</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
608
+ 41: <span class="ruby-ivar">@root</span> = <span class="ruby-identifier">insert</span>(<span class="ruby-ivar">@root</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
609
+ 42: <span class="ruby-ivar">@height_black</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">isred</span>(<span class="ruby-ivar">@root</span>)
610
+ 43: <span class="ruby-ivar">@root</span>.<span class="ruby-identifier">color</span> = <span class="ruby-identifier">:black</span>
611
+ 44: <span class="ruby-identifier">value</span>
612
+ 45: <span class="ruby-keyword kw">end</span>
613
+ </pre>
614
+ </div>
615
+ </div>
616
+ </div>
617
+
618
+ <div id="method-M000007" class="method-detail">
619
+ <a name="M000007"></a>
620
+
621
+ <div class="method-heading">
622
+ <a href="#M000007" class="method-signature">
623
+ <span class="method-name">size</span><span class="method-args">()</span>
624
+ </a>
625
+ </div>
626
+
627
+ <div class="method-description">
628
+ <p>
629
+ Return the number of items in the TreeMap.
630
+ </p>
631
+ <pre>
632
+ map = Algorithms::Containers::TreeMap.new
633
+ map.push(&quot;MA&quot;, &quot;Massachusetts&quot;)
634
+ map.push(&quot;GA&quot;, &quot;Georgia&quot;)
635
+ map.size #=&gt; 2
636
+ </pre>
637
+ <p><a class="source-toggle" href="#"
638
+ onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
639
+ <div class="method-source-code" id="M000007-source">
640
+ <pre>
641
+ <span class="ruby-comment cmt"># File lib/containers/rb_tree_map.rb, line 54</span>
642
+ 54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">size</span>
643
+ 55: <span class="ruby-ivar">@root</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@root</span>.<span class="ruby-identifier">size</span> <span class="ruby-keyword kw">or</span> <span class="ruby-value">0</span>
644
+ 56: <span class="ruby-keyword kw">end</span>
645
+ </pre>
646
+ </div>
647
+ </div>
648
+ </div>
649
+
650
+
651
+ </div>
652
+
653
+
654
+ </div>
655
+
656
+
657
+ <div id="validator-badges">
658
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
659
+ </div>
660
+
661
+ </body>
662
+ </html>