algorithm_selector 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 926d23241bd078e7ef227b177b23098577985d80
4
- data.tar.gz: 79243d9cd2b4052ae23c4e49ba50b2f550bfedaf
3
+ metadata.gz: e0cfca8272e99082f11cceaa1ff5ef54c3e8d30f
4
+ data.tar.gz: adf9913686218c3a760f4a7f12f676e58d781f67
5
5
  SHA512:
6
- metadata.gz: 64aa876d466eeb9b09c4de18ac7c2e60f28c2f9287e0044a339dcdc839748825a7e74de77c7ea6055edb7e73e2d68468e70d77b6e406dbedad15eba688b1b60c
7
- data.tar.gz: e1358cbd177c52a88a16bb43dbb617ffc959d9f31f3292d4eb49e4e5bd20c0e315ac5dd7c2e866d318e7eba4574103b25a81f63f451c848c51699f4031226a4a
6
+ metadata.gz: db87236bad1fe2136e41622250b565b308afba397111684ad694e739c4c4445c7e7552bb8855e4d8272c3b694bb2b6828fa10487ad1f569c4c025c467a77674b
7
+ data.tar.gz: 813f3dc48ff67dcd626ebb755e801f14fe99fe21b044aee2de32289fb61fecfab4f8f1d225afdbe26b898c6e2fc8bf098a706f699186d88e281da5a53914333b
@@ -1,2 +1,2 @@
1
1
  lib/algorithm_selector.rb 2ce266b24d0eb15a31621b30141a1fea866ebcef
2
- lib/algorithm_selector/version.rb f906b6ec2f42d6a2d9b988d91284b8b4c87ea3a6
2
+ lib/algorithm_selector/version.rb d072ccedf90400b2b79c6b39e8443e7ea9fd2026
Binary file
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = %q{Takes a desired action and data set, returns best algorithm.}
13
13
  spec.description = %q{Calculates algorithms and data structures for sorting and searching. Selects best one to use for particular data set.
14
- Currently supports: Bubble Sort, Insertion Sort, Selection Sort, Merge Sort, Quick Sort, Stack, Queue, Linked List, Binary Search Tree}
14
+ Currently supports: Bubble Sort, Insertion Sort, Selection Sort, Merge Sort, Quick Sort, Heap Sort, Stack, Queue, Linked List, Binary Search Tree}
15
15
  spec.homepage = "https://github.com/jnvbui/algorithm_selector"
16
16
  spec.license = "MIT"
17
17
 
@@ -115,7 +115,7 @@
115
115
  <dt id="VERSION-constant" class="">VERSION =
116
116
 
117
117
  </dt>
118
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.1.3</span><span class='tstring_end'>&quot;</span></span></pre></dd>
118
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.1.5</span><span class='tstring_end'>&quot;</span></span></pre></dd>
119
119
 
120
120
  </dl>
121
121
 
@@ -506,7 +506,7 @@
506
506
  </div>
507
507
 
508
508
  <div id="footer">
509
- Generated on Sat Jul 30 20:58:51 2016 by
509
+ Generated on Sat Jul 30 21:03:38 2016 by
510
510
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
511
511
  0.9.4 (ruby-2.1.2).
512
512
  </div>
@@ -430,7 +430,7 @@
430
430
  </div>
431
431
 
432
432
  <div id="footer">
433
- Generated on Sat Jul 30 20:58:51 2016 by
433
+ Generated on Sat Jul 30 21:03:38 2016 by
434
434
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
435
435
  0.9.4 (ruby-2.1.2).
436
436
  </div>
