algorithm_selector 0.1.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.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +1 -0
- data/.yardoc/checksums +2 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +6 -0
- data/algorithm_selector.gemspec +35 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/doc/AlgorithmSelector.html +505 -0
- data/doc/BSTNode.html +440 -0
- data/doc/BinaryTree.html +572 -0
- data/doc/LinkNode.html +440 -0
- data/doc/LinkedList.html +879 -0
- data/doc/Queue.html +569 -0
- data/doc/Searches.html +442 -0
- data/doc/Sorts.html +916 -0
- data/doc/Stack.html +723 -0
- data/doc/_index.html +183 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +481 -0
- data/doc/file.README.html +129 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +129 -0
- data/doc/js/app.js +243 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +507 -0
- data/doc/top-level-namespace.html +114 -0
- data/lib/.DS_Store +0 -0
- data/lib/algorithm_selector.rb +562 -0
- data/lib/algorithm_selector/version.rb +3 -0
- metadata +129 -0
data/doc/Stack.html
ADDED
@@ -0,0 +1,723 @@
|
|
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: Stack
|
8
|
+
|
9
|
+
— 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 = "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"></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> »
|
40
|
+
|
41
|
+
|
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
|
+
<iframe id="search_frame" src="class_list.html"></iframe>
|
63
|
+
|
64
|
+
<div id="content"><h1>Class: Stack
|
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">Stack</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>Stack data structure Worst-Case Space Complexity: O(n)</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
|
+
Instance 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="#empty%3F-instance_method" title="#empty? (instance method)">#<strong>empty?</strong> ⇒ Boolean </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="#full%3F-instance_method" title="#full? (instance method)">#<strong>full?</strong> ⇒ Boolean </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="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(size, array = []) ⇒ Stack </a>
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
</span>
|
182
|
+
|
183
|
+
|
184
|
+
<span class="note title constructor">constructor</span>
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
<span class="summary_desc"><div class='inline'>
|
194
|
+
<p>A new instance of Stack.</p>
|
195
|
+
</div></span>
|
196
|
+
|
197
|
+
</li>
|
198
|
+
|
199
|
+
|
200
|
+
<li class="public ">
|
201
|
+
<span class="summary_signature">
|
202
|
+
|
203
|
+
<a href="#look-instance_method" title="#look (instance method)">#<strong>look</strong> ⇒ Object </a>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
</span>
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
218
|
+
|
219
|
+
</li>
|
220
|
+
|
221
|
+
|
222
|
+
<li class="public ">
|
223
|
+
<span class="summary_signature">
|
224
|
+
|
225
|
+
<a href="#pop-instance_method" title="#pop (instance method)">#<strong>pop</strong> ⇒ Object </a>
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
</span>
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
<span class="summary_desc"><div class='inline'>
|
240
|
+
<p>Deletion, Worst-Case Time Complexity: O(1).</p>
|
241
|
+
</div></span>
|
242
|
+
|
243
|
+
</li>
|
244
|
+
|
245
|
+
|
246
|
+
<li class="public ">
|
247
|
+
<span class="summary_signature">
|
248
|
+
|
249
|
+
<a href="#push-instance_method" title="#push (instance method)">#<strong>push</strong>(el) ⇒ Object </a>
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
</span>
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<span class="summary_desc"><div class='inline'>
|
264
|
+
<p>Insertion, Worst-Case Time Complexity: O(1).</p>
|
265
|
+
</div></span>
|
266
|
+
|
267
|
+
</li>
|
268
|
+
|
269
|
+
|
270
|
+
<li class="public ">
|
271
|
+
<span class="summary_signature">
|
272
|
+
|
273
|
+
<a href="#search-instance_method" title="#search (instance method)">#<strong>search</strong>(target) ⇒ Object </a>
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
</span>
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
<span class="summary_desc"><div class='inline'>
|
288
|
+
<p>Search, Average-Case Time Complexity: O(n) Search, Worst-Case Time
|
289
|
+
Complexity: O(n).</p>
|
290
|
+
</div></span>
|
291
|
+
|
292
|
+
</li>
|
293
|
+
|
294
|
+
|
295
|
+
<li class="public ">
|
296
|
+
<span class="summary_signature">
|
297
|
+
|
298
|
+
<a href="#size-instance_method" title="#size (instance method)">#<strong>size</strong> ⇒ Object </a>
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
</span>
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
313
|
+
|
314
|
+
</li>
|
315
|
+
|
316
|
+
|
317
|
+
</ul>
|
318
|
+
|
319
|
+
|
320
|
+
<div id="constructor_details" class="method_details_list">
|
321
|
+
<h2>Constructor Details</h2>
|
322
|
+
|
323
|
+
<div class="method_details first">
|
324
|
+
<h3 class="signature first" id="initialize-instance_method">
|
325
|
+
|
326
|
+
#<strong>initialize</strong>(size, array = []) ⇒ <tt><span class='object_link'><a href="" title="Stack (class)">Stack</a></span></tt>
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
</h3><div class="docstring">
|
333
|
+
<div class="discussion">
|
334
|
+
|
335
|
+
<p>Returns a new instance of Stack</p>
|
336
|
+
|
337
|
+
|
338
|
+
</div>
|
339
|
+
</div>
|
340
|
+
<div class="tags">
|
341
|
+
|
342
|
+
|
343
|
+
</div><table class="source_code">
|
344
|
+
<tr>
|
345
|
+
<td>
|
346
|
+
<pre class="lines">
|
347
|
+
|
348
|
+
|
349
|
+
266
|
350
|
+
267
|
351
|
+
268
|
352
|
+
269
|
353
|
+
270
|
354
|
+
271</pre>
|
355
|
+
</td>
|
356
|
+
<td>
|
357
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 266</span>
|
358
|
+
|
359
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_size'>size</span><span class='comma'>,</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>
|
360
|
+
<span class='ivar'>@size</span> <span class='op'>=</span> <span class='id identifier rubyid_size'>size</span>
|
361
|
+
<span class='ivar'>@store</span> <span class='op'>=</span> <span class='const'>Array</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@size</span><span class='rparen'>)</span>
|
362
|
+
<span class='ivar'>@top</span> <span class='op'>=</span> <span class='op'>-</span><span class='int'>1</span>
|
363
|
+
<span class='id identifier rubyid_array'>array</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_el'>el</span><span class='op'>|</span> <span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_el'>el</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
364
|
+
<span class='kw'>end</span></pre>
|
365
|
+
</td>
|
366
|
+
</tr>
|
367
|
+
</table>
|
368
|
+
</div>
|
369
|
+
|
370
|
+
</div>
|
371
|
+
|
372
|
+
|
373
|
+
<div id="instance_method_details" class="method_details_list">
|
374
|
+
<h2>Instance Method Details</h2>
|
375
|
+
|
376
|
+
|
377
|
+
<div class="method_details first">
|
378
|
+
<h3 class="signature first" id="empty?-instance_method">
|
379
|
+
|
380
|
+
#<strong>empty?</strong> ⇒ <tt>Boolean</tt>
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
</h3><div class="docstring">
|
387
|
+
<div class="discussion">
|
388
|
+
|
389
|
+
|
390
|
+
</div>
|
391
|
+
</div>
|
392
|
+
<div class="tags">
|
393
|
+
|
394
|
+
<p class="tag_title">Returns:</p>
|
395
|
+
<ul class="return">
|
396
|
+
|
397
|
+
<li>
|
398
|
+
|
399
|
+
|
400
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
</li>
|
405
|
+
|
406
|
+
</ul>
|
407
|
+
|
408
|
+
</div><table class="source_code">
|
409
|
+
<tr>
|
410
|
+
<td>
|
411
|
+
<pre class="lines">
|
412
|
+
|
413
|
+
|
414
|
+
324
|
415
|
+
325
|
416
|
+
326</pre>
|
417
|
+
</td>
|
418
|
+
<td>
|
419
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 324</span>
|
420
|
+
|
421
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_empty?'>empty?</span>
|
422
|
+
<span class='ivar'>@top</span> <span class='op'>==</span> <span class='op'>-</span><span class='int'>1</span>
|
423
|
+
<span class='kw'>end</span></pre>
|
424
|
+
</td>
|
425
|
+
</tr>
|
426
|
+
</table>
|
427
|
+
</div>
|
428
|
+
|
429
|
+
<div class="method_details ">
|
430
|
+
<h3 class="signature " id="full?-instance_method">
|
431
|
+
|
432
|
+
#<strong>full?</strong> ⇒ <tt>Boolean</tt>
|
433
|
+
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
</h3><div class="docstring">
|
439
|
+
<div class="discussion">
|
440
|
+
|
441
|
+
|
442
|
+
</div>
|
443
|
+
</div>
|
444
|
+
<div class="tags">
|
445
|
+
|
446
|
+
<p class="tag_title">Returns:</p>
|
447
|
+
<ul class="return">
|
448
|
+
|
449
|
+
<li>
|
450
|
+
|
451
|
+
|
452
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
</li>
|
457
|
+
|
458
|
+
</ul>
|
459
|
+
|
460
|
+
</div><table class="source_code">
|
461
|
+
<tr>
|
462
|
+
<td>
|
463
|
+
<pre class="lines">
|
464
|
+
|
465
|
+
|
466
|
+
320
|
467
|
+
321
|
468
|
+
322</pre>
|
469
|
+
</td>
|
470
|
+
<td>
|
471
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 320</span>
|
472
|
+
|
473
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_full?'>full?</span>
|
474
|
+
<span class='ivar'>@top</span> <span class='op'>==</span> <span class='lparen'>(</span><span class='ivar'>@size</span> <span class='op'>-</span> <span class='int'>1</span><span class='rparen'>)</span>
|
475
|
+
<span class='kw'>end</span></pre>
|
476
|
+
</td>
|
477
|
+
</tr>
|
478
|
+
</table>
|
479
|
+
</div>
|
480
|
+
|
481
|
+
<div class="method_details ">
|
482
|
+
<h3 class="signature " id="look-instance_method">
|
483
|
+
|
484
|
+
#<strong>look</strong> ⇒ <tt>Object</tt>
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
|
490
|
+
</h3><table class="source_code">
|
491
|
+
<tr>
|
492
|
+
<td>
|
493
|
+
<pre class="lines">
|
494
|
+
|
495
|
+
|
496
|
+
316
|
497
|
+
317
|
498
|
+
318</pre>
|
499
|
+
</td>
|
500
|
+
<td>
|
501
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 316</span>
|
502
|
+
|
503
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_look'>look</span>
|
504
|
+
<span class='ivar'>@store</span><span class='lbracket'>[</span><span class='ivar'>@top</span><span class='rbracket'>]</span>
|
505
|
+
<span class='kw'>end</span></pre>
|
506
|
+
</td>
|
507
|
+
</tr>
|
508
|
+
</table>
|
509
|
+
</div>
|
510
|
+
|
511
|
+
<div class="method_details ">
|
512
|
+
<h3 class="signature " id="pop-instance_method">
|
513
|
+
|
514
|
+
#<strong>pop</strong> ⇒ <tt>Object</tt>
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
</h3><div class="docstring">
|
521
|
+
<div class="discussion">
|
522
|
+
|
523
|
+
<p>Deletion, Worst-Case Time Complexity: O(1)</p>
|
524
|
+
|
525
|
+
|
526
|
+
</div>
|
527
|
+
</div>
|
528
|
+
<div class="tags">
|
529
|
+
|
530
|
+
|
531
|
+
</div><table class="source_code">
|
532
|
+
<tr>
|
533
|
+
<td>
|
534
|
+
<pre class="lines">
|
535
|
+
|
536
|
+
|
537
|
+
290
|
538
|
+
291
|
539
|
+
292
|
540
|
+
293
|
541
|
+
294
|
542
|
+
295
|
543
|
+
296
|
544
|
+
297
|
545
|
+
298
|
546
|
+
299</pre>
|
547
|
+
</td>
|
548
|
+
<td>
|
549
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 290</span>
|
550
|
+
|
551
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_pop'>pop</span>
|
552
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_empty?'>empty?</span>
|
553
|
+
<span class='kw'>nil</span>
|
554
|
+
<span class='kw'>else</span>
|
555
|
+
<span class='id identifier rubyid_popped'>popped</span> <span class='op'>=</span> <span class='ivar'>@store</span><span class='lbracket'>[</span><span class='ivar'>@top</span><span class='rbracket'>]</span>
|
556
|
+
<span class='ivar'>@store</span><span class='lbracket'>[</span><span class='ivar'>@top</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
557
|
+
<span class='ivar'>@top</span> <span class='op'>=</span> <span class='ivar'>@top</span><span class='period'>.</span><span class='id identifier rubyid_pred'>pred</span>
|
558
|
+
<span class='id identifier rubyid_popped'>popped</span>
|
559
|
+
<span class='kw'>end</span>
|
560
|
+
<span class='kw'>end</span></pre>
|
561
|
+
</td>
|
562
|
+
</tr>
|
563
|
+
</table>
|
564
|
+
</div>
|
565
|
+
|
566
|
+
<div class="method_details ">
|
567
|
+
<h3 class="signature " id="push-instance_method">
|
568
|
+
|
569
|
+
#<strong>push</strong>(el) ⇒ <tt>Object</tt>
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
|
574
|
+
|
575
|
+
</h3><div class="docstring">
|
576
|
+
<div class="discussion">
|
577
|
+
|
578
|
+
<p>Insertion, Worst-Case Time Complexity: O(1)</p>
|
579
|
+
|
580
|
+
|
581
|
+
</div>
|
582
|
+
</div>
|
583
|
+
<div class="tags">
|
584
|
+
|
585
|
+
|
586
|
+
</div><table class="source_code">
|
587
|
+
<tr>
|
588
|
+
<td>
|
589
|
+
<pre class="lines">
|
590
|
+
|
591
|
+
|
592
|
+
302
|
593
|
+
303
|
594
|
+
304
|
595
|
+
305
|
596
|
+
306
|
597
|
+
307
|
598
|
+
308
|
599
|
+
309
|
600
|
+
310</pre>
|
601
|
+
</td>
|
602
|
+
<td>
|
603
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 302</span>
|
604
|
+
|
605
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_el'>el</span><span class='rparen'>)</span>
|
606
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_full?'>full?</span> <span class='kw'>or</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
607
|
+
<span class='kw'>nil</span>
|
608
|
+
<span class='kw'>else</span>
|
609
|
+
<span class='ivar'>@top</span> <span class='op'>=</span> <span class='ivar'>@top</span><span class='period'>.</span><span class='id identifier rubyid_succ'>succ</span>
|
610
|
+
<span class='ivar'>@store</span><span class='lbracket'>[</span><span class='ivar'>@top</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_el'>el</span>
|
611
|
+
<span class='kw'>self</span>
|
612
|
+
<span class='kw'>end</span>
|
613
|
+
<span class='kw'>end</span></pre>
|
614
|
+
</td>
|
615
|
+
</tr>
|
616
|
+
</table>
|
617
|
+
</div>
|
618
|
+
|
619
|
+
<div class="method_details ">
|
620
|
+
<h3 class="signature " id="search-instance_method">
|
621
|
+
|
622
|
+
#<strong>search</strong>(target) ⇒ <tt>Object</tt>
|
623
|
+
|
624
|
+
|
625
|
+
|
626
|
+
|
627
|
+
|
628
|
+
</h3><div class="docstring">
|
629
|
+
<div class="discussion">
|
630
|
+
|
631
|
+
<p>Search, Average-Case Time Complexity: O(n) Search, Worst-Case Time
|
632
|
+
Complexity: O(n)</p>
|
633
|
+
|
634
|
+
|
635
|
+
</div>
|
636
|
+
</div>
|
637
|
+
<div class="tags">
|
638
|
+
|
639
|
+
|
640
|
+
</div><table class="source_code">
|
641
|
+
<tr>
|
642
|
+
<td>
|
643
|
+
<pre class="lines">
|
644
|
+
|
645
|
+
|
646
|
+
275
|
647
|
+
276
|
648
|
+
277
|
649
|
+
278
|
650
|
+
279
|
651
|
+
280
|
652
|
+
281
|
653
|
+
282
|
654
|
+
283
|
655
|
+
284
|
656
|
+
285
|
657
|
+
286
|
658
|
+
287</pre>
|
659
|
+
</td>
|
660
|
+
<td>
|
661
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 275</span>
|
662
|
+
|
663
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_search'>search</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='rparen'>)</span>
|
664
|
+
<span class='id identifier rubyid_found'>found</span> <span class='op'>=</span> <span class='kw'>false</span>
|
665
|
+
<span class='id identifier rubyid_new_stack'>new_stack</span> <span class='op'>=</span> <span class='const'>Stack</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@size</span><span class='rparen'>)</span>
|
666
|
+
<span class='kw'>until</span> <span class='id identifier rubyid_empty?'>empty?</span> <span class='kw'>do</span>
|
667
|
+
<span class='id identifier rubyid_new_stack'>new_stack</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_pop'>pop</span><span class='rparen'>)</span>
|
668
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_new_stack'>new_stack</span><span class='period'>.</span><span class='id identifier rubyid_look'>look</span> <span class='op'>==</span> <span class='id identifier rubyid_target'>target</span>
|
669
|
+
<span class='id identifier rubyid_found'>found</span> <span class='op'>=</span> <span class='kw'>true</span>
|
670
|
+
<span class='kw'>break</span>
|
671
|
+
<span class='kw'>end</span>
|
672
|
+
<span class='kw'>end</span>
|
673
|
+
<span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_new_stack'>new_stack</span><span class='period'>.</span><span class='id identifier rubyid_pop'>pop</span><span class='rparen'>)</span> <span class='kw'>until</span> <span class='id identifier rubyid_new_stack'>new_stack</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
674
|
+
<span class='id identifier rubyid_found'>found</span>
|
675
|
+
<span class='kw'>end</span></pre>
|
676
|
+
</td>
|
677
|
+
</tr>
|
678
|
+
</table>
|
679
|
+
</div>
|
680
|
+
|
681
|
+
<div class="method_details ">
|
682
|
+
<h3 class="signature " id="size-instance_method">
|
683
|
+
|
684
|
+
#<strong>size</strong> ⇒ <tt>Object</tt>
|
685
|
+
|
686
|
+
|
687
|
+
|
688
|
+
|
689
|
+
|
690
|
+
</h3><table class="source_code">
|
691
|
+
<tr>
|
692
|
+
<td>
|
693
|
+
<pre class="lines">
|
694
|
+
|
695
|
+
|
696
|
+
312
|
697
|
+
313
|
698
|
+
314</pre>
|
699
|
+
</td>
|
700
|
+
<td>
|
701
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 312</span>
|
702
|
+
|
703
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_size'>size</span>
|
704
|
+
<span class='ivar'>@size</span>
|
705
|
+
<span class='kw'>end</span></pre>
|
706
|
+
</td>
|
707
|
+
</tr>
|
708
|
+
</table>
|
709
|
+
</div>
|
710
|
+
|
711
|
+
</div>
|
712
|
+
|
713
|
+
</div>
|
714
|
+
|
715
|
+
<div id="footer">
|
716
|
+
Generated on Fri Jul 22 11:22:30 2016 by
|
717
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
718
|
+
0.9.4 (ruby-2.1.2).
|
719
|
+
</div>
|
720
|
+
|
721
|
+
</div>
|
722
|
+
</body>
|
723
|
+
</html>
|