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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +3 -3
- data/documentation/CollectionUtils/Heap.html +1276 -0
- data/documentation/CollectionUtils/HeapUtils/MaxHeap.html +490 -0
- data/documentation/CollectionUtils/HeapUtils/MinHeap.html +490 -0
- data/documentation/CollectionUtils/HeapUtils.html +117 -0
- data/documentation/CollectionUtils/Queue.html +749 -0
- data/documentation/CollectionUtils/Stack.html +674 -0
- data/documentation/CollectionUtils/TreeUtils/BST.html +515 -0
- data/documentation/CollectionUtils/TreeUtils.html +117 -0
- data/documentation/CollectionUtils.html +134 -0
- data/documentation/_index.html +211 -0
- data/documentation/class_list.html +51 -0
- data/documentation/css/common.css +1 -0
- data/documentation/css/full_list.css +58 -0
- data/documentation/css/style.css +492 -0
- data/documentation/file.README.html +124 -0
- data/documentation/file_list.html +56 -0
- data/documentation/frames.html +17 -0
- data/documentation/index.html +124 -0
- data/documentation/js/app.js +248 -0
- data/documentation/js/full_list.js +216 -0
- data/documentation/js/jquery.js +4 -0
- data/documentation/method_list.html +355 -0
- data/documentation/top-level-namespace.html +110 -0
- data/lib/collection_utils/heap.rb +251 -0
- data/lib/collection_utils/heap_utils/max_heap.rb +12 -12
- data/lib/collection_utils/heap_utils/min_heap.rb +13 -11
- data/lib/collection_utils/queue.rb +21 -0
- data/lib/collection_utils/stack.rb +25 -2
- data/lib/collection_utils/tree_utils/bst.rb +69 -0
- data/lib/collection_utils/tree_utils.rb +5 -0
- data/lib/collection_utils/version.rb +1 -1
- metadata +28 -3
- data/lib/collection_utils/heap_utils/heap.rb +0 -97
@@ -0,0 +1,117 @@
|
|
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
|
+
Module: CollectionUtils::HeapUtils
|
8
|
+
|
9
|
+
— 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::HeapUtils";
|
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 (H)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../CollectionUtils.html" title="CollectionUtils (module)">CollectionUtils</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">HeapUtils</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>Module: CollectionUtils::HeapUtils
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<dl>
|
80
|
+
<dt>Defined in:</dt>
|
81
|
+
<dd>lib/collection_utils/heap_utils.rb<span class="defines">,<br />
|
82
|
+
lib/collection_utils/heap_utils/max_heap.rb,<br /> lib/collection_utils/heap_utils/min_heap.rb</span>
|
83
|
+
</dd>
|
84
|
+
</dl>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
<h2>Defined Under Namespace</h2>
|
89
|
+
<p class="children">
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="HeapUtils/MaxHeap.html" title="CollectionUtils::HeapUtils::MaxHeap (class)">MaxHeap</a></span>, <span class='object_link'><a href="HeapUtils/MinHeap.html" title="CollectionUtils::HeapUtils::MinHeap (class)">MinHeap</a></span>
|
95
|
+
|
96
|
+
|
97
|
+
</p>
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
</div>
|
108
|
+
|
109
|
+
<div id="footer">
|
110
|
+
Generated on Thu Jul 20 01:32:56 2017 by
|
111
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
112
|
+
0.9.9 (ruby-2.0.0).
|
113
|
+
</div>
|
114
|
+
|
115
|
+
</div>
|
116
|
+
</body>
|
117
|
+
</html>
|
@@ -0,0 +1,749 @@
|
|
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::Queue
|
8
|
+
|
9
|
+
— 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::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?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 (Q)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../CollectionUtils.html" title="CollectionUtils (module)">CollectionUtils</a></span></span>
|
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
|
+
<div id="content"><h1>Class: CollectionUtils::Queue
|
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::Queue</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/queue.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="#dequeue-instance_method" title="#dequeue (instance method)">#<strong>dequeue</strong> ⇒ Object </a>
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
</span>
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
<span class="summary_desc"><div class='inline'>
|
135
|
+
<p>Dequeue will remove element from queue and return the value.</p>
|
136
|
+
</div></span>
|
137
|
+
|
138
|
+
</li>
|
139
|
+
|
140
|
+
|
141
|
+
<li class="public ">
|
142
|
+
<span class="summary_signature">
|
143
|
+
|
144
|
+
<a href="#enqueue-instance_method" title="#enqueue (instance method)">#<strong>enqueue</strong>(element) ⇒ Object </a>
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
</span>
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
<span class="summary_desc"><div class='inline'>
|
159
|
+
<p>Enqueue will add an element in queue.</p>
|
160
|
+
</div></span>
|
161
|
+
|
162
|
+
</li>
|
163
|
+
|
164
|
+
|
165
|
+
<li class="public ">
|
166
|
+
<span class="summary_signature">
|
167
|
+
|
168
|
+
<a href="#front-instance_method" title="#front (instance method)">#<strong>front</strong> ⇒ Object </a>
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
</span>
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
<span class="summary_desc"><div class='inline'>
|
183
|
+
<p>Element that has been recently added.</p>
|
184
|
+
</div></span>
|
185
|
+
|
186
|
+
</li>
|
187
|
+
|
188
|
+
|
189
|
+
<li class="public ">
|
190
|
+
<span class="summary_signature">
|
191
|
+
|
192
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(array = []) ⇒ Queue </a>
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
</span>
|
197
|
+
|
198
|
+
|
199
|
+
<span class="note title constructor">constructor</span>
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
<span class="summary_desc"><div class='inline'>
|
209
|
+
<p>Constructors.</p>
|
210
|
+
</div></span>
|
211
|
+
|
212
|
+
</li>
|
213
|
+
|
214
|
+
|
215
|
+
<li class="public ">
|
216
|
+
<span class="summary_signature">
|
217
|
+
|
218
|
+
<a href="#is_empty%3F-instance_method" title="#is_empty? (instance method)">#<strong>is_empty?</strong> ⇒ Boolean </a>
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
</span>
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
<span class="summary_desc"><div class='inline'>
|
233
|
+
<p>Which tells queue's emptiness.</p>
|
234
|
+
</div></span>
|
235
|
+
|
236
|
+
</li>
|
237
|
+
|
238
|
+
|
239
|
+
<li class="public ">
|
240
|
+
<span class="summary_signature">
|
241
|
+
|
242
|
+
<a href="#rear-instance_method" title="#rear (instance method)">#<strong>rear</strong> ⇒ Object </a>
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
</span>
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
<span class="summary_desc"><div class='inline'>
|
257
|
+
<p>Element that will be dequeued next.</p>
|
258
|
+
</div></span>
|
259
|
+
|
260
|
+
</li>
|
261
|
+
|
262
|
+
|
263
|
+
<li class="public ">
|
264
|
+
<span class="summary_signature">
|
265
|
+
|
266
|
+
<a href="#size-instance_method" title="#size (instance method)">#<strong>size</strong> ⇒ Integer </a>
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
</span>
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
<span class="summary_desc"><div class='inline'>
|
281
|
+
<p>Size of queue.</p>
|
282
|
+
</div></span>
|
283
|
+
|
284
|
+
</li>
|
285
|
+
|
286
|
+
|
287
|
+
</ul>
|
288
|
+
|
289
|
+
|
290
|
+
<div id="constructor_details" class="method_details_list">
|
291
|
+
<h2>Constructor Details</h2>
|
292
|
+
|
293
|
+
<div class="method_details first">
|
294
|
+
<h3 class="signature first" id="initialize-instance_method">
|
295
|
+
|
296
|
+
#<strong>initialize</strong>(array = []) ⇒ <tt><span class='object_link'><a href="" title="CollectionUtils::Queue (class)">Queue</a></span></tt>
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
</h3><div class="docstring">
|
303
|
+
<div class="discussion">
|
304
|
+
|
305
|
+
<p>Constructors</p>
|
306
|
+
|
307
|
+
|
308
|
+
</div>
|
309
|
+
</div>
|
310
|
+
<div class="tags">
|
311
|
+
|
312
|
+
|
313
|
+
</div><table class="source_code">
|
314
|
+
<tr>
|
315
|
+
<td>
|
316
|
+
<pre class="lines">
|
317
|
+
|
318
|
+
|
319
|
+
9
|
320
|
+
10
|
321
|
+
11
|
322
|
+
12
|
323
|
+
13
|
324
|
+
14</pre>
|
325
|
+
</td>
|
326
|
+
<td>
|
327
|
+
<pre class="code"><span class="info file"># File 'lib/collection_utils/queue.rb', line 9</span>
|
328
|
+
|
329
|
+
<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>
|
330
|
+
<span class='ivar'>@queue</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
331
|
+
<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>
|
332
|
+
<span class='id identifier rubyid_enqueue'>enqueue</span><span class='lparen'>(</span><span class='id identifier rubyid_element'>element</span><span class='rparen'>)</span>
|
333
|
+
<span class='kw'>end</span>
|
334
|
+
<span class='kw'>end</span></pre>
|
335
|
+
</td>
|
336
|
+
</tr>
|
337
|
+
</table>
|
338
|
+
</div>
|
339
|
+
|
340
|
+
</div>
|
341
|
+
|
342
|
+
|
343
|
+
<div id="instance_method_details" class="method_details_list">
|
344
|
+
<h2>Instance Method Details</h2>
|
345
|
+
|
346
|
+
|
347
|
+
<div class="method_details first">
|
348
|
+
<h3 class="signature first" id="dequeue-instance_method">
|
349
|
+
|
350
|
+
#<strong>dequeue</strong> ⇒ <tt>Object</tt>
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
</h3><div class="docstring">
|
357
|
+
<div class="discussion">
|
358
|
+
|
359
|
+
<p>Dequeue will remove element from queue and return the value</p>
|
360
|
+
|
361
|
+
|
362
|
+
</div>
|
363
|
+
</div>
|
364
|
+
<div class="tags">
|
365
|
+
|
366
|
+
<div class="examples">
|
367
|
+
<p class="tag_title">Examples:</p>
|
368
|
+
|
369
|
+
|
370
|
+
<p class="example_title"><div class='inline'>
|
371
|
+
<p>delete element from queue</p>
|
372
|
+
</div></p>
|
373
|
+
|
374
|
+
<pre class="example code"><code><span class='id identifier rubyid_queue'>queue</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::Queue (class)">Queue</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="CollectionUtils::Queue#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='rparen'>)</span>
|
375
|
+
<span class='id identifier rubyid_queue'>queue</span><span class='period'>.</span><span class='id identifier rubyid_enqueue'>enqueue</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
|
376
|
+
<span class='id identifier rubyid_queue'>queue</span><span class='period'>.</span><span class='id identifier rubyid_enqueue'>enqueue</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>1</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='rbracket'>]</span><span class='rparen'>)</span>
|
377
|
+
<span class='id identifier rubyid_element'>element</span> <span class='op'>=</span> <span class='id identifier rubyid_queue'>queue</span><span class='period'>.</span><span class='id identifier rubyid_dequeue'>dequeue</span> <span class='comment'>#element = 1</span></code></pre>
|
378
|
+
|
379
|
+
</div>
|
380
|
+
|
381
|
+
<p class="tag_title">Returns:</p>
|
382
|
+
<ul class="return">
|
383
|
+
|
384
|
+
<li>
|
385
|
+
|
386
|
+
|
387
|
+
<span class='type'></span>
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
<div class='inline'>
|
393
|
+
<p>element that has been removed</p>
|
394
|
+
</div>
|
395
|
+
|
396
|
+
</li>
|
397
|
+
|
398
|
+
</ul>
|
399
|
+
|
400
|
+
</div><table class="source_code">
|
401
|
+
<tr>
|
402
|
+
<td>
|
403
|
+
<pre class="lines">
|
404
|
+
|
405
|
+
|
406
|
+
38
|
407
|
+
39
|
408
|
+
40
|
409
|
+
41
|
410
|
+
42</pre>
|
411
|
+
</td>
|
412
|
+
<td>
|
413
|
+
<pre class="code"><span class="info file"># File 'lib/collection_utils/queue.rb', line 38</span>
|
414
|
+
|
415
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_dequeue'>dequeue</span>
|
416
|
+
<span class='id identifier rubyid_element'>element</span> <span class='op'>=</span> <span class='ivar'>@queue</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
417
|
+
<span class='ivar'>@queue</span> <span class='op'>=</span> <span class='ivar'>@queue</span><span class='period'>.</span><span class='id identifier rubyid_slice'>slice</span><span class='lparen'>(</span><span class='int'>1</span><span class='op'>..</span><span class='op'>-</span><span class='int'>1</span><span class='rparen'>)</span>
|
418
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_element'>element</span>
|
419
|
+
<span class='kw'>end</span></pre>
|
420
|
+
</td>
|
421
|
+
</tr>
|
422
|
+
</table>
|
423
|
+
</div>
|
424
|
+
|
425
|
+
<div class="method_details ">
|
426
|
+
<h3 class="signature " id="enqueue-instance_method">
|
427
|
+
|
428
|
+
#<strong>enqueue</strong>(element) ⇒ <tt>Object</tt>
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
</h3><div class="docstring">
|
435
|
+
<div class="discussion">
|
436
|
+
|
437
|
+
<p>Enqueue will add an element in queue. The added element can be seen through
|
438
|
+
rear function call</p>
|
439
|
+
|
440
|
+
|
441
|
+
</div>
|
442
|
+
</div>
|
443
|
+
<div class="tags">
|
444
|
+
|
445
|
+
<div class="examples">
|
446
|
+
<p class="tag_title">Examples:</p>
|
447
|
+
|
448
|
+
|
449
|
+
<p class="example_title"><div class='inline'>
|
450
|
+
<p>Add element in queue</p>
|
451
|
+
</div></p>
|
452
|
+
|
453
|
+
<pre class="example code"><code><span class='id identifier rubyid_queue'>queue</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::Queue (class)">Queue</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="CollectionUtils::Queue#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='rparen'>)</span>
|
454
|
+
<span class='id identifier rubyid_queue'>queue</span><span class='period'>.</span><span class='id identifier rubyid_enqueue'>enqueue</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
|
455
|
+
<span class='id identifier rubyid_queue'>queue</span><span class='period'>.</span><span class='id identifier rubyid_enqueue'>enqueue</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>1</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='rbracket'>]</span><span class='rparen'>)</span></code></pre>
|
456
|
+
|
457
|
+
</div>
|
458
|
+
<p class="tag_title">Parameters:</p>
|
459
|
+
<ul class="param">
|
460
|
+
|
461
|
+
<li>
|
462
|
+
|
463
|
+
<span class='name'>element</span>
|
464
|
+
|
465
|
+
|
466
|
+
<span class='type'></span>
|
467
|
+
|
468
|
+
|
469
|
+
|
470
|
+
—
|
471
|
+
<div class='inline'>
|
472
|
+
<p>to be added in queue</p>
|
473
|
+
</div>
|
474
|
+
|
475
|
+
</li>
|
476
|
+
|
477
|
+
</ul>
|
478
|
+
|
479
|
+
|
480
|
+
</div><table class="source_code">
|
481
|
+
<tr>
|
482
|
+
<td>
|
483
|
+
<pre class="lines">
|
484
|
+
|
485
|
+
|
486
|
+
26
|
487
|
+
27
|
488
|
+
28</pre>
|
489
|
+
</td>
|
490
|
+
<td>
|
491
|
+
<pre class="code"><span class="info file"># File 'lib/collection_utils/queue.rb', line 26</span>
|
492
|
+
|
493
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_enqueue'>enqueue</span><span class='lparen'>(</span><span class='id identifier rubyid_element'>element</span><span class='rparen'>)</span>
|
494
|
+
<span class='ivar'>@queue</span> <span class='op'><<</span> <span class='id identifier rubyid_element'>element</span>
|
495
|
+
<span class='kw'>end</span></pre>
|
496
|
+
</td>
|
497
|
+
</tr>
|
498
|
+
</table>
|
499
|
+
</div>
|
500
|
+
|
501
|
+
<div class="method_details ">
|
502
|
+
<h3 class="signature " id="front-instance_method">
|
503
|
+
|
504
|
+
#<strong>front</strong> ⇒ <tt>Object</tt>
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
|
510
|
+
</h3><div class="docstring">
|
511
|
+
<div class="discussion">
|
512
|
+
|
513
|
+
<p>Returns element that has been recently added</p>
|
514
|
+
|
515
|
+
|
516
|
+
</div>
|
517
|
+
</div>
|
518
|
+
<div class="tags">
|
519
|
+
|
520
|
+
<p class="tag_title">Returns:</p>
|
521
|
+
<ul class="return">
|
522
|
+
|
523
|
+
<li>
|
524
|
+
|
525
|
+
|
526
|
+
<span class='type'></span>
|
527
|
+
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
<div class='inline'>
|
532
|
+
<p>element that has been recently added</p>
|
533
|
+
</div>
|
534
|
+
|
535
|
+
</li>
|
536
|
+
|
537
|
+
</ul>
|
538
|
+
|
539
|
+
</div><table class="source_code">
|
540
|
+
<tr>
|
541
|
+
<td>
|
542
|
+
<pre class="lines">
|
543
|
+
|
544
|
+
|
545
|
+
46
|
546
|
+
47
|
547
|
+
48</pre>
|
548
|
+
</td>
|
549
|
+
<td>
|
550
|
+
<pre class="code"><span class="info file"># File 'lib/collection_utils/queue.rb', line 46</span>
|
551
|
+
|
552
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_front'>front</span>
|
553
|
+
<span class='kw'>return</span> <span class='ivar'>@queue</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
554
|
+
<span class='kw'>end</span></pre>
|
555
|
+
</td>
|
556
|
+
</tr>
|
557
|
+
</table>
|
558
|
+
</div>
|
559
|
+
|
560
|
+
<div class="method_details ">
|
561
|
+
<h3 class="signature " id="is_empty?-instance_method">
|
562
|
+
|
563
|
+
#<strong>is_empty?</strong> ⇒ <tt>Boolean</tt>
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
</h3><div class="docstring">
|
570
|
+
<div class="discussion">
|
571
|
+
|
572
|
+
<p>Returns which tells queue's emptiness</p>
|
573
|
+
|
574
|
+
|
575
|
+
</div>
|
576
|
+
</div>
|
577
|
+
<div class="tags">
|
578
|
+
|
579
|
+
<p class="tag_title">Returns:</p>
|
580
|
+
<ul class="return">
|
581
|
+
|
582
|
+
<li>
|
583
|
+
|
584
|
+
|
585
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
—
|
590
|
+
<div class='inline'>
|
591
|
+
<p>which tells queue's emptiness</p>
|
592
|
+
</div>
|
593
|
+
|
594
|
+
</li>
|
595
|
+
|
596
|
+
</ul>
|
597
|
+
|
598
|
+
</div><table class="source_code">
|
599
|
+
<tr>
|
600
|
+
<td>
|
601
|
+
<pre class="lines">
|
602
|
+
|
603
|
+
|
604
|
+
56
|
605
|
+
57
|
606
|
+
58</pre>
|
607
|
+
</td>
|
608
|
+
<td>
|
609
|
+
<pre class="code"><span class="info file"># File 'lib/collection_utils/queue.rb', line 56</span>
|
610
|
+
|
611
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_is_empty?'>is_empty?</span>
|
612
|
+
<span class='kw'>return</span> <span class='ivar'>@queue</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>0</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="rear-instance_method">
|
621
|
+
|
622
|
+
#<strong>rear</strong> ⇒ <tt>Object</tt>
|
623
|
+
|
624
|
+
|
625
|
+
|
626
|
+
|
627
|
+
|
628
|
+
</h3><div class="docstring">
|
629
|
+
<div class="discussion">
|
630
|
+
|
631
|
+
<p>Returns element that will be dequeued next</p>
|
632
|
+
|
633
|
+
|
634
|
+
</div>
|
635
|
+
</div>
|
636
|
+
<div class="tags">
|
637
|
+
|
638
|
+
<p class="tag_title">Returns:</p>
|
639
|
+
<ul class="return">
|
640
|
+
|
641
|
+
<li>
|
642
|
+
|
643
|
+
|
644
|
+
<span class='type'></span>
|
645
|
+
|
646
|
+
|
647
|
+
|
648
|
+
|
649
|
+
<div class='inline'>
|
650
|
+
<p>element that will be dequeued next</p>
|
651
|
+
</div>
|
652
|
+
|
653
|
+
</li>
|
654
|
+
|
655
|
+
</ul>
|
656
|
+
|
657
|
+
</div><table class="source_code">
|
658
|
+
<tr>
|
659
|
+
<td>
|
660
|
+
<pre class="lines">
|
661
|
+
|
662
|
+
|
663
|
+
51
|
664
|
+
52
|
665
|
+
53</pre>
|
666
|
+
</td>
|
667
|
+
<td>
|
668
|
+
<pre class="code"><span class="info file"># File 'lib/collection_utils/queue.rb', line 51</span>
|
669
|
+
|
670
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_rear'>rear</span>
|
671
|
+
<span class='kw'>return</span> <span class='ivar'>@queue</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span>
|
672
|
+
<span class='kw'>end</span></pre>
|
673
|
+
</td>
|
674
|
+
</tr>
|
675
|
+
</table>
|
676
|
+
</div>
|
677
|
+
|
678
|
+
<div class="method_details ">
|
679
|
+
<h3 class="signature " id="size-instance_method">
|
680
|
+
|
681
|
+
#<strong>size</strong> ⇒ <tt>Integer</tt>
|
682
|
+
|
683
|
+
|
684
|
+
|
685
|
+
|
686
|
+
|
687
|
+
</h3><div class="docstring">
|
688
|
+
<div class="discussion">
|
689
|
+
|
690
|
+
<p>Returns size of queue</p>
|
691
|
+
|
692
|
+
|
693
|
+
</div>
|
694
|
+
</div>
|
695
|
+
<div class="tags">
|
696
|
+
|
697
|
+
<p class="tag_title">Returns:</p>
|
698
|
+
<ul class="return">
|
699
|
+
|
700
|
+
<li>
|
701
|
+
|
702
|
+
|
703
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
704
|
+
|
705
|
+
|
706
|
+
|
707
|
+
—
|
708
|
+
<div class='inline'>
|
709
|
+
<p>size of queue</p>
|
710
|
+
</div>
|
711
|
+
|
712
|
+
</li>
|
713
|
+
|
714
|
+
</ul>
|
715
|
+
|
716
|
+
</div><table class="source_code">
|
717
|
+
<tr>
|
718
|
+
<td>
|
719
|
+
<pre class="lines">
|
720
|
+
|
721
|
+
|
722
|
+
61
|
723
|
+
62
|
724
|
+
63</pre>
|
725
|
+
</td>
|
726
|
+
<td>
|
727
|
+
<pre class="code"><span class="info file"># File 'lib/collection_utils/queue.rb', line 61</span>
|
728
|
+
|
729
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_size'>size</span>
|
730
|
+
<span class='kw'>return</span> <span class='ivar'>@queue</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
|
731
|
+
<span class='kw'>end</span></pre>
|
732
|
+
</td>
|
733
|
+
</tr>
|
734
|
+
</table>
|
735
|
+
</div>
|
736
|
+
|
737
|
+
</div>
|
738
|
+
|
739
|
+
</div>
|
740
|
+
|
741
|
+
<div id="footer">
|
742
|
+
Generated on Thu Jul 20 01:32:56 2017 by
|
743
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
744
|
+
0.9.9 (ruby-2.0.0).
|
745
|
+
</div>
|
746
|
+
|
747
|
+
</div>
|
748
|
+
</body>
|
749
|
+
</html>
|