@@ -0,0 +1,741 @@
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: BinaryMinHeap
8
+
9
+ &mdash; Documentation by YARD 0.9.4
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 = "BinaryMinHeap";
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"></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 (B)</a> &raquo;
40
+
41
+
42
+ <span class="title">BinaryMinHeap</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
+ <iframe id="search_frame" src="class_list.html"></iframe>
63
+
64
+ <div id="content"><h1>Class: BinaryMinHeap
65
+
66
+
67
+
68
+ </h1>
69
+ <div class="box_info">
70
+
71
+ <dl>
72
+ <dt>Inherits:</dt>
73
+ <dd>
74
+ <span class="inheritName">Object</span>
75
+
76
+ <ul class="fullTree">
77
+ <li>Object</li>
78
+
79
+ <li class="next">BinaryMinHeap</li>
80
+
81
+ </ul>
82
+ <a href="#" class="inheritanceTree">show all</a>
83
+
84
+ </dd>
85
+ </dl>
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ <dl>
98
+ <dt>Defined in:</dt>
99
+ <dd>lib/algorithm_selector.rb</dd>
100
+ </dl>
101
+
102
+ </div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+
107
+ <p>MinHeap helper class for Heap Sort</p>
108
+
109
+
110
+ </div>
111
+ </div>
112
+ <div class="tags">
113
+
114
+
115
+ </div>
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+ <h2>
124
+ Class Method Summary
125
+ <small><a href="#" class="summary_toggle">collapse</a></small>
126
+ </h2>
127
+
128
+ <ul class="summary">
129
+
130
+ <li class="public ">
131
+ <span class="summary_signature">
132
+
133
+ <a href="#child_indices-class_method" title="child_indices (class method)">.<strong>child_indices</strong>(len, parent_index) &#x21d2; Object </a>
134
+
135
+
136
+
137
+ </span>
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+ <span class="summary_desc"><div class='inline'></div></span>
148
+
149
+ </li>
150
+
151
+
152
+ <li class="public ">
153
+ <span class="summary_signature">
154
+
155
+ <a href="#heapify_down-class_method" title="heapify_down (class method)">.<strong>heapify_down</strong>(array, parent_idx, len = array.length, &amp;prc) &#x21d2; Object </a>
156
+
157
+
158
+
159
+ </span>
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ <span class="summary_desc"><div class='inline'></div></span>
170
+
171
+ </li>
172
+
173
+
174
+ <li class="public ">
175
+ <span class="summary_signature">
176
+
177
+ <a href="#heapify_up-class_method" title="heapify_up (class method)">.<strong>heapify_up</strong>(array, child_idx, len = array.length, &amp;prc) &#x21d2; Object </a>
178
+
179
+
180
+
181
+ </span>
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+ <span class="summary_desc"><div class='inline'></div></span>
192
+
193
+ </li>
194
+
195
+
196
+ <li class="public ">
197
+ <span class="summary_signature">
198
+
199
+ <a href="#parent_index-class_method" title="parent_index (class method)">.<strong>parent_index</strong>(child_index) &#x21d2; Object </a>
200
+
201
+
202
+
203
+ </span>
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+ <span class="summary_desc"><div class='inline'></div></span>
214
+
215
+ </li>
216
+
217
+
218
+ </ul>
219
+
220
+ <h2>
221
+ Instance Method Summary
222
+ <small><a href="#" class="summary_toggle">collapse</a></small>
223
+ </h2>
224
+
225
+ <ul class="summary">
226
+
227
+ <li class="public ">
228
+ <span class="summary_signature">
229
+
230
+ <a href="#count-instance_method" title="#count (instance method)">#<strong>count</strong> &#x21d2; Object </a>
231
+
232
+
233
+
234
+ </span>
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+ <span class="summary_desc"><div class='inline'></div></span>
245
+
246
+ </li>
247
+
248
+
249
+ <li class="public ">
250
+ <span class="summary_signature">
251
+
252
+ <a href="#extract-instance_method" title="#extract (instance method)">#<strong>extract</strong> &#x21d2; Object </a>
253
+
254
+
255
+
256
+ </span>
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+ <span class="summary_desc"><div class='inline'></div></span>
267
+
268
+ </li>
269
+
270
+
271
+ <li class="public ">
272
+ <span class="summary_signature">
273
+
274
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(&amp;prc) &#x21d2; BinaryMinHeap </a>
275
+
276
+
277
+
278
+ </span>
279
+
280
+
281
+ <span class="note title constructor">constructor</span>
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+ <span class="summary_desc"><div class='inline'>
291
+ <p>A new instance of BinaryMinHeap.</p>
292
+ </div></span>
293
+
294
+ </li>
295
+
296
+
297
+ <li class="public ">
298
+ <span class="summary_signature">
299
+
300
+ <a href="#peek-instance_method" title="#peek (instance method)">#<strong>peek</strong> &#x21d2; Object </a>
301
+
302
+
303
+
304
+ </span>
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+ <span class="summary_desc"><div class='inline'></div></span>
315
+
316
+ </li>
317
+
318
+
319
+ <li class="public ">
320
+ <span class="summary_signature">
321
+
322
+ <a href="#push-instance_method" title="#push (instance method)">#<strong>push</strong>(val) &#x21d2; Object </a>
323
+
324
+
325
+
326
+ </span>
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+ <span class="summary_desc"><div class='inline'></div></span>
337
+
338
+ </li>
339
+
340
+
341
+ </ul>
342
+
343
+
344
+ <div id="constructor_details" class="method_details_list">
345
+ <h2>Constructor Details</h2>
346
+
347
+ <div class="method_details first">
348
+ <h3 class="signature first" id="initialize-instance_method">
349
+
350
+ #<strong>initialize</strong>(&amp;prc) &#x21d2; <tt><span class='object_link'><a href="" title="BinaryMinHeap (class)">BinaryMinHeap</a></span></tt>
351
+
352
+
353
+
354
+
355
+
356
+ </h3><div class="docstring">
357
+ <div class="discussion">
358
+
359
+ <p>Returns a new instance of BinaryMinHeap</p>
360
+
361
+
362
+ </div>
363
+ </div>
364
+ <div class="tags">
365
+
366
+
367
+ </div><table class="source_code">
368
+ <tr>
369
+ <td>
370
+ <pre class="lines">
371
+
372
+
373
+ 592
374
+ 593
375
+ 594
376
+ 595</pre>
377
+ </td>
378
+ <td>
379
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 592</span>
380
+
381
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_prc'>prc</span><span class='rparen'>)</span>
382
+ <span class='ivar'>@store</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
383
+ <span class='ivar'>@prc</span> <span class='op'>=</span> <span class='id identifier rubyid_prc'>prc</span> <span class='op'>||</span> <span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_el1'>el1</span><span class='comma'>,</span> <span class='id identifier rubyid_el2'>el2</span><span class='op'>|</span> <span class='id identifier rubyid_el1'>el1</span> <span class='op'>&lt;=&gt;</span> <span class='id identifier rubyid_el2'>el2</span> <span class='rbrace'>}</span>
384
+ <span class='kw'>end</span></pre>
385
+ </td>
386
+ </tr>
387
+ </table>
388
+ </div>
389
+
390
+ </div>
391
+
392
+
393
+ <div id="class_method_details" class="method_details_list">
394
+ <h2>Class Method Details</h2>
395
+
396
+
397
+ <div class="method_details first">
398
+ <h3 class="signature first" id="child_indices-class_method">
399
+
400
+ .<strong>child_indices</strong>(len, parent_index) &#x21d2; <tt>Object</tt>
401
+
402
+
403
+
404
+
405
+
406
+ </h3><table class="source_code">
407
+ <tr>
408
+ <td>
409
+ <pre class="lines">
410
+
411
+
412
+ 626
413
+ 627
414
+ 628</pre>
415
+ </td>
416
+ <td>
417
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 626</span>
418
+
419
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_child_indices'>child_indices</span><span class='lparen'>(</span><span class='id identifier rubyid_len'>len</span><span class='comma'>,</span> <span class='id identifier rubyid_parent_index'>parent_index</span><span class='rparen'>)</span>
420
+ <span class='lbracket'>[</span><span class='int'>2</span> <span class='op'>*</span> <span class='id identifier rubyid_parent_index'>parent_index</span> <span class='op'>+</span> <span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span> <span class='op'>*</span> <span class='id identifier rubyid_parent_index'>parent_index</span> <span class='op'>+</span> <span class='int'>2</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_idx'>idx</span><span class='op'>|</span> <span class='id identifier rubyid_idx'>idx</span> <span class='op'>&lt;</span> <span class='id identifier rubyid_len'>len</span> <span class='rbrace'>}</span>
421
+ <span class='kw'>end</span></pre>
422
+ </td>
423
+ </tr>
424
+ </table>
425
+ </div>
426
+
427
+ <div class="method_details ">
428
+ <h3 class="signature " id="heapify_down-class_method">
429
+
430
+ .<strong>heapify_down</strong>(array, parent_idx, len = array.length, &amp;prc) &#x21d2; <tt>Object</tt>
431
+
432
+
433
+
434
+
435
+
436
+ </h3><table class="source_code">
437
+ <tr>
438
+ <td>
439
+ <pre class="lines">
440
+
441
+
442
+ 635
443
+ 636
444
+ 637
445
+ 638
446
+ 639
447
+ 640
448
+ 641
449
+ 642
450
+ 643
451
+ 644
452
+ 645
453
+ 646
454
+ 647
455
+ 648
456
+ 649
457
+ 650
458
+ 651
459
+ 652
460
+ 653
461
+ 654
462
+ 655
463
+ 656
464
+ 657
465
+ 658
466
+ 659
467
+ 660</pre>
468
+ </td>
469
+ <td>
470
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 635</span>
471
+
472
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_heapify_down'>heapify_down</span><span class='lparen'>(</span><span class='id identifier rubyid_array'>array</span><span class='comma'>,</span> <span class='id identifier rubyid_parent_idx'>parent_idx</span><span class='comma'>,</span> <span class='id identifier rubyid_len'>len</span> <span class='op'>=</span> <span class='id identifier rubyid_array'>array</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_prc'>prc</span><span class='rparen'>)</span>
473
+ <span class='id identifier rubyid_prc'>prc</span> <span class='op'>||=</span> <span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_el1'>el1</span><span class='comma'>,</span> <span class='id identifier rubyid_el2'>el2</span><span class='op'>|</span> <span class='id identifier rubyid_el1'>el1</span> <span class='op'>&lt;=&gt;</span> <span class='id identifier rubyid_el2'>el2</span> <span class='rbrace'>}</span>
474
+
475
+ <span class='id identifier rubyid_left_child'>left_child</span><span class='comma'>,</span> <span class='id identifier rubyid_right_child'>right_child</span> <span class='op'>=</span> <span class='id identifier rubyid_child_indices'>child_indices</span><span class='lparen'>(</span><span class='id identifier rubyid_len'>len</span><span class='comma'>,</span> <span class='id identifier rubyid_parent_idx'>parent_idx</span><span class='rparen'>)</span>
476
+
477
+ <span class='id identifier rubyid_parent'>parent</span> <span class='op'>=</span> <span class='id identifier rubyid_array'>array</span><span class='lbracket'>[</span><span class='id identifier rubyid_parent_idx'>parent_idx</span><span class='rbracket'>]</span>
478
+
479
+ <span class='id identifier rubyid_children'>children</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
480
+ <span class='id identifier rubyid_children'>children</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_array'>array</span><span class='lbracket'>[</span><span class='id identifier rubyid_left_child'>left_child</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_left_child'>left_child</span>
481
+ <span class='id identifier rubyid_children'>children</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_array'>array</span><span class='lbracket'>[</span><span class='id identifier rubyid_right_child'>right_child</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_right_child'>right_child</span>
482
+
483
+ <span class='kw'>if</span> <span class='id identifier rubyid_children'>children</span><span class='period'>.</span><span class='id identifier rubyid_all?'>all?</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_child'>child</span><span class='op'>|</span> <span class='id identifier rubyid_prc'>prc</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='id identifier rubyid_child'>child</span><span class='rparen'>)</span> <span class='op'>&lt;=</span> <span class='int'>0</span> <span class='rbrace'>}</span>
484
+ <span class='kw'>return</span> <span class='id identifier rubyid_array'>array</span>
485
+ <span class='kw'>end</span>
486
+
487
+ <span class='id identifier rubyid_swap_idx'>swap_idx</span> <span class='op'>=</span> <span class='kw'>nil</span>
488
+ <span class='kw'>if</span> <span class='id identifier rubyid_children'>children</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>1</span>
489
+ <span class='id identifier rubyid_swap_idx'>swap_idx</span> <span class='op'>=</span> <span class='id identifier rubyid_left_child'>left_child</span>
490
+ <span class='kw'>else</span>
491
+ <span class='id identifier rubyid_swap_idx'>swap_idx</span> <span class='op'>=</span>
492
+ <span class='id identifier rubyid_prc'>prc</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_children'>children</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_children'>children</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='op'>-</span><span class='int'>1</span> <span class='op'>?</span> <span class='id identifier rubyid_left_child'>left_child</span> <span class='op'>:</span> <span class='id identifier rubyid_right_child'>right_child</span>
493
+ <span class='kw'>end</span>
494
+
495
+ <span class='id identifier rubyid_array'>array</span><span class='lbracket'>[</span><span class='id identifier rubyid_parent_idx'>parent_idx</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_array'>array</span><span class='lbracket'>[</span><span class='id identifier rubyid_swap_idx'>swap_idx</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_array'>array</span><span class='lbracket'>[</span><span class='id identifier rubyid_swap_idx'>swap_idx</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_parent'>parent</span>
496
+ <span class='id identifier rubyid_heapify_down'>heapify_down</span><span class='lparen'>(</span><span class='id identifier rubyid_array'>array</span><span class='comma'>,</span> <span class='id identifier rubyid_swap_idx'>swap_idx</span><span class='comma'>,</span> <span class='id identifier rubyid_len'>len</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_prc'>prc</span><span class='rparen'>)</span>
497
+ <span class='kw'>end</span></pre>
498
+ </td>
499
+ </tr>
500
+ </table>
501
+ </div>
502
+
503
+ <div class="method_details ">
504
+ <h3 class="signature " id="heapify_up-class_method">
505
+
506
+ .<strong>heapify_up</strong>(array, child_idx, len = array.length, &amp;prc) &#x21d2; <tt>Object</tt>
507
+
508
+
509
+
510
+
511
+
512
+ </h3><table class="source_code">
513
+ <tr>
514
+ <td>
515
+ <pre class="lines">
516
+
517
+
518
+ 662
519
+ 663
520
+ 664
521
+ 665
522
+ 666
523
+ 667
524
+ 668
525
+ 669
526
+ 670
527
+ 671
528
+ 672
529
+ 673
530
+ 674</pre>
531
+ </td>
532
+ <td>
533
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 662</span>
534
+
535
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_heapify_up'>heapify_up</span><span class='lparen'>(</span><span class='id identifier rubyid_array'>array</span><span class='comma'>,</span> <span class='id identifier rubyid_child_idx'>child_idx</span><span class='comma'>,</span> <span class='id identifier rubyid_len'>len</span> <span class='op'>=</span> <span class='id identifier rubyid_array'>array</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_prc'>prc</span><span class='rparen'>)</span>
536
+ <span class='id identifier rubyid_prc'>prc</span> <span class='op'>||=</span> <span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_el1'>el1</span><span class='comma'>,</span> <span class='id identifier rubyid_el2'>el2</span><span class='op'>|</span> <span class='id identifier rubyid_el1'>el1</span> <span class='op'>&lt;=&gt;</span> <span class='id identifier rubyid_el2'>el2</span> <span class='rbrace'>}</span>
537
+ <span class='kw'>return</span> <span class='id identifier rubyid_array'>array</span> <span class='kw'>if</span> <span class='id identifier rubyid_child_idx'>child_idx</span> <span class='op'>==</span> <span class='int'>0</span>
538
+
539
+ <span class='id identifier rubyid_parent_idx'>parent_idx</span> <span class='op'>=</span> <span class='id identifier rubyid_parent_index'>parent_index</span><span class='lparen'>(</span><span class='id identifier rubyid_child_idx'>child_idx</span><span class='rparen'>)</span>
540
+ <span class='id identifier rubyid_child'>child</span><span class='comma'>,</span> <span class='id identifier rubyid_parent'>parent</span> <span class='op'>=</span> <span class='id identifier rubyid_array'>array</span><span class='lbracket'>[</span><span class='id identifier rubyid_child_idx'>child_idx</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_array'>array</span><span class='lbracket'>[</span><span class='id identifier rubyid_parent_idx'>parent_idx</span><span class='rbracket'>]</span>
541
+ <span class='kw'>if</span> <span class='id identifier rubyid_prc'>prc</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_child'>child</span><span class='comma'>,</span> <span class='id identifier rubyid_parent'>parent</span><span class='rparen'>)</span> <span class='op'>&gt;=</span> <span class='int'>0</span>
542
+ <span class='kw'>return</span> <span class='id identifier rubyid_array'>array</span>
543
+ <span class='kw'>else</span>
544
+ <span class='id identifier rubyid_array'>array</span><span class='lbracket'>[</span><span class='id identifier rubyid_child_idx'>child_idx</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_array'>array</span><span class='lbracket'>[</span><span class='id identifier rubyid_parent_idx'>parent_idx</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='id identifier rubyid_child'>child</span>
545
+ <span class='id identifier rubyid_heapify_up'>heapify_up</span><span class='lparen'>(</span><span class='id identifier rubyid_array'>array</span><span class='comma'>,</span> <span class='id identifier rubyid_parent_idx'>parent_idx</span><span class='comma'>,</span> <span class='id identifier rubyid_len'>len</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_prc'>prc</span><span class='rparen'>)</span>
546
+ <span class='kw'>end</span>
547
+ <span class='kw'>end</span></pre>
548
+ </td>
549
+ </tr>
550
+ </table>
551
+ </div>
552
+
553
+ <div class="method_details ">
554
+ <h3 class="signature " id="parent_index-class_method">
555
+
556
+ .<strong>parent_index</strong>(child_index) &#x21d2; <tt>Object</tt>
557
+
558
+
559
+
560
+
561
+
562
+ </h3><table class="source_code">
563
+ <tr>
564
+ <td>
565
+ <pre class="lines">
566
+
567
+
568
+ 630
569
+ 631
570
+ 632
571
+ 633</pre>
572
+ </td>
573
+ <td>
574
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 630</span>
575
+
576
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parent_index'>parent_index</span><span class='lparen'>(</span><span class='id identifier rubyid_child_index'>child_index</span><span class='rparen'>)</span>
577
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>root has no parent</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_child_index'>child_index</span> <span class='op'>==</span> <span class='int'>0</span>
578
+ <span class='lparen'>(</span><span class='id identifier rubyid_child_index'>child_index</span> <span class='op'>-</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='op'>/</span> <span class='int'>2</span>
579
+ <span class='kw'>end</span></pre>
580
+ </td>
581
+ </tr>
582
+ </table>
583
+ </div>
584
+
585
+ </div>
586
+
587
+ <div id="instance_method_details" class="method_details_list">
588
+ <h2>Instance Method Details</h2>
589
+
590
+
591
+ <div class="method_details first">
592
+ <h3 class="signature first" id="count-instance_method">
593
+
594
+ #<strong>count</strong> &#x21d2; <tt>Object</tt>
595
+
596
+
597
+
598
+
599
+
600
+ </h3><table class="source_code">
601
+ <tr>
602
+ <td>
603
+ <pre class="lines">
604
+
605
+
606
+ 597
607
+ 598
608
+ 599</pre>
609
+ </td>
610
+ <td>
611
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 597</span>
612
+
613
+ <span class='kw'>def</span> <span class='id identifier rubyid_count'>count</span>
614
+ <span class='ivar'>@store</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
615
+ <span class='kw'>end</span></pre>
616
+ </td>
617
+ </tr>
618
+ </table>
619
+ </div>
620
+
621
+ <div class="method_details ">
622
+ <h3 class="signature " id="extract-instance_method">
623
+
624
+ #<strong>extract</strong> &#x21d2; <tt>Object</tt>
625
+
626
+
627
+
628
+
629
+
630
+ </h3><table class="source_code">
631
+ <tr>
632
+ <td>
633
+ <pre class="lines">
634
+
635
+
636
+ 601
637
+ 602
638
+ 603
639
+ 604
640
+ 605
641
+ 606
642
+ 607
643
+ 608
644
+ 609
645
+ 610</pre>
646
+ </td>
647
+ <td>
648
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 601</span>
649
+
650
+ <span class='kw'>def</span> <span class='id identifier rubyid_extract'>extract</span>
651
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>no element to extract</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_count'>count</span> <span class='op'>==</span> <span class='int'>0</span>
652
+ <span class='id identifier rubyid_val'>val</span> <span class='op'>=</span> <span class='ivar'>@store</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
653
+ <span class='ivar'>@store</span><span class='period'>.</span><span class='id identifier rubyid_pop'>pop</span> <span class='kw'>if</span> <span class='id identifier rubyid_count'>count</span> <span class='op'>==</span> <span class='int'>1</span>
654
+ <span class='kw'>if</span> <span class='id identifier rubyid_count'>count</span> <span class='op'>&gt;</span> <span class='int'>1</span>
655
+ <span class='ivar'>@store</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='ivar'>@store</span><span class='period'>.</span><span class='id identifier rubyid_pop'>pop</span>
656
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_heapify_down'>heapify_down</span><span class='lparen'>(</span><span class='ivar'>@store</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='ivar'>@prc</span><span class='rparen'>)</span>
657
+ <span class='kw'>end</span>
658
+ <span class='id identifier rubyid_val'>val</span>
659
+ <span class='kw'>end</span></pre>
660
+ </td>
661
+ </tr>
662
+ </table>
663
+ </div>
664
+
665
+ <div class="method_details ">
666
+ <h3 class="signature " id="peek-instance_method">
667
+
668
+ #<strong>peek</strong> &#x21d2; <tt>Object</tt>
669
+
670
+
671
+
672
+
673
+
674
+ </h3><table class="source_code">
675
+ <tr>
676
+ <td>
677
+ <pre class="lines">
678
+
679
+
680
+ 612
681
+ 613
682
+ 614
683
+ 615</pre>
684
+ </td>
685
+ <td>
686
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 612</span>
687
+
688
+ <span class='kw'>def</span> <span class='id identifier rubyid_peek'>peek</span>
689
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>no element to peek</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_count'>count</span> <span class='op'>==</span> <span class='int'>0</span>
690
+ <span class='ivar'>@store</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
691
+ <span class='kw'>end</span></pre>
692
+ </td>
693
+ </tr>
694
+ </table>
695
+ </div>
696
+
697
+ <div class="method_details ">
698
+ <h3 class="signature " id="push-instance_method">
699
+
700
+ #<strong>push</strong>(val) &#x21d2; <tt>Object</tt>
701
+
702
+
703
+
704
+
705
+
706
+ </h3><table class="source_code">
707
+ <tr>
708
+ <td>
709
+ <pre class="lines">
710
+
711
+
712
+ 617
713
+ 618
714
+ 619
715
+ 620</pre>
716
+ </td>
717
+ <td>
718
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 617</span>
719
+
720
+ <span class='kw'>def</span> <span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
721
+ <span class='ivar'>@store</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
722
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_heapify_up'>heapify_up</span><span class='lparen'>(</span><span class='ivar'>@store</span><span class='comma'>,</span> <span class='id identifier rubyid_count'>count</span> <span class='op'>-</span> <span class='int'>1</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='ivar'>@prc</span><span class='rparen'>)</span>
723
+ <span class='kw'>end</span></pre>
724
+ </td>
725
+ </tr>
726
+ </table>
727
+ </div>
728
+
729
+ </div>
730
+
731
+ </div>
732
+
733
+ <div id="footer">
734
+ Generated on Sat Jul 30 21:03:38 2016 by
735
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
736
+ 0.9.4 (ruby-2.1.2).
737
+ </div>
738
+
739
+ </div>
740
+ </body>
741
+ </html>
@@ -562,7 +562,7 @@
562
562
  </div>
563
563
 
564
564
  <div id="footer">
565
- Generated on Sat Jul 30 20:58:51 2016 by
565
+ Generated on Sat Jul 30 21:03:38 2016 by
566
566
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
567
567
  0.9.4 (ruby-2.1.2).
568
568
  </div>
@@ -430,7 +430,7 @@
430
430
  </div>
431
431
 
432
432
  <div id="footer">
433
- Generated on Sat Jul 30 20:58:51 2016 by
433
+ Generated on Sat Jul 30 21:03:38 2016 by
434
434
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
435
435
  0.9.4 (ruby-2.1.2).
436
436
  </div>
@@ -869,7 +869,7 @@
869
869
  </div>
870
870
 
871
871
  <div id="footer">
872
- Generated on Sat Jul 30 20:58:51 2016 by
872
+ Generated on Sat Jul 30 21:03:38 2016 by
873
873
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
874
874
  0.9.4 (ruby-2.1.2).
875
875
  </div>
@@ -546,7 +546,7 @@
546
546
  </div>
547
547
 
548
548
  <div id="footer">
549
- Generated on Sat Jul 30 20:58:51 2016 by
549
+ Generated on Sat Jul 30 21:03:38 2016 by
550
550
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
551
551
  0.9.4 (ruby-2.1.2).
552
552
  </div>
@@ -495,7 +495,7 @@
495
495
  </div>
496
496
 
497
497
  <div id="footer">
498
- Generated on Sat Jul 30 20:58:51 2016 by
498
+ Generated on Sat Jul 30 21:03:38 2016 by
499
499
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
500
500
  0.9.4 (ruby-2.1.2).
501
501
  </div>
@@ -990,7 +990,7 @@ Complexity: O(n^2) Worst-Case Time Complexity: O(n^2)</p>
990
990
  </div>
991
991
 
992
992
  <div id="footer">
993
- Generated on Sat Jul 30 20:58:51 2016 by
993
+ Generated on Sat Jul 30 21:03:38 2016 by
994
994
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
995
995
  0.9.4 (ruby-2.1.2).
996
996
  </div>
@@ -700,7 +700,7 @@ Complexity: O(n)</p>
700
700
  </div>
701
701
 
702
702
  <div id="footer">
703
- Generated on Sat Jul 30 20:58:51 2016 by
703
+ Generated on Sat Jul 30 21:03:38 2016 by
704
704
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
705
705
  0.9.4 (ruby-2.1.2).
706
706
  </div>
@@ -178,7 +178,7 @@
178
178
  </div>
179
179
 
180
180
  <div id="footer">
181
- Generated on Sat Jul 30 20:58:50 2016 by
181
+ Generated on Sat Jul 30 21:03:37 2016 by
182
182
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
183
183
  0.9.4 (ruby-2.1.2).
184
184
  </div>
@@ -314,7 +314,7 @@ href="http://opensource.org/licenses/MIT">MIT License</a>.</p>
314
314
  </div></div>
315
315
 
316
316
  <div id="footer">
317
- Generated on Sat Jul 30 20:58:51 2016 by
317
+ Generated on Sat Jul 30 21:03:38 2016 by
318
318
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
319
319
  0.9.4 (ruby-2.1.2).
320
320
  </div>
@@ -314,7 +314,7 @@ href="http://opensource.org/licenses/MIT">MIT License</a>.</p>
314
314
  </div></div>
315
315
 
316
316
  <div id="footer">
317
- Generated on Sat Jul 30 20:58:51 2016 by
317
+ Generated on Sat Jul 30 21:03:37 2016 by
318
318
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
319
319
  0.9.4 (ruby-2.1.2).
320
320
  </div>
@@ -104,7 +104,7 @@
104
104
  </div>
105
105
 
106
106
  <div id="footer">
107
- Generated on Sat Jul 30 20:58:51 2016 by
107
+ Generated on Sat Jul 30 21:03:38 2016 by
108
108
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
109
109
  0.9.4 (ruby-2.1.2).
110
110
  </div>
@@ -1,3 +1,3 @@
1
1
  module AlgorithmSelector
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algorithm_selector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - joseph
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '3.0'
55
55
  description: |-
56
56
  Calculates algorithms and data structures for sorting and searching. Selects best one to use for particular data set.
57
- Currently supports: Bubble Sort, Insertion Sort, Selection Sort, Merge Sort, Quick Sort, Stack, Queue, Linked List, Binary Search Tree
57
+ Currently supports: Bubble Sort, Insertion Sort, Selection Sort, Merge Sort, Quick Sort, Heap Sort, Stack, Queue, Linked List, Binary Search Tree
58
58
  email:
59
59
  - jnvbui@gmail.com
60
60
  executables: []
@@ -77,6 +77,7 @@ files:
77
77
  - bin/setup
78
78
  - doc/AlgorithmSelector.html
79
79
  - doc/BSTNode.html
80
+ - doc/BinaryMinHeap.html
80
81
  - doc/BinaryTree.html
81
82
  - doc/LinkNode.html
82
83
  - doc/LinkedList.html