ds 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +13 -0
- data/doc/Array.html +264 -0
- data/doc/DS.html +292 -0
- data/doc/DS/Array2D.html +345 -0
- data/doc/DS/BinaryHeap.html +493 -0
- data/doc/DS/BinarySearchTree.html +313 -0
- data/doc/DS/BinaryTree.html +433 -0
- data/doc/DS/CompleteBinaryTree.html +550 -0
- data/doc/DS/CyclicList.html +234 -0
- data/doc/DS/Digraph.html +299 -0
- data/doc/DS/Edge.html +283 -0
- data/doc/DS/ExpandableArray.html +316 -0
- data/doc/DS/Graph.html +739 -0
- data/doc/DS/GraphAsList.html +361 -0
- data/doc/DS/GraphAsMatrix.html +633 -0
- data/doc/DS/GraphAsTriMatrix.html +274 -0
- data/doc/DS/List.html +1263 -0
- data/doc/DS/ListElement.html +344 -0
- data/doc/DS/Queue.html +517 -0
- data/doc/DS/Ring.html +323 -0
- data/doc/DS/Stack.html +407 -0
- data/doc/DS/Tree.html +770 -0
- data/doc/DS/TreeWalker.html +561 -0
- data/doc/DS/TriMatrix.html +338 -0
- data/doc/created.rid +25 -0
- data/doc/ds/graphs/digraph_rb.html +52 -0
- data/doc/ds/graphs/edge_rb.html +52 -0
- data/doc/ds/graphs/graph_as_list_rb.html +52 -0
- data/doc/ds/graphs/graph_as_matrix_rb.html +52 -0
- data/doc/ds/graphs/graph_as_tri_matrix_rb.html +52 -0
- data/doc/ds/graphs/graph_rb.html +52 -0
- data/doc/ds/lists/cyclic_list_rb.html +52 -0
- data/doc/ds/lists/list_element_rb.html +52 -0
- data/doc/ds/lists/list_rb.html +52 -0
- data/doc/ds/lists/ring_rb.html +52 -0
- data/doc/ds/matrixes/array_2d_rb.html +52 -0
- data/doc/ds/matrixes/expandable_array_rb.html +52 -0
- data/doc/ds/matrixes/tri_matrix_rb.html +52 -0
- data/doc/ds/queues/queue_rb.html +52 -0
- data/doc/ds/stacks/stack_rb.html +52 -0
- data/doc/ds/trees/binary_heap_rb.html +52 -0
- data/doc/ds/trees/binary_search_tree_rb.html +52 -0
- data/doc/ds/trees/binary_tree_rb.html +52 -0
- data/doc/ds/trees/complete_binary_tree_rb.html +52 -0
- data/doc/ds/trees/tree_rb.html +52 -0
- data/doc/ds/trees/tree_walker_rb.html +52 -0
- data/doc/ds/version_rb.html +52 -0
- data/doc/ds_rb.html +98 -0
- data/doc/ext/ext_rb.html +52 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +375 -0
- data/doc/js/darkfish.js +116 -0
- data/doc/js/jquery.js +32 -0
- data/doc/js/quicksearch.js +114 -0
- data/doc/js/thickbox-compressed.js +10 -0
- data/doc/rdoc.css +763 -0
- data/ds.gemspec +20 -0
- data/lib/ds.rb +38 -0
- data/lib/ds/graphs/digraph.rb +20 -0
- data/lib/ds/graphs/edge.rb +15 -0
- data/lib/ds/graphs/graph.rb +107 -0
- data/lib/ds/graphs/graph_as_list.rb +48 -0
- data/lib/ds/graphs/graph_as_matrix.rb +114 -0
- data/lib/ds/graphs/graph_as_tri_matrix.rb +25 -0
- data/lib/ds/lists/cyclic_list.rb +21 -0
- data/lib/ds/lists/list.rb +303 -0
- data/lib/ds/lists/list_element.rb +26 -0
- data/lib/ds/lists/ring.rb +42 -0
- data/lib/ds/matrixes/array_2d.rb +35 -0
- data/lib/ds/matrixes/expandable_array.rb +37 -0
- data/lib/ds/matrixes/tri_matrix.rb +30 -0
- data/lib/ds/queues/queue.rb +53 -0
- data/lib/ds/stacks/stack.rb +39 -0
- data/lib/ds/trees/binary_heap.rb +71 -0
- data/lib/ds/trees/binary_search_tree.rb +32 -0
- data/lib/ds/trees/binary_tree.rb +65 -0
- data/lib/ds/trees/complete_binary_tree.rb +52 -0
- data/lib/ds/trees/tree.rb +117 -0
- data/lib/ds/trees/tree_walker.rb +179 -0
- data/lib/ds/version.rb +3 -0
- data/lib/ext/ext.rb +15 -0
- data/test/help.rb +8 -0
- data/test/test_array2d.rb +51 -0
- data/test/test_binary_heap.rb +35 -0
- data/test/test_binary_search_tree.rb +32 -0
- data/test/test_binary_tree.rb +51 -0
- data/test/test_complete_binary_tree.rb +30 -0
- data/test/test_digraph.rb +134 -0
- data/test/test_expandable_array.rb +26 -0
- data/test/test_graph.rb +71 -0
- data/test/test_list.rb +138 -0
- data/test/test_list_element.rb +56 -0
- data/test/test_queue.rb +110 -0
- data/test/test_ring.rb +28 -0
- data/test/test_stack.rb +87 -0
- data/test/test_tree.rb +48 -0
- data/test/test_tree_walker.rb +69 -0
- data/test/test_tri_matrix.rb +22 -0
- metadata +184 -0
@@ -0,0 +1,550 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Class: DS::CompleteBinaryTree</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body id="top" class="class">
|
19
|
+
|
20
|
+
<div id="metadata">
|
21
|
+
<div id="home-metadata">
|
22
|
+
<div id="home-section" class="section">
|
23
|
+
<h3 class="section-header">
|
24
|
+
<a href="../index.html">Home</a>
|
25
|
+
<a href="../index.html#classes">Classes</a>
|
26
|
+
<a href="../index.html#methods">Methods</a>
|
27
|
+
</h3>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div id="file-metadata">
|
32
|
+
<div id="file-list-section" class="section">
|
33
|
+
<h3 class="section-header">In Files</h3>
|
34
|
+
<div class="section-body">
|
35
|
+
<ul>
|
36
|
+
|
37
|
+
<li><a href="../ds/trees/complete_binary_tree_rb.html?TB_iframe=true&height=550&width=785"
|
38
|
+
class="thickbox" title="ds/trees/complete_binary_tree.rb">ds/trees/complete_binary_tree.rb</a></li>
|
39
|
+
|
40
|
+
</ul>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div id="class-metadata">
|
48
|
+
|
49
|
+
<!-- Parent Class -->
|
50
|
+
<div id="parent-class-section" class="section">
|
51
|
+
<h3 class="section-header">Parent</h3>
|
52
|
+
|
53
|
+
<p class="link">Object</p>
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Method Quickref -->
|
64
|
+
<div id="method-list-section" class="section">
|
65
|
+
<h3 class="section-header">Methods</h3>
|
66
|
+
<ul class="link-list">
|
67
|
+
|
68
|
+
<li><a href="#method-c-new">::new</a></li>
|
69
|
+
|
70
|
+
<li><a href="#method-i-3C-3C">#<<</a></li>
|
71
|
+
|
72
|
+
<li><a href="#method-i-children">#children</a></li>
|
73
|
+
|
74
|
+
<li><a href="#method-i-left">#left</a></li>
|
75
|
+
|
76
|
+
<li><a href="#method-i-left_index">#left_index</a></li>
|
77
|
+
|
78
|
+
<li><a href="#method-i-parent">#parent</a></li>
|
79
|
+
|
80
|
+
<li><a href="#method-i-parent_index">#parent_index</a></li>
|
81
|
+
|
82
|
+
<li><a href="#method-i-right">#right</a></li>
|
83
|
+
|
84
|
+
<li><a href="#method-i-right_index">#right_index</a></li>
|
85
|
+
|
86
|
+
<li><a href="#method-i-root">#root</a></li>
|
87
|
+
|
88
|
+
</ul>
|
89
|
+
</div>
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
<div id="project-metadata">
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<div id="classindex-section" class="section project-section">
|
100
|
+
<h3 class="section-header">Class/Module Index
|
101
|
+
<span class="search-toggle"><img src="../images/find.png"
|
102
|
+
height="16" width="16" alt="[+]"
|
103
|
+
title="show/hide quicksearch" /></span></h3>
|
104
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
105
|
+
<fieldset>
|
106
|
+
<legend>Quicksearch</legend>
|
107
|
+
<input type="text" name="quicksearch" value=""
|
108
|
+
class="quicksearch-field" />
|
109
|
+
</fieldset>
|
110
|
+
</form>
|
111
|
+
|
112
|
+
<ul class="link-list">
|
113
|
+
|
114
|
+
<li><a href="../DS.html">DS</a></li>
|
115
|
+
|
116
|
+
<li><a href="../DS/Array2D.html">DS::Array2D</a></li>
|
117
|
+
|
118
|
+
<li><a href="../DS/BinaryHeap.html">DS::BinaryHeap</a></li>
|
119
|
+
|
120
|
+
<li><a href="../DS/BinarySearchTree.html">DS::BinarySearchTree</a></li>
|
121
|
+
|
122
|
+
<li><a href="../DS/BinaryTree.html">DS::BinaryTree</a></li>
|
123
|
+
|
124
|
+
<li><a href="../DS/CompleteBinaryTree.html">DS::CompleteBinaryTree</a></li>
|
125
|
+
|
126
|
+
<li><a href="../DS/CyclicList.html">DS::CyclicList</a></li>
|
127
|
+
|
128
|
+
<li><a href="../DS/Digraph.html">DS::Digraph</a></li>
|
129
|
+
|
130
|
+
<li><a href="../DS/Edge.html">DS::Edge</a></li>
|
131
|
+
|
132
|
+
<li><a href="../DS/ExpandableArray.html">DS::ExpandableArray</a></li>
|
133
|
+
|
134
|
+
<li><a href="../DS/Graph.html">DS::Graph</a></li>
|
135
|
+
|
136
|
+
<li><a href="../DS/GraphAsList.html">DS::GraphAsList</a></li>
|
137
|
+
|
138
|
+
<li><a href="../DS/GraphAsMatrix.html">DS::GraphAsMatrix</a></li>
|
139
|
+
|
140
|
+
<li><a href="../DS/GraphAsTriMatrix.html">DS::GraphAsTriMatrix</a></li>
|
141
|
+
|
142
|
+
<li><a href="../DS/List.html">DS::List</a></li>
|
143
|
+
|
144
|
+
<li><a href="../DS/ListElement.html">DS::ListElement</a></li>
|
145
|
+
|
146
|
+
<li><a href="../DS/Queue.html">DS::Queue</a></li>
|
147
|
+
|
148
|
+
<li><a href="../DS/Ring.html">DS::Ring</a></li>
|
149
|
+
|
150
|
+
<li><a href="../DS/Stack.html">DS::Stack</a></li>
|
151
|
+
|
152
|
+
<li><a href="../DS/Tree.html">DS::Tree</a></li>
|
153
|
+
|
154
|
+
<li><a href="../DS/TreeWalker.html">DS::TreeWalker</a></li>
|
155
|
+
|
156
|
+
<li><a href="../DS/TriMatrix.html">DS::TriMatrix</a></li>
|
157
|
+
|
158
|
+
<li><a href="../Array.html">Array</a></li>
|
159
|
+
|
160
|
+
</ul>
|
161
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
162
|
+
</div>
|
163
|
+
|
164
|
+
|
165
|
+
</div>
|
166
|
+
</div>
|
167
|
+
|
168
|
+
<div id="documentation">
|
169
|
+
<h1 class="class">DS::CompleteBinaryTree</h1>
|
170
|
+
|
171
|
+
<div id="description" class="description">
|
172
|
+
|
173
|
+
</div><!-- description -->
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
<div id="5Buntitled-5D" class="documentation-section">
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
<!-- Methods -->
|
188
|
+
|
189
|
+
<div id="public-class-method-details" class="method-section section">
|
190
|
+
<h3 class="section-header">Public Class Methods</h3>
|
191
|
+
|
192
|
+
|
193
|
+
<div id="new-method" class="method-detail ">
|
194
|
+
<a name="method-c-new"></a>
|
195
|
+
|
196
|
+
|
197
|
+
<div class="method-heading">
|
198
|
+
<span class="method-name">new</span><span
|
199
|
+
class="method-args">(*args)</span>
|
200
|
+
<span class="method-click-advice">click to toggle source</span>
|
201
|
+
</div>
|
202
|
+
|
203
|
+
|
204
|
+
<div class="method-description">
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
<div class="method-source-code" id="new-source">
|
211
|
+
<pre>
|
212
|
+
<span class="ruby-comment"># File ds/trees/complete_binary_tree.rb, line 4</span>
|
213
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(*<span class="ruby-identifier">args</span>)
|
214
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
|
215
|
+
<span class="ruby-ivar">@data</span> = []
|
216
|
+
<span class="ruby-keyword">else</span>
|
217
|
+
<span class="ruby-ivar">@data</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">to_a</span>
|
218
|
+
<span class="ruby-keyword">end</span>
|
219
|
+
<span class="ruby-keyword">end</span></pre>
|
220
|
+
</div><!-- new-source -->
|
221
|
+
|
222
|
+
</div>
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
</div><!-- new-method -->
|
228
|
+
|
229
|
+
|
230
|
+
</div><!-- public-class-method-details -->
|
231
|
+
|
232
|
+
<div id="public-instance-method-details" class="method-section section">
|
233
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
234
|
+
|
235
|
+
|
236
|
+
<div id="3C-3C-method" class="method-detail ">
|
237
|
+
<a name="method-i-3C-3C"></a>
|
238
|
+
|
239
|
+
|
240
|
+
<div class="method-heading">
|
241
|
+
<span class="method-name"><<</span><span
|
242
|
+
class="method-args">(value)</span>
|
243
|
+
<span class="method-click-advice">click to toggle source</span>
|
244
|
+
</div>
|
245
|
+
|
246
|
+
|
247
|
+
<div class="method-description">
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
<div class="method-source-code" id="3C-3C-source">
|
254
|
+
<pre>
|
255
|
+
<span class="ruby-comment"># File ds/trees/complete_binary_tree.rb, line 12</span>
|
256
|
+
<span class="ruby-keyword">def</span> <span class="ruby-operator"><<</span> (<span class="ruby-identifier">value</span>)
|
257
|
+
<span class="ruby-ivar">@data</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">value</span>
|
258
|
+
<span class="ruby-keyword">end</span></pre>
|
259
|
+
</div><!-- 3C-3C-source -->
|
260
|
+
|
261
|
+
</div>
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
</div><!-- 3C-3C-method -->
|
267
|
+
|
268
|
+
|
269
|
+
<div id="children-method" class="method-detail ">
|
270
|
+
<a name="method-i-children"></a>
|
271
|
+
|
272
|
+
|
273
|
+
<div class="method-heading">
|
274
|
+
<span class="method-name">children</span><span
|
275
|
+
class="method-args">(value)</span>
|
276
|
+
<span class="method-click-advice">click to toggle source</span>
|
277
|
+
</div>
|
278
|
+
|
279
|
+
|
280
|
+
<div class="method-description">
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
<div class="method-source-code" id="children-source">
|
287
|
+
<pre>
|
288
|
+
<span class="ruby-comment"># File ds/trees/complete_binary_tree.rb, line 20</span>
|
289
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">children</span>(<span class="ruby-identifier">value</span>)
|
290
|
+
<span class="ruby-identifier">i</span> = <span class="ruby-ivar">@data</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">value</span>)
|
291
|
+
<span class="ruby-keyword">return</span> [<span class="ruby-ivar">@data</span>[<span class="ruby-value">2</span>*<span class="ruby-identifier">i</span><span class="ruby-operator">+</span><span class="ruby-value">1</span>], <span class="ruby-ivar">@data</span>[<span class="ruby-value">2</span>*<span class="ruby-identifier">i</span><span class="ruby-operator">+</span><span class="ruby-value">2</span>]]
|
292
|
+
<span class="ruby-keyword">end</span></pre>
|
293
|
+
</div><!-- children-source -->
|
294
|
+
|
295
|
+
</div>
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
</div><!-- children-method -->
|
301
|
+
|
302
|
+
|
303
|
+
<div id="left-method" class="method-detail ">
|
304
|
+
<a name="method-i-left"></a>
|
305
|
+
|
306
|
+
|
307
|
+
<div class="method-heading">
|
308
|
+
<span class="method-name">left</span><span
|
309
|
+
class="method-args">(value)</span>
|
310
|
+
<span class="method-click-advice">click to toggle source</span>
|
311
|
+
</div>
|
312
|
+
|
313
|
+
|
314
|
+
<div class="method-description">
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
<div class="method-source-code" id="left-source">
|
321
|
+
<pre>
|
322
|
+
<span class="ruby-comment"># File ds/trees/complete_binary_tree.rb, line 29</span>
|
323
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">left</span> <span class="ruby-identifier">value</span>
|
324
|
+
<span class="ruby-identifier">children</span>(<span class="ruby-identifier">value</span>).<span class="ruby-identifier">first</span>
|
325
|
+
<span class="ruby-keyword">end</span></pre>
|
326
|
+
</div><!-- left-source -->
|
327
|
+
|
328
|
+
</div>
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
</div><!-- left-method -->
|
334
|
+
|
335
|
+
|
336
|
+
<div id="left_index-method" class="method-detail ">
|
337
|
+
<a name="method-i-left_index"></a>
|
338
|
+
|
339
|
+
|
340
|
+
<div class="method-heading">
|
341
|
+
<span class="method-name">left_index</span><span
|
342
|
+
class="method-args">(i)</span>
|
343
|
+
<span class="method-click-advice">click to toggle source</span>
|
344
|
+
</div>
|
345
|
+
|
346
|
+
|
347
|
+
<div class="method-description">
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
<div class="method-source-code" id="left_index-source">
|
354
|
+
<pre>
|
355
|
+
<span class="ruby-comment"># File ds/trees/complete_binary_tree.rb, line 33</span>
|
356
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">left_index</span>(<span class="ruby-identifier">i</span>)
|
357
|
+
<span class="ruby-value">2</span>*<span class="ruby-identifier">i</span><span class="ruby-operator">+</span><span class="ruby-value">1</span>
|
358
|
+
<span class="ruby-keyword">end</span></pre>
|
359
|
+
</div><!-- left_index-source -->
|
360
|
+
|
361
|
+
</div>
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
</div><!-- left_index-method -->
|
367
|
+
|
368
|
+
|
369
|
+
<div id="parent-method" class="method-detail ">
|
370
|
+
<a name="method-i-parent"></a>
|
371
|
+
|
372
|
+
|
373
|
+
<div class="method-heading">
|
374
|
+
<span class="method-name">parent</span><span
|
375
|
+
class="method-args">(value)</span>
|
376
|
+
<span class="method-click-advice">click to toggle source</span>
|
377
|
+
</div>
|
378
|
+
|
379
|
+
|
380
|
+
<div class="method-description">
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
<div class="method-source-code" id="parent-source">
|
387
|
+
<pre>
|
388
|
+
<span class="ruby-comment"># File ds/trees/complete_binary_tree.rb, line 45</span>
|
389
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parent</span> <span class="ruby-identifier">value</span>
|
390
|
+
<span class="ruby-identifier">i</span> = <span class="ruby-ivar">@data</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">value</span>)
|
391
|
+
<span class="ruby-ivar">@data</span>[<span class="ruby-identifier">parent_index</span>(<span class="ruby-identifier">i</span>)]
|
392
|
+
<span class="ruby-keyword">end</span></pre>
|
393
|
+
</div><!-- parent-source -->
|
394
|
+
|
395
|
+
</div>
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
</div><!-- parent-method -->
|
401
|
+
|
402
|
+
|
403
|
+
<div id="parent_index-method" class="method-detail ">
|
404
|
+
<a name="method-i-parent_index"></a>
|
405
|
+
|
406
|
+
|
407
|
+
<div class="method-heading">
|
408
|
+
<span class="method-name">parent_index</span><span
|
409
|
+
class="method-args">(i)</span>
|
410
|
+
<span class="method-click-advice">click to toggle source</span>
|
411
|
+
</div>
|
412
|
+
|
413
|
+
|
414
|
+
<div class="method-description">
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
<div class="method-source-code" id="parent_index-source">
|
421
|
+
<pre>
|
422
|
+
<span class="ruby-comment"># File ds/trees/complete_binary_tree.rb, line 41</span>
|
423
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parent_index</span>(<span class="ruby-identifier">i</span>)
|
424
|
+
(<span class="ruby-identifier">i</span><span class="ruby-operator">+</span><span class="ruby-value">1</span>)<span class="ruby-operator">/</span><span class="ruby-value">2</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
|
425
|
+
<span class="ruby-keyword">end</span></pre>
|
426
|
+
</div><!-- parent_index-source -->
|
427
|
+
|
428
|
+
</div>
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
</div><!-- parent_index-method -->
|
434
|
+
|
435
|
+
|
436
|
+
<div id="right-method" class="method-detail ">
|
437
|
+
<a name="method-i-right"></a>
|
438
|
+
|
439
|
+
|
440
|
+
<div class="method-heading">
|
441
|
+
<span class="method-name">right</span><span
|
442
|
+
class="method-args">(value)</span>
|
443
|
+
<span class="method-click-advice">click to toggle source</span>
|
444
|
+
</div>
|
445
|
+
|
446
|
+
|
447
|
+
<div class="method-description">
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
<div class="method-source-code" id="right-source">
|
454
|
+
<pre>
|
455
|
+
<span class="ruby-comment"># File ds/trees/complete_binary_tree.rb, line 25</span>
|
456
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">right</span> <span class="ruby-identifier">value</span>
|
457
|
+
<span class="ruby-identifier">children</span>(<span class="ruby-identifier">value</span>)[<span class="ruby-value">1</span>]
|
458
|
+
<span class="ruby-keyword">end</span></pre>
|
459
|
+
</div><!-- right-source -->
|
460
|
+
|
461
|
+
</div>
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
</div><!-- right-method -->
|
467
|
+
|
468
|
+
|
469
|
+
<div id="right_index-method" class="method-detail ">
|
470
|
+
<a name="method-i-right_index"></a>
|
471
|
+
|
472
|
+
|
473
|
+
<div class="method-heading">
|
474
|
+
<span class="method-name">right_index</span><span
|
475
|
+
class="method-args">(i)</span>
|
476
|
+
<span class="method-click-advice">click to toggle source</span>
|
477
|
+
</div>
|
478
|
+
|
479
|
+
|
480
|
+
<div class="method-description">
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
<div class="method-source-code" id="right_index-source">
|
487
|
+
<pre>
|
488
|
+
<span class="ruby-comment"># File ds/trees/complete_binary_tree.rb, line 37</span>
|
489
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">right_index</span>(<span class="ruby-identifier">i</span>)
|
490
|
+
<span class="ruby-value">2</span>*<span class="ruby-identifier">i</span><span class="ruby-operator">+</span><span class="ruby-value">2</span>
|
491
|
+
<span class="ruby-keyword">end</span></pre>
|
492
|
+
</div><!-- right_index-source -->
|
493
|
+
|
494
|
+
</div>
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
</div><!-- right_index-method -->
|
500
|
+
|
501
|
+
|
502
|
+
<div id="root-method" class="method-detail ">
|
503
|
+
<a name="method-i-root"></a>
|
504
|
+
|
505
|
+
|
506
|
+
<div class="method-heading">
|
507
|
+
<span class="method-name">root</span><span
|
508
|
+
class="method-args">()</span>
|
509
|
+
<span class="method-click-advice">click to toggle source</span>
|
510
|
+
</div>
|
511
|
+
|
512
|
+
|
513
|
+
<div class="method-description">
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
<div class="method-source-code" id="root-source">
|
520
|
+
<pre>
|
521
|
+
<span class="ruby-comment"># File ds/trees/complete_binary_tree.rb, line 16</span>
|
522
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">root</span>
|
523
|
+
<span class="ruby-ivar">@data</span>.<span class="ruby-identifier">first</span>
|
524
|
+
<span class="ruby-keyword">end</span></pre>
|
525
|
+
</div><!-- root-source -->
|
526
|
+
|
527
|
+
</div>
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
|
532
|
+
</div><!-- root-method -->
|
533
|
+
|
534
|
+
|
535
|
+
</div><!-- public-instance-method-details -->
|
536
|
+
|
537
|
+
</div><!-- 5Buntitled-5D -->
|
538
|
+
|
539
|
+
|
540
|
+
</div><!-- documentation -->
|
541
|
+
|
542
|
+
<div id="validator-badges">
|
543
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
544
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
545
|
+
Rdoc Generator</a> 2</small>.</p>
|
546
|
+
</div>
|
547
|
+
|
548
|
+
</body>
|
549
|
+
</html>
|
550
|
+
|