algorithm_selector 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,569 @@
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: Queue
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 = "Queue";
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 (Q)</a> &raquo;
40
+
41
+
42
+ <span class="title">Queue</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: Queue
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">Queue</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>Queue 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="#dequeue-instance_method" title="#dequeue (instance method)">#<strong>dequeue</strong> &#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'>
148
+ <p>Deletion, Worst-Case Time Complexity: O(1).</p>
149
+ </div></span>
150
+
151
+ </li>
152
+
153
+
154
+ <li class="public ">
155
+ <span class="summary_signature">
156
+
157
+ <a href="#enqueue-instance_method" title="#enqueue (instance method)">#<strong>enqueue</strong>(el) &#x21d2; Object </a>
158
+
159
+
160
+
161
+ </span>
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+ <span class="summary_desc"><div class='inline'>
172
+ <p>Insertion, Worst-Case Time Complexity: O(1).</p>
173
+ </div></span>
174
+
175
+ </li>
176
+
177
+
178
+ <li class="public ">
179
+ <span class="summary_signature">
180
+
181
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(size, array = []) &#x21d2; Queue </a>
182
+
183
+
184
+
185
+ </span>
186
+
187
+
188
+ <span class="note title constructor">constructor</span>
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+ <span class="summary_desc"><div class='inline'>
198
+ <p>A new instance of Queue.</p>
199
+ </div></span>
200
+
201
+ </li>
202
+
203
+
204
+ <li class="public ">
205
+ <span class="summary_signature">
206
+
207
+ <a href="#look-instance_method" title="#look (instance method)">#<strong>look</strong> &#x21d2; Object </a>
208
+
209
+
210
+
211
+ </span>
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+ <span class="summary_desc"><div class='inline'></div></span>
222
+
223
+ </li>
224
+
225
+
226
+ <li class="public ">
227
+ <span class="summary_signature">
228
+
229
+ <a href="#search-instance_method" title="#search (instance method)">#<strong>search</strong>(target) &#x21d2; Object </a>
230
+
231
+
232
+
233
+ </span>
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+ <span class="summary_desc"><div class='inline'>
244
+ <p>Search, Worst-Case Time Complexity: O(n).</p>
245
+ </div></span>
246
+
247
+ </li>
248
+
249
+
250
+ <li class="public ">
251
+ <span class="summary_signature">
252
+
253
+ <a href="#size-instance_method" title="#size (instance method)">#<strong>size</strong> &#x21d2; Object </a>
254
+
255
+
256
+
257
+ </span>
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+ <span class="summary_desc"><div class='inline'></div></span>
268
+
269
+ </li>
270
+
271
+
272
+ </ul>
273
+
274
+
275
+ <div id="constructor_details" class="method_details_list">
276
+ <h2>Constructor Details</h2>
277
+
278
+ <div class="method_details first">
279
+ <h3 class="signature first" id="initialize-instance_method">
280
+
281
+ #<strong>initialize</strong>(size, array = []) &#x21d2; <tt><span class='object_link'><a href="" title="Queue (class)">Queue</a></span></tt>
282
+
283
+
284
+
285
+
286
+
287
+ </h3><div class="docstring">
288
+ <div class="discussion">
289
+
290
+ <p>Returns a new instance of Queue</p>
291
+
292
+
293
+ </div>
294
+ </div>
295
+ <div class="tags">
296
+
297
+
298
+ </div><table class="source_code">
299
+ <tr>
300
+ <td>
301
+ <pre class="lines">
302
+
303
+
304
+ 332
305
+ 333
306
+ 334
307
+ 335
308
+ 336
309
+ 337
310
+ 338
311
+ 339</pre>
312
+ </td>
313
+ <td>
314
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 332</span>
315
+
316
+ <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>
317
+ <span class='ivar'>@size</span> <span class='op'>=</span> <span class='id identifier rubyid_size'>size</span>
318
+ <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>
319
+ <span class='ivar'>@head</span><span class='comma'>,</span> <span class='ivar'>@tail</span> <span class='op'>=</span> <span class='op'>-</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>0</span>
320
+
321
+ <span class='comment'># initialize Queue with array if given
322
+ </span> <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_enqueue'>enqueue</span><span class='lparen'>(</span><span class='id identifier rubyid_el'>el</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
323
+ <span class='kw'>end</span></pre>
324
+ </td>
325
+ </tr>
326
+ </table>
327
+ </div>
328
+
329
+ </div>
330
+
331
+
332
+ <div id="instance_method_details" class="method_details_list">
333
+ <h2>Instance Method Details</h2>
334
+
335
+
336
+ <div class="method_details first">
337
+ <h3 class="signature first" id="dequeue-instance_method">
338
+
339
+ #<strong>dequeue</strong> &#x21d2; <tt>Object</tt>
340
+
341
+
342
+
343
+
344
+
345
+ </h3><div class="docstring">
346
+ <div class="discussion">
347
+
348
+ <p>Deletion, Worst-Case Time Complexity: O(1)</p>
349
+
350
+
351
+ </div>
352
+ </div>
353
+ <div class="tags">
354
+
355
+
356
+ </div><table class="source_code">
357
+ <tr>
358
+ <td>
359
+ <pre class="lines">
360
+
361
+
362
+ 352
363
+ 353
364
+ 354
365
+ 355
366
+ 356
367
+ 357
368
+ 358
369
+ 359
370
+ 360
371
+ 361
372
+ 362</pre>
373
+ </td>
374
+ <td>
375
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 352</span>
376
+
377
+ <span class='kw'>def</span> <span class='id identifier rubyid_dequeue'>dequeue</span>
378
+ <span class='kw'>if</span> <span class='id identifier rubyid_empty?'>empty?</span>
379
+ <span class='kw'>nil</span>
380
+ <span class='kw'>else</span>
381
+ <span class='ivar'>@tail</span> <span class='op'>=</span> <span class='ivar'>@tail</span><span class='period'>.</span><span class='id identifier rubyid_succ'>succ</span>
382
+ <span class='id identifier rubyid_dequeued'>dequeued</span> <span class='op'>=</span> <span class='ivar'>@store</span><span class='lbracket'>[</span><span class='ivar'>@head</span><span class='rbracket'>]</span>
383
+ <span class='ivar'>@store</span><span class='period'>.</span><span class='id identifier rubyid_unshift'>unshift</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='rparen'>)</span>
384
+ <span class='ivar'>@store</span><span class='period'>.</span><span class='id identifier rubyid_pop'>pop</span>
385
+ <span class='id identifier rubyid_dequeued'>dequeued</span>
386
+ <span class='kw'>end</span>
387
+ <span class='kw'>end</span></pre>
388
+ </td>
389
+ </tr>
390
+ </table>
391
+ </div>
392
+
393
+ <div class="method_details ">
394
+ <h3 class="signature " id="enqueue-instance_method">
395
+
396
+ #<strong>enqueue</strong>(el) &#x21d2; <tt>Object</tt>
397
+
398
+
399
+
400
+
401
+
402
+ </h3><div class="docstring">
403
+ <div class="discussion">
404
+
405
+ <p>Insertion, Worst-Case Time Complexity: O(1)</p>
406
+
407
+
408
+ </div>
409
+ </div>
410
+ <div class="tags">
411
+
412
+
413
+ </div><table class="source_code">
414
+ <tr>
415
+ <td>
416
+ <pre class="lines">
417
+
418
+
419
+ 365
420
+ 366
421
+ 367
422
+ 368
423
+ 369
424
+ 370
425
+ 371
426
+ 372
427
+ 373</pre>
428
+ </td>
429
+ <td>
430
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 365</span>
431
+
432
+ <span class='kw'>def</span> <span class='id identifier rubyid_enqueue'>enqueue</span><span class='lparen'>(</span><span class='id identifier rubyid_el'>el</span><span class='rparen'>)</span>
433
+ <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>
434
+ <span class='kw'>nil</span>
435
+ <span class='kw'>else</span>
436
+ <span class='ivar'>@tail</span> <span class='op'>=</span> <span class='ivar'>@tail</span><span class='period'>.</span><span class='id identifier rubyid_pred'>pred</span>
437
+ <span class='ivar'>@store</span><span class='lbracket'>[</span><span class='ivar'>@tail</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_el'>el</span>
438
+ <span class='kw'>self</span>
439
+ <span class='kw'>end</span>
440
+ <span class='kw'>end</span></pre>
441
+ </td>
442
+ </tr>
443
+ </table>
444
+ </div>
445
+
446
+ <div class="method_details ">
447
+ <h3 class="signature " id="look-instance_method">
448
+
449
+ #<strong>look</strong> &#x21d2; <tt>Object</tt>
450
+
451
+
452
+
453
+
454
+
455
+ </h3><table class="source_code">
456
+ <tr>
457
+ <td>
458
+ <pre class="lines">
459
+
460
+
461
+ 379
462
+ 380
463
+ 381</pre>
464
+ </td>
465
+ <td>
466
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 379</span>
467
+
468
+ <span class='kw'>def</span> <span class='id identifier rubyid_look'>look</span>
469
+ <span class='ivar'>@store</span><span class='lbracket'>[</span><span class='ivar'>@head</span><span class='rbracket'>]</span>
470
+ <span class='kw'>end</span></pre>
471
+ </td>
472
+ </tr>
473
+ </table>
474
+ </div>
475
+
476
+ <div class="method_details ">
477
+ <h3 class="signature " id="search-instance_method">
478
+
479
+ #<strong>search</strong>(target) &#x21d2; <tt>Object</tt>
480
+
481
+
482
+
483
+
484
+
485
+ </h3><div class="docstring">
486
+ <div class="discussion">
487
+
488
+ <p>Search, Worst-Case Time Complexity: O(n)</p>
489
+
490
+
491
+ </div>
492
+ </div>
493
+ <div class="tags">
494
+
495
+
496
+ </div><table class="source_code">
497
+ <tr>
498
+ <td>
499
+ <pre class="lines">
500
+
501
+
502
+ 342
503
+ 343
504
+ 344
505
+ 345
506
+ 346
507
+ 347
508
+ 348
509
+ 349</pre>
510
+ </td>
511
+ <td>
512
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 342</span>
513
+
514
+ <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>
515
+ <span class='id identifier rubyid_found'>found</span> <span class='op'>=</span> <span class='kw'>false</span>
516
+ <span class='ivar'>@size</span><span class='period'>.</span><span class='id identifier rubyid_times'>times</span> <span class='kw'>do</span>
517
+ <span class='id identifier rubyid_found'>found</span> <span class='op'>=</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_look'>look</span> <span class='op'>==</span> <span class='id identifier rubyid_target'>target</span>
518
+ <span class='id identifier rubyid_enqueue'>enqueue</span><span class='lparen'>(</span><span class='id identifier rubyid_dequeue'>dequeue</span><span class='rparen'>)</span>
519
+ <span class='kw'>end</span>
520
+ <span class='id identifier rubyid_found'>found</span>
521
+ <span class='kw'>end</span></pre>
522
+ </td>
523
+ </tr>
524
+ </table>
525
+ </div>
526
+
527
+ <div class="method_details ">
528
+ <h3 class="signature " id="size-instance_method">
529
+
530
+ #<strong>size</strong> &#x21d2; <tt>Object</tt>
531
+
532
+
533
+
534
+
535
+
536
+ </h3><table class="source_code">
537
+ <tr>
538
+ <td>
539
+ <pre class="lines">
540
+
541
+
542
+ 375
543
+ 376
544
+ 377</pre>
545
+ </td>
546
+ <td>
547
+ <pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 375</span>
548
+
549
+ <span class='kw'>def</span> <span class='id identifier rubyid_size'>size</span>
550
+ <span class='ivar'>@size</span>
551
+ <span class='kw'>end</span></pre>
552
+ </td>
553
+ </tr>
554
+ </table>
555
+ </div>
556
+
557
+ </div>
558
+
559
+ </div>
560
+
561
+ <div id="footer">
562
+ Generated on Fri Jul 22 11:22:30 2016 by
563
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
564
+ 0.9.4 (ruby-2.1.2).
565
+ </div>
566
+
567
+ </div>
568
+ </body>
569
+ </html>