collection_utils 0.1.0 → 1.0.0

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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/README.md +3 -3
  4. data/documentation/CollectionUtils/Heap.html +1276 -0
  5. data/documentation/CollectionUtils/HeapUtils/MaxHeap.html +490 -0
  6. data/documentation/CollectionUtils/HeapUtils/MinHeap.html +490 -0
  7. data/documentation/CollectionUtils/HeapUtils.html +117 -0
  8. data/documentation/CollectionUtils/Queue.html +749 -0
  9. data/documentation/CollectionUtils/Stack.html +674 -0
  10. data/documentation/CollectionUtils/TreeUtils/BST.html +515 -0
  11. data/documentation/CollectionUtils/TreeUtils.html +117 -0
  12. data/documentation/CollectionUtils.html +134 -0
  13. data/documentation/_index.html +211 -0
  14. data/documentation/class_list.html +51 -0
  15. data/documentation/css/common.css +1 -0
  16. data/documentation/css/full_list.css +58 -0
  17. data/documentation/css/style.css +492 -0
  18. data/documentation/file.README.html +124 -0
  19. data/documentation/file_list.html +56 -0
  20. data/documentation/frames.html +17 -0
  21. data/documentation/index.html +124 -0
  22. data/documentation/js/app.js +248 -0
  23. data/documentation/js/full_list.js +216 -0
  24. data/documentation/js/jquery.js +4 -0
  25. data/documentation/method_list.html +355 -0
  26. data/documentation/top-level-namespace.html +110 -0
  27. data/lib/collection_utils/heap.rb +251 -0
  28. data/lib/collection_utils/heap_utils/max_heap.rb +12 -12
  29. data/lib/collection_utils/heap_utils/min_heap.rb +13 -11
  30. data/lib/collection_utils/queue.rb +21 -0
  31. data/lib/collection_utils/stack.rb +25 -2
  32. data/lib/collection_utils/tree_utils/bst.rb +69 -0
  33. data/lib/collection_utils/tree_utils.rb +5 -0
  34. data/lib/collection_utils/version.rb +1 -1
  35. metadata +28 -3
  36. data/lib/collection_utils/heap_utils/heap.rb +0 -97
@@ -0,0 +1,674 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: CollectionUtils::Stack
8
+
9
+ &mdash; Documentation by YARD 0.9.9
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "CollectionUtils::Stack";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (S)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../CollectionUtils.html" title="CollectionUtils (module)">CollectionUtils</a></span></span>
41
+ &raquo;
42
+ <span class="title">Stack</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: CollectionUtils::Stack
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">CollectionUtils::Stack</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/collection_utils/stack.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+ <h2>
111
+ Instance Method Summary
112
+ <small><a href="#" class="summary_toggle">collapse</a></small>
113
+ </h2>
114
+
115
+ <ul class="summary">
116
+
117
+ <li class="public ">
118
+ <span class="summary_signature">
119
+
120
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(array = []) &#x21d2; Stack </a>
121
+
122
+
123
+
124
+ </span>
125
+
126
+
127
+ <span class="note title constructor">constructor</span>
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+ <span class="summary_desc"><div class='inline'>
137
+ <p>Constructors.</p>
138
+ </div></span>
139
+
140
+ </li>
141
+
142
+
143
+ <li class="public ">
144
+ <span class="summary_signature">
145
+
146
+ <a href="#is_empty%3F-instance_method" title="#is_empty? (instance method)">#<strong>is_empty?</strong> &#x21d2; Boolean </a>
147
+
148
+
149
+
150
+ </span>
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+ <span class="summary_desc"><div class='inline'>
161
+ <p>Stack&#39;s emptiness.</p>
162
+ </div></span>
163
+
164
+ </li>
165
+
166
+
167
+ <li class="public ">
168
+ <span class="summary_signature">
169
+
170
+ <a href="#peek-instance_method" title="#peek (instance method)">#<strong>peek</strong> &#x21d2; Object </a>
171
+
172
+
173
+
174
+ </span>
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+ <span class="summary_desc"><div class='inline'>
185
+ <p>View the top element of the stack without removing it.</p>
186
+ </div></span>
187
+
188
+ </li>
189
+
190
+
191
+ <li class="public ">
192
+ <span class="summary_signature">
193
+
194
+ <a href="#pop-instance_method" title="#pop (instance method)">#<strong>pop</strong> &#x21d2; Object </a>
195
+
196
+
197
+
198
+ </span>
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+ <span class="summary_desc"><div class='inline'>
209
+ <p>Pop will remove the top element from the stack and return the removed
210
+ element.</p>
211
+ </div></span>
212
+
213
+ </li>
214
+
215
+
216
+ <li class="public ">
217
+ <span class="summary_signature">
218
+
219
+ <a href="#push-instance_method" title="#push (instance method)">#<strong>push</strong>(element) &#x21d2; Object </a>
220
+
221
+
222
+
223
+ </span>
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+ <span class="summary_desc"><div class='inline'>
234
+ <p>Add the element to the stack using push.</p>
235
+ </div></span>
236
+
237
+ </li>
238
+
239
+
240
+ <li class="public ">
241
+ <span class="summary_signature">
242
+
243
+ <a href="#size-instance_method" title="#size (instance method)">#<strong>size</strong> &#x21d2; Integer </a>
244
+
245
+
246
+
247
+ </span>
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+ <span class="summary_desc"><div class='inline'>
258
+ <p>Size of stack.</p>
259
+ </div></span>
260
+
261
+ </li>
262
+
263
+
264
+ </ul>
265
+
266
+
267
+ <div id="constructor_details" class="method_details_list">
268
+ <h2>Constructor Details</h2>
269
+
270
+ <div class="method_details first">
271
+ <h3 class="signature first" id="initialize-instance_method">
272
+
273
+ #<strong>initialize</strong>(array = []) &#x21d2; <tt><span class='object_link'><a href="" title="CollectionUtils::Stack (class)">Stack</a></span></tt>
274
+
275
+
276
+
277
+
278
+
279
+ </h3><div class="docstring">
280
+ <div class="discussion">
281
+
282
+ <p>Constructors</p>
283
+
284
+
285
+ </div>
286
+ </div>
287
+ <div class="tags">
288
+
289
+
290
+ </div><table class="source_code">
291
+ <tr>
292
+ <td>
293
+ <pre class="lines">
294
+
295
+
296
+ 8
297
+ 9
298
+ 10
299
+ 11
300
+ 12
301
+ 13</pre>
302
+ </td>
303
+ <td>
304
+ <pre class="code"><span class="info file"># File 'lib/collection_utils/stack.rb', line 8</span>
305
+
306
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_array'>array</span><span class='op'>=</span><span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
307
+ <span class='ivar'>@stack</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
308
+ <span class='id identifier rubyid_array'>array</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_element'>element</span><span class='op'>|</span>
309
+ <span class='ivar'>@stack</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_element'>element</span>
310
+ <span class='kw'>end</span>
311
+ <span class='kw'>end</span></pre>
312
+ </td>
313
+ </tr>
314
+ </table>
315
+ </div>
316
+
317
+ </div>
318
+
319
+
320
+ <div id="instance_method_details" class="method_details_list">
321
+ <h2>Instance Method Details</h2>
322
+
323
+
324
+ <div class="method_details first">
325
+ <h3 class="signature first" id="is_empty?-instance_method">
326
+
327
+ #<strong>is_empty?</strong> &#x21d2; <tt>Boolean</tt>
328
+
329
+
330
+
331
+
332
+
333
+ </h3><div class="docstring">
334
+ <div class="discussion">
335
+
336
+ <p>Returns stack&#39;s emptiness</p>
337
+
338
+
339
+ </div>
340
+ </div>
341
+ <div class="tags">
342
+
343
+ <p class="tag_title">Returns:</p>
344
+ <ul class="return">
345
+
346
+ <li>
347
+
348
+
349
+ <span class='type'>(<tt>Boolean</tt>)</span>
350
+
351
+
352
+
353
+ &mdash;
354
+ <div class='inline'>
355
+ <p>stack&#39;s emptiness</p>
356
+ </div>
357
+
358
+ </li>
359
+
360
+ </ul>
361
+
362
+ </div><table class="source_code">
363
+ <tr>
364
+ <td>
365
+ <pre class="lines">
366
+
367
+
368
+ 39
369
+ 40
370
+ 41</pre>
371
+ </td>
372
+ <td>
373
+ <pre class="code"><span class="info file"># File 'lib/collection_utils/stack.rb', line 39</span>
374
+
375
+ <span class='kw'>def</span> <span class='id identifier rubyid_is_empty?'>is_empty?</span>
376
+ <span class='kw'>return</span> <span class='ivar'>@stack</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>0</span>
377
+ <span class='kw'>end</span></pre>
378
+ </td>
379
+ </tr>
380
+ </table>
381
+ </div>
382
+
383
+ <div class="method_details ">
384
+ <h3 class="signature " id="peek-instance_method">
385
+
386
+ #<strong>peek</strong> &#x21d2; <tt>Object</tt>
387
+
388
+
389
+
390
+
391
+
392
+ </h3><div class="docstring">
393
+ <div class="discussion">
394
+
395
+ <p>View the top element of the stack without removing it</p>
396
+
397
+
398
+ </div>
399
+ </div>
400
+ <div class="tags">
401
+
402
+ <div class="examples">
403
+ <p class="tag_title">Examples:</p>
404
+
405
+
406
+ <p class="example_title"><div class='inline'>
407
+ <p>Create a stack [1,2,3,4,5] and get 5 using peek</p>
408
+ </div></p>
409
+
410
+ <pre class="example code"><code><span class='id identifier rubyid_stack'>stack</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../CollectionUtils.html" title="CollectionUtils (module)">CollectionUtils</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="CollectionUtils::Stack (class)">Stack</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="CollectionUtils::Stack#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span><span class='int'>2</span><span class='comma'>,</span><span class='int'>3</span><span class='comma'>,</span><span class='int'>4</span><span class='comma'>,</span><span class='int'>5</span><span class='rbracket'>]</span><span class='rparen'>)</span>
411
+ <span class='id identifier rubyid_top_element'>top_element</span> <span class='op'>=</span> <span class='id identifier rubyid_stack'>stack</span><span class='period'>.</span><span class='id identifier rubyid_peek'>peek</span> <span class='comment'># top_element = 5</span></code></pre>
412
+
413
+ </div>
414
+
415
+ <p class="tag_title">Returns:</p>
416
+ <ul class="return">
417
+
418
+ <li>
419
+
420
+
421
+ <span class='type'></span>
422
+
423
+
424
+
425
+
426
+ <div class='inline'>
427
+ <p>Top element of the stack</p>
428
+ </div>
429
+
430
+ </li>
431
+
432
+ </ul>
433
+
434
+ </div><table class="source_code">
435
+ <tr>
436
+ <td>
437
+ <pre class="lines">
438
+
439
+
440
+ 50
441
+ 51
442
+ 52</pre>
443
+ </td>
444
+ <td>
445
+ <pre class="code"><span class="info file"># File 'lib/collection_utils/stack.rb', line 50</span>
446
+
447
+ <span class='kw'>def</span> <span class='id identifier rubyid_peek'>peek</span>
448
+ <span class='kw'>return</span> <span class='ivar'>@stack</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span>
449
+ <span class='kw'>end</span></pre>
450
+ </td>
451
+ </tr>
452
+ </table>
453
+ </div>
454
+
455
+ <div class="method_details ">
456
+ <h3 class="signature " id="pop-instance_method">
457
+
458
+ #<strong>pop</strong> &#x21d2; <tt>Object</tt>
459
+
460
+
461
+
462
+
463
+
464
+ </h3><div class="docstring">
465
+ <div class="discussion">
466
+
467
+ <p>Pop will remove the top element from the stack and return the removed
468
+ element.</p>
469
+
470
+
471
+ </div>
472
+ </div>
473
+ <div class="tags">
474
+
475
+ <div class="examples">
476
+ <p class="tag_title">Examples:</p>
477
+
478
+
479
+ <p class="example_title"><div class='inline'>
480
+ <p>Create a stack [1,2,3,4,5] and remove 5 using pop</p>
481
+ </div></p>
482
+
483
+ <pre class="example code"><code><span class='id identifier rubyid_stack'>stack</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../CollectionUtils.html" title="CollectionUtils (module)">CollectionUtils</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="CollectionUtils::Stack (class)">Stack</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="CollectionUtils::Stack#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span><span class='int'>2</span><span class='comma'>,</span><span class='int'>3</span><span class='comma'>,</span><span class='int'>4</span><span class='comma'>,</span><span class='int'>5</span><span class='rbracket'>]</span><span class='rparen'>)</span>
484
+ <span class='id identifier rubyid_top_element'>top_element</span> <span class='op'>=</span> <span class='id identifier rubyid_stack'>stack</span><span class='period'>.</span><span class='id identifier rubyid_pop'>pop</span><span class='lparen'>(</span><span class='rparen'>)</span></code></pre>
485
+
486
+ </div>
487
+
488
+ <p class="tag_title">Returns:</p>
489
+ <ul class="return">
490
+
491
+ <li>
492
+
493
+
494
+ <span class='type'></span>
495
+
496
+
497
+
498
+
499
+ <div class='inline'>
500
+ <p>Top element of the stack</p>
501
+ </div>
502
+
503
+ </li>
504
+
505
+ </ul>
506
+
507
+ </div><table class="source_code">
508
+ <tr>
509
+ <td>
510
+ <pre class="lines">
511
+
512
+
513
+ 22
514
+ 23
515
+ 24</pre>
516
+ </td>
517
+ <td>
518
+ <pre class="code"><span class="info file"># File 'lib/collection_utils/stack.rb', line 22</span>
519
+
520
+ <span class='kw'>def</span> <span class='id identifier rubyid_pop'>pop</span>
521
+ <span class='kw'>return</span> <span class='ivar'>@stack</span><span class='period'>.</span><span class='id identifier rubyid_pop'>pop</span>
522
+ <span class='kw'>end</span></pre>
523
+ </td>
524
+ </tr>
525
+ </table>
526
+ </div>
527
+
528
+ <div class="method_details ">
529
+ <h3 class="signature " id="push-instance_method">
530
+
531
+ #<strong>push</strong>(element) &#x21d2; <tt>Object</tt>
532
+
533
+
534
+
535
+
536
+
537
+ </h3><div class="docstring">
538
+ <div class="discussion">
539
+
540
+ <p>Add the element to the stack using push</p>
541
+
542
+
543
+ </div>
544
+ </div>
545
+ <div class="tags">
546
+
547
+ <div class="examples">
548
+ <p class="tag_title">Examples:</p>
549
+
550
+
551
+ <p class="example_title"><div class='inline'>
552
+ <p>Create a stack [1,2,3,4,5] and add 6 to it.</p>
553
+ </div></p>
554
+
555
+ <pre class="example code"><code><span class='id identifier rubyid_stack'>stack</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../CollectionUtils.html" title="CollectionUtils (module)">CollectionUtils</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="CollectionUtils::Stack (class)">Stack</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="CollectionUtils::Stack#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span><span class='int'>2</span><span class='comma'>,</span><span class='int'>3</span><span class='comma'>,</span><span class='int'>4</span><span class='comma'>,</span><span class='int'>5</span><span class='rbracket'>]</span><span class='rparen'>)</span>
556
+ <span class='id identifier rubyid_stack'>stack</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='int'>6</span><span class='rparen'>)</span>
557
+ <span class='comment'>#stack will be [1,2,3,4,5,6]</span></code></pre>
558
+
559
+ </div>
560
+ <p class="tag_title">Parameters:</p>
561
+ <ul class="param">
562
+
563
+ <li>
564
+
565
+ <span class='name'>element</span>
566
+
567
+
568
+ <span class='type'></span>
569
+
570
+
571
+
572
+ &mdash;
573
+ <div class='inline'>
574
+ <p>that needs to added to stack. This element will the top element</p>
575
+ </div>
576
+
577
+ </li>
578
+
579
+ </ul>
580
+
581
+
582
+ </div><table class="source_code">
583
+ <tr>
584
+ <td>
585
+ <pre class="lines">
586
+
587
+
588
+ 34
589
+ 35
590
+ 36</pre>
591
+ </td>
592
+ <td>
593
+ <pre class="code"><span class="info file"># File 'lib/collection_utils/stack.rb', line 34</span>
594
+
595
+ <span class='kw'>def</span> <span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_element'>element</span><span class='rparen'>)</span>
596
+ <span class='ivar'>@stack</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_element'>element</span>
597
+ <span class='kw'>end</span></pre>
598
+ </td>
599
+ </tr>
600
+ </table>
601
+ </div>
602
+
603
+ <div class="method_details ">
604
+ <h3 class="signature " id="size-instance_method">
605
+
606
+ #<strong>size</strong> &#x21d2; <tt>Integer</tt>
607
+
608
+
609
+
610
+
611
+
612
+ </h3><div class="docstring">
613
+ <div class="discussion">
614
+
615
+ <p>Returns size of stack</p>
616
+
617
+
618
+ </div>
619
+ </div>
620
+ <div class="tags">
621
+
622
+ <p class="tag_title">Returns:</p>
623
+ <ul class="return">
624
+
625
+ <li>
626
+
627
+
628
+ <span class='type'>(<tt>Integer</tt>)</span>
629
+
630
+
631
+
632
+ &mdash;
633
+ <div class='inline'>
634
+ <p>size of stack</p>
635
+ </div>
636
+
637
+ </li>
638
+
639
+ </ul>
640
+
641
+ </div><table class="source_code">
642
+ <tr>
643
+ <td>
644
+ <pre class="lines">
645
+
646
+
647
+ 55
648
+ 56
649
+ 57</pre>
650
+ </td>
651
+ <td>
652
+ <pre class="code"><span class="info file"># File 'lib/collection_utils/stack.rb', line 55</span>
653
+
654
+ <span class='kw'>def</span> <span class='id identifier rubyid_size'>size</span>
655
+ <span class='kw'>return</span> <span class='ivar'>@stack</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
656
+ <span class='kw'>end</span></pre>
657
+ </td>
658
+ </tr>
659
+ </table>
660
+ </div>
661
+
662
+ </div>
663
+
664
+ </div>
665
+
666
+ <div id="footer">
667
+ Generated on Thu Jul 20 01:32:56 2017 by
668
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
669
+ 0.9.9 (ruby-2.0.0).
670
+ </div>
671
+
672
+ </div>
673
+ </body>
674
+ </html>