ds 0.0.1
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.
- 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
data/doc/DS/Array2D.html
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
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::Array2D</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/matrixes/array_2d_rb.html?TB_iframe=true&height=550&width=785"
|
|
38
|
+
class="thickbox" title="ds/matrixes/array_2d.rb">ds/matrixes/array_2d.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-5B-5D">#[]</a></li>
|
|
71
|
+
|
|
72
|
+
<li><a href="#method-i-5B-5D-3D">#[]=</a></li>
|
|
73
|
+
|
|
74
|
+
<li><a href="#method-i-to_a">#to_a</a></li>
|
|
75
|
+
|
|
76
|
+
</ul>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<div id="project-metadata">
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
<div id="classindex-section" class="section project-section">
|
|
88
|
+
<h3 class="section-header">Class/Module Index
|
|
89
|
+
<span class="search-toggle"><img src="../images/find.png"
|
|
90
|
+
height="16" width="16" alt="[+]"
|
|
91
|
+
title="show/hide quicksearch" /></span></h3>
|
|
92
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
|
93
|
+
<fieldset>
|
|
94
|
+
<legend>Quicksearch</legend>
|
|
95
|
+
<input type="text" name="quicksearch" value=""
|
|
96
|
+
class="quicksearch-field" />
|
|
97
|
+
</fieldset>
|
|
98
|
+
</form>
|
|
99
|
+
|
|
100
|
+
<ul class="link-list">
|
|
101
|
+
|
|
102
|
+
<li><a href="../DS.html">DS</a></li>
|
|
103
|
+
|
|
104
|
+
<li><a href="../DS/Array2D.html">DS::Array2D</a></li>
|
|
105
|
+
|
|
106
|
+
<li><a href="../DS/BinaryHeap.html">DS::BinaryHeap</a></li>
|
|
107
|
+
|
|
108
|
+
<li><a href="../DS/BinarySearchTree.html">DS::BinarySearchTree</a></li>
|
|
109
|
+
|
|
110
|
+
<li><a href="../DS/BinaryTree.html">DS::BinaryTree</a></li>
|
|
111
|
+
|
|
112
|
+
<li><a href="../DS/CompleteBinaryTree.html">DS::CompleteBinaryTree</a></li>
|
|
113
|
+
|
|
114
|
+
<li><a href="../DS/CyclicList.html">DS::CyclicList</a></li>
|
|
115
|
+
|
|
116
|
+
<li><a href="../DS/Digraph.html">DS::Digraph</a></li>
|
|
117
|
+
|
|
118
|
+
<li><a href="../DS/Edge.html">DS::Edge</a></li>
|
|
119
|
+
|
|
120
|
+
<li><a href="../DS/ExpandableArray.html">DS::ExpandableArray</a></li>
|
|
121
|
+
|
|
122
|
+
<li><a href="../DS/Graph.html">DS::Graph</a></li>
|
|
123
|
+
|
|
124
|
+
<li><a href="../DS/GraphAsList.html">DS::GraphAsList</a></li>
|
|
125
|
+
|
|
126
|
+
<li><a href="../DS/GraphAsMatrix.html">DS::GraphAsMatrix</a></li>
|
|
127
|
+
|
|
128
|
+
<li><a href="../DS/GraphAsTriMatrix.html">DS::GraphAsTriMatrix</a></li>
|
|
129
|
+
|
|
130
|
+
<li><a href="../DS/List.html">DS::List</a></li>
|
|
131
|
+
|
|
132
|
+
<li><a href="../DS/ListElement.html">DS::ListElement</a></li>
|
|
133
|
+
|
|
134
|
+
<li><a href="../DS/Queue.html">DS::Queue</a></li>
|
|
135
|
+
|
|
136
|
+
<li><a href="../DS/Ring.html">DS::Ring</a></li>
|
|
137
|
+
|
|
138
|
+
<li><a href="../DS/Stack.html">DS::Stack</a></li>
|
|
139
|
+
|
|
140
|
+
<li><a href="../DS/Tree.html">DS::Tree</a></li>
|
|
141
|
+
|
|
142
|
+
<li><a href="../DS/TreeWalker.html">DS::TreeWalker</a></li>
|
|
143
|
+
|
|
144
|
+
<li><a href="../DS/TriMatrix.html">DS::TriMatrix</a></li>
|
|
145
|
+
|
|
146
|
+
<li><a href="../Array.html">Array</a></li>
|
|
147
|
+
|
|
148
|
+
</ul>
|
|
149
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
|
150
|
+
</div>
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<div id="documentation">
|
|
157
|
+
<h1 class="class">DS::Array2D</h1>
|
|
158
|
+
|
|
159
|
+
<div id="description" class="description">
|
|
160
|
+
|
|
161
|
+
<p>Implements two dimensional array.</p>
|
|
162
|
+
|
|
163
|
+
</div><!-- description -->
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
<div id="5Buntitled-5D" class="documentation-section">
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
<!-- Methods -->
|
|
178
|
+
|
|
179
|
+
<div id="public-class-method-details" class="method-section section">
|
|
180
|
+
<h3 class="section-header">Public Class Methods</h3>
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
<div id="new-method" class="method-detail ">
|
|
184
|
+
<a name="method-c-new"></a>
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
<div class="method-heading">
|
|
188
|
+
<span class="method-name">new</span><span
|
|
189
|
+
class="method-args">(size=1,init=0)</span>
|
|
190
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
191
|
+
</div>
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
<div class="method-description">
|
|
195
|
+
|
|
196
|
+
<p>Creates new two dimensional array. Init is the default value of the array.</p>
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
<div class="method-source-code" id="new-source">
|
|
201
|
+
<pre>
|
|
202
|
+
<span class="ruby-comment"># File ds/matrixes/array_2d.rb, line 8</span>
|
|
203
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">size</span>=<span class="ruby-value">1</span>,<span class="ruby-identifier">init</span>=<span class="ruby-value">0</span>)
|
|
204
|
+
<span class="ruby-ivar">@init</span> = <span class="ruby-identifier">init</span>
|
|
205
|
+
<span class="ruby-ivar">@store</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">size</span>){<span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">size</span>){<span class="ruby-identifier">init</span>}}
|
|
206
|
+
<span class="ruby-keyword">end</span></pre>
|
|
207
|
+
</div><!-- new-source -->
|
|
208
|
+
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
</div><!-- new-method -->
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
</div><!-- public-class-method-details -->
|
|
218
|
+
|
|
219
|
+
<div id="public-instance-method-details" class="method-section section">
|
|
220
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
<div id="5B-5D-method" class="method-detail ">
|
|
224
|
+
<a name="method-i-5B-5D"></a>
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
<div class="method-heading">
|
|
228
|
+
<span class="method-name">[]</span><span
|
|
229
|
+
class="method-args">(x,y)</span>
|
|
230
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
<div class="method-description">
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
<div class="method-source-code" id="5B-5D-source">
|
|
241
|
+
<pre>
|
|
242
|
+
<span class="ruby-comment"># File ds/matrixes/array_2d.rb, line 14</span>
|
|
243
|
+
<span class="ruby-keyword">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span>)
|
|
244
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@store</span>[<span class="ruby-identifier">x</span>].<span class="ruby-identifier">nil?</span>
|
|
245
|
+
<span class="ruby-ivar">@store</span>[<span class="ruby-identifier">x</span>] = []
|
|
246
|
+
<span class="ruby-ivar">@init</span>
|
|
247
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-ivar">@store</span>[<span class="ruby-identifier">x</span>][<span class="ruby-identifier">y</span>].<span class="ruby-identifier">nil?</span>
|
|
248
|
+
<span class="ruby-ivar">@init</span>
|
|
249
|
+
<span class="ruby-keyword">else</span>
|
|
250
|
+
<span class="ruby-ivar">@store</span>[<span class="ruby-identifier">x</span>][<span class="ruby-identifier">y</span>]
|
|
251
|
+
<span class="ruby-keyword">end</span>
|
|
252
|
+
<span class="ruby-keyword">end</span></pre>
|
|
253
|
+
</div><!-- 5B-5D-source -->
|
|
254
|
+
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
</div><!-- 5B-5D-method -->
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
<div id="5B-5D-3D-method" class="method-detail ">
|
|
264
|
+
<a name="method-i-5B-5D-3D"></a>
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
<div class="method-heading">
|
|
268
|
+
<span class="method-name">[]=</span><span
|
|
269
|
+
class="method-args">(x,y,v)</span>
|
|
270
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
271
|
+
</div>
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
<div class="method-description">
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
<div class="method-source-code" id="5B-5D-3D-source">
|
|
281
|
+
<pre>
|
|
282
|
+
<span class="ruby-comment"># File ds/matrixes/array_2d.rb, line 25</span>
|
|
283
|
+
<span class="ruby-keyword">def</span> <span class="ruby-operator">[]=</span>(<span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span>,<span class="ruby-identifier">v</span>)
|
|
284
|
+
<span class="ruby-ivar">@store</span>[<span class="ruby-identifier">x</span>] = [] <span class="ruby-keyword">if</span> <span class="ruby-ivar">@store</span>[<span class="ruby-identifier">x</span>].<span class="ruby-identifier">nil?</span>
|
|
285
|
+
<span class="ruby-ivar">@store</span>[<span class="ruby-identifier">x</span>][<span class="ruby-identifier">y</span>] = <span class="ruby-identifier">v</span>
|
|
286
|
+
<span class="ruby-keyword">end</span></pre>
|
|
287
|
+
</div><!-- 5B-5D-3D-source -->
|
|
288
|
+
|
|
289
|
+
</div>
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
</div><!-- 5B-5D-3D-method -->
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
<div id="to_a-method" class="method-detail ">
|
|
298
|
+
<a name="method-i-to_a"></a>
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
<div class="method-heading">
|
|
302
|
+
<span class="method-name">to_a</span><span
|
|
303
|
+
class="method-args">()</span>
|
|
304
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
305
|
+
</div>
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
<div class="method-description">
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
<div class="method-source-code" id="to_a-source">
|
|
315
|
+
<pre>
|
|
316
|
+
<span class="ruby-comment"># File ds/matrixes/array_2d.rb, line 30</span>
|
|
317
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">to_a</span>
|
|
318
|
+
<span class="ruby-ivar">@store</span>.<span class="ruby-identifier">flatten</span>
|
|
319
|
+
<span class="ruby-keyword">end</span></pre>
|
|
320
|
+
</div><!-- to_a-source -->
|
|
321
|
+
|
|
322
|
+
</div>
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
</div><!-- to_a-method -->
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
</div><!-- public-instance-method-details -->
|
|
331
|
+
|
|
332
|
+
</div><!-- 5Buntitled-5D -->
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
</div><!-- documentation -->
|
|
336
|
+
|
|
337
|
+
<div id="validator-badges">
|
|
338
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
339
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
|
340
|
+
Rdoc Generator</a> 2</small>.</p>
|
|
341
|
+
</div>
|
|
342
|
+
|
|
343
|
+
</body>
|
|
344
|
+
</html>
|
|
345
|
+
|
|
@@ -0,0 +1,493 @@
|
|
|
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::BinaryHeap</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/binary_heap_rb.html?TB_iframe=true&height=550&width=785"
|
|
38
|
+
class="thickbox" title="ds/trees/binary_heap.rb">ds/trees/binary_heap.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">CompleteBinaryTree</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-heapify">#heapify</a></li>
|
|
71
|
+
|
|
72
|
+
<li><a href="#method-i-heapify-21">#heapify!</a></li>
|
|
73
|
+
|
|
74
|
+
<li><a href="#method-i-insert">#insert</a></li>
|
|
75
|
+
|
|
76
|
+
<li><a href="#method-i-relation">#relation</a></li>
|
|
77
|
+
|
|
78
|
+
<li><a href="#method-i-set_relation">#set_relation</a></li>
|
|
79
|
+
|
|
80
|
+
<li><a href="#method-i-to_a">#to_a</a></li>
|
|
81
|
+
|
|
82
|
+
</ul>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<div id="project-metadata">
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
<div id="classindex-section" class="section project-section">
|
|
94
|
+
<h3 class="section-header">Class/Module Index
|
|
95
|
+
<span class="search-toggle"><img src="../images/find.png"
|
|
96
|
+
height="16" width="16" alt="[+]"
|
|
97
|
+
title="show/hide quicksearch" /></span></h3>
|
|
98
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
|
99
|
+
<fieldset>
|
|
100
|
+
<legend>Quicksearch</legend>
|
|
101
|
+
<input type="text" name="quicksearch" value=""
|
|
102
|
+
class="quicksearch-field" />
|
|
103
|
+
</fieldset>
|
|
104
|
+
</form>
|
|
105
|
+
|
|
106
|
+
<ul class="link-list">
|
|
107
|
+
|
|
108
|
+
<li><a href="../DS.html">DS</a></li>
|
|
109
|
+
|
|
110
|
+
<li><a href="../DS/Array2D.html">DS::Array2D</a></li>
|
|
111
|
+
|
|
112
|
+
<li><a href="../DS/BinaryHeap.html">DS::BinaryHeap</a></li>
|
|
113
|
+
|
|
114
|
+
<li><a href="../DS/BinarySearchTree.html">DS::BinarySearchTree</a></li>
|
|
115
|
+
|
|
116
|
+
<li><a href="../DS/BinaryTree.html">DS::BinaryTree</a></li>
|
|
117
|
+
|
|
118
|
+
<li><a href="../DS/CompleteBinaryTree.html">DS::CompleteBinaryTree</a></li>
|
|
119
|
+
|
|
120
|
+
<li><a href="../DS/CyclicList.html">DS::CyclicList</a></li>
|
|
121
|
+
|
|
122
|
+
<li><a href="../DS/Digraph.html">DS::Digraph</a></li>
|
|
123
|
+
|
|
124
|
+
<li><a href="../DS/Edge.html">DS::Edge</a></li>
|
|
125
|
+
|
|
126
|
+
<li><a href="../DS/ExpandableArray.html">DS::ExpandableArray</a></li>
|
|
127
|
+
|
|
128
|
+
<li><a href="../DS/Graph.html">DS::Graph</a></li>
|
|
129
|
+
|
|
130
|
+
<li><a href="../DS/GraphAsList.html">DS::GraphAsList</a></li>
|
|
131
|
+
|
|
132
|
+
<li><a href="../DS/GraphAsMatrix.html">DS::GraphAsMatrix</a></li>
|
|
133
|
+
|
|
134
|
+
<li><a href="../DS/GraphAsTriMatrix.html">DS::GraphAsTriMatrix</a></li>
|
|
135
|
+
|
|
136
|
+
<li><a href="../DS/List.html">DS::List</a></li>
|
|
137
|
+
|
|
138
|
+
<li><a href="../DS/ListElement.html">DS::ListElement</a></li>
|
|
139
|
+
|
|
140
|
+
<li><a href="../DS/Queue.html">DS::Queue</a></li>
|
|
141
|
+
|
|
142
|
+
<li><a href="../DS/Ring.html">DS::Ring</a></li>
|
|
143
|
+
|
|
144
|
+
<li><a href="../DS/Stack.html">DS::Stack</a></li>
|
|
145
|
+
|
|
146
|
+
<li><a href="../DS/Tree.html">DS::Tree</a></li>
|
|
147
|
+
|
|
148
|
+
<li><a href="../DS/TreeWalker.html">DS::TreeWalker</a></li>
|
|
149
|
+
|
|
150
|
+
<li><a href="../DS/TriMatrix.html">DS::TriMatrix</a></li>
|
|
151
|
+
|
|
152
|
+
<li><a href="../Array.html">Array</a></li>
|
|
153
|
+
|
|
154
|
+
</ul>
|
|
155
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
|
156
|
+
</div>
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
<div id="documentation">
|
|
163
|
+
<h1 class="class">DS::BinaryHeap</h1>
|
|
164
|
+
|
|
165
|
+
<div id="description" class="description">
|
|
166
|
+
|
|
167
|
+
</div><!-- description -->
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
<div id="5Buntitled-5D" class="documentation-section">
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
<!-- Attributes -->
|
|
181
|
+
<div id="attribute-method-details" class="method-section section">
|
|
182
|
+
<h3 class="section-header">Attributes</h3>
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
<div id="data-attribute-method" class="method-detail">
|
|
186
|
+
<a name="data"></a>
|
|
187
|
+
|
|
188
|
+
<a name="data="></a>
|
|
189
|
+
|
|
190
|
+
<div class="method-heading attribute-method-heading">
|
|
191
|
+
<span class="method-name">data</span><span
|
|
192
|
+
class="attribute-access-type">[RW]</span>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<div class="method-description">
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
</div><!-- attribute-method-details -->
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
<!-- Methods -->
|
|
206
|
+
|
|
207
|
+
<div id="public-class-method-details" class="method-section section">
|
|
208
|
+
<h3 class="section-header">Public Class Methods</h3>
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
<div id="new-method" class="method-detail ">
|
|
212
|
+
<a name="method-c-new"></a>
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
<div class="method-heading">
|
|
216
|
+
<span class="method-name">new</span><span
|
|
217
|
+
class="method-args">(*args, &block)</span>
|
|
218
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
219
|
+
</div>
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
<div class="method-description">
|
|
223
|
+
|
|
224
|
+
<p>Create new Heap from args. Given block sets the heap relation. Default heap
|
|
225
|
+
relation is Max Heap.</p>
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
<div class="method-source-code" id="new-source">
|
|
230
|
+
<pre>
|
|
231
|
+
<span class="ruby-comment"># File ds/trees/binary_heap.rb, line 7</span>
|
|
232
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(*<span class="ruby-identifier">args</span>, &<span class="ruby-identifier">block</span>)
|
|
233
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
|
|
234
|
+
<span class="ruby-ivar">@relation</span> = <span class="ruby-identifier">block</span>
|
|
235
|
+
<span class="ruby-keyword">else</span>
|
|
236
|
+
<span class="ruby-ivar">@relation</span> = <span class="ruby-constant">Proc</span>.<span class="ruby-identifier">new</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">parent</span>,<span class="ruby-identifier">child</span><span class="ruby-operator">|</span> <span class="ruby-identifier">parent</span> <span class="ruby-operator">>=</span> <span class="ruby-identifier">child</span>}
|
|
237
|
+
<span class="ruby-keyword">end</span>
|
|
238
|
+
<span class="ruby-ivar">@data</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">to_a</span>
|
|
239
|
+
<span class="ruby-identifier">heapify!</span>
|
|
240
|
+
<span class="ruby-keyword">end</span></pre>
|
|
241
|
+
</div><!-- new-source -->
|
|
242
|
+
|
|
243
|
+
</div>
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
</div><!-- new-method -->
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
</div><!-- public-class-method-details -->
|
|
252
|
+
|
|
253
|
+
<div id="public-instance-method-details" class="method-section section">
|
|
254
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
<div id="heapify-method" class="method-detail ">
|
|
258
|
+
<a name="method-i-heapify"></a>
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
<div class="method-heading">
|
|
262
|
+
<span class="method-name">heapify</span><span
|
|
263
|
+
class="method-args">(i)</span>
|
|
264
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
265
|
+
</div>
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
<div class="method-description">
|
|
269
|
+
|
|
270
|
+
<p>Maintain heap condition for i node. O(log)</p>
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
<div class="method-source-code" id="heapify-source">
|
|
275
|
+
<pre>
|
|
276
|
+
<span class="ruby-comment"># File ds/trees/binary_heap.rb, line 51</span>
|
|
277
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">heapify</span>(<span class="ruby-identifier">i</span>)
|
|
278
|
+
<span class="ruby-identifier">left</span> = <span class="ruby-identifier">left_index</span>(<span class="ruby-identifier">i</span>)
|
|
279
|
+
<span class="ruby-identifier">left</span> = <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">left</span> <span class="ruby-operator">>=</span> <span class="ruby-ivar">@data</span>.<span class="ruby-identifier">size</span>
|
|
280
|
+
|
|
281
|
+
<span class="ruby-identifier">right</span> = <span class="ruby-identifier">right_index</span>(<span class="ruby-identifier">i</span>)
|
|
282
|
+
<span class="ruby-identifier">right</span> = <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">right</span> <span class="ruby-operator">>=</span> <span class="ruby-ivar">@data</span>.<span class="ruby-identifier">size</span>
|
|
283
|
+
|
|
284
|
+
<span class="ruby-identifier">largest</span> = [<span class="ruby-identifier">i</span>,<span class="ruby-identifier">left</span>,<span class="ruby-identifier">right</span>].<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">sort</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span><span class="ruby-operator">|</span> <span class="ruby-identifier">relation</span>(<span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span>)<span class="ruby-operator">?</span><span class="ruby-value">-1</span><span class="ruby-operator">:</span><span class="ruby-value">1</span>}.<span class="ruby-identifier">first</span>
|
|
285
|
+
|
|
286
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">largest</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">i</span>
|
|
287
|
+
<span class="ruby-ivar">@data</span>[<span class="ruby-identifier">i</span>], <span class="ruby-ivar">@data</span>[<span class="ruby-identifier">largest</span>] = <span class="ruby-ivar">@data</span>[<span class="ruby-identifier">largest</span>], <span class="ruby-ivar">@data</span>[<span class="ruby-identifier">i</span>]
|
|
288
|
+
<span class="ruby-identifier">heapify</span>(<span class="ruby-identifier">largest</span>)
|
|
289
|
+
<span class="ruby-keyword">end</span>
|
|
290
|
+
<span class="ruby-keyword">end</span></pre>
|
|
291
|
+
</div><!-- heapify-source -->
|
|
292
|
+
|
|
293
|
+
</div>
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
</div><!-- heapify-method -->
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
<div id="heapify-21-method" class="method-detail ">
|
|
302
|
+
<a name="method-i-heapify-21"></a>
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
<div class="method-heading">
|
|
306
|
+
<span class="method-name">heapify!</span><span
|
|
307
|
+
class="method-args">()</span>
|
|
308
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
309
|
+
</div>
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
<div class="method-description">
|
|
313
|
+
|
|
314
|
+
<p>Arranges data in heap. O(n)</p>
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
<div class="method-source-code" id="heapify-21-source">
|
|
319
|
+
<pre>
|
|
320
|
+
<span class="ruby-comment"># File ds/trees/binary_heap.rb, line 27</span>
|
|
321
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">heapify!</span>
|
|
322
|
+
(<span class="ruby-ivar">@data</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">/</span><span class="ruby-value">2</span>).<span class="ruby-identifier">downto</span>(<span class="ruby-value">0</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
|
323
|
+
<span class="ruby-identifier">heapify</span>(<span class="ruby-identifier">i</span>)
|
|
324
|
+
<span class="ruby-keyword">end</span>
|
|
325
|
+
<span class="ruby-keyword">end</span></pre>
|
|
326
|
+
</div><!-- heapify-21-source -->
|
|
327
|
+
|
|
328
|
+
</div>
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
</div><!-- heapify-21-method -->
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
<div id="insert-method" class="method-detail ">
|
|
337
|
+
<a name="method-i-insert"></a>
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
<div class="method-heading">
|
|
341
|
+
<span class="method-name">insert</span><span
|
|
342
|
+
class="method-args">(value)</span>
|
|
343
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
344
|
+
</div>
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
<div class="method-description">
|
|
348
|
+
|
|
349
|
+
<p>Inserts new value to heap maintaining the heap relation. Returns heap
|
|
350
|
+
itself. O(log)</p>
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
<div class="method-source-code" id="insert-source">
|
|
355
|
+
<pre>
|
|
356
|
+
<span class="ruby-comment"># File ds/trees/binary_heap.rb, line 36</span>
|
|
357
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">insert</span>(<span class="ruby-identifier">value</span>)
|
|
358
|
+
<span class="ruby-ivar">@data</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">value</span>
|
|
359
|
+
<span class="ruby-identifier">child</span> = <span class="ruby-ivar">@data</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>
|
|
360
|
+
<span class="ruby-identifier">parent</span> = <span class="ruby-identifier">parent_index</span>(<span class="ruby-identifier">child</span>)
|
|
361
|
+
|
|
362
|
+
<span class="ruby-keyword">while</span> <span class="ruby-identifier">parent</span> <span class="ruby-operator">>=</span> <span class="ruby-value">0</span> <span class="ruby-keyword">and</span> <span class="ruby-operator">!</span><span class="ruby-identifier">relation</span>(<span class="ruby-identifier">parent</span>,<span class="ruby-identifier">child</span>)
|
|
363
|
+
<span class="ruby-ivar">@data</span>[<span class="ruby-identifier">child</span>], <span class="ruby-ivar">@data</span>[<span class="ruby-identifier">parent</span>] = <span class="ruby-ivar">@data</span>[<span class="ruby-identifier">parent</span>], <span class="ruby-ivar">@data</span>[<span class="ruby-identifier">child</span>]
|
|
364
|
+
<span class="ruby-identifier">child</span> = <span class="ruby-identifier">parent</span>
|
|
365
|
+
<span class="ruby-identifier">parent</span> = <span class="ruby-identifier">parent_index</span>(<span class="ruby-identifier">child</span>)
|
|
366
|
+
<span class="ruby-keyword">end</span>
|
|
367
|
+
<span class="ruby-keyword">self</span>
|
|
368
|
+
<span class="ruby-keyword">end</span></pre>
|
|
369
|
+
</div><!-- insert-source -->
|
|
370
|
+
|
|
371
|
+
</div>
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
</div><!-- insert-method -->
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
<div id="relation-method" class="method-detail ">
|
|
380
|
+
<a name="method-i-relation"></a>
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
<div class="method-heading">
|
|
384
|
+
<span class="method-name">relation</span><span
|
|
385
|
+
class="method-args">(parent,child)</span>
|
|
386
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
387
|
+
</div>
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
<div class="method-description">
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
<div class="method-source-code" id="relation-source">
|
|
397
|
+
<pre>
|
|
398
|
+
<span class="ruby-comment"># File ds/trees/binary_heap.rb, line 21</span>
|
|
399
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">relation</span>(<span class="ruby-identifier">parent</span>,<span class="ruby-identifier">child</span>)
|
|
400
|
+
<span class="ruby-ivar">@relation</span>.<span class="ruby-identifier">call</span>(<span class="ruby-ivar">@data</span>[<span class="ruby-identifier">parent</span>],<span class="ruby-ivar">@data</span>[<span class="ruby-identifier">child</span>])
|
|
401
|
+
<span class="ruby-keyword">end</span></pre>
|
|
402
|
+
</div><!-- relation-source -->
|
|
403
|
+
|
|
404
|
+
</div>
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
</div><!-- relation-method -->
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
<div id="set_relation-method" class="method-detail ">
|
|
413
|
+
<a name="method-i-set_relation"></a>
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
<div class="method-heading">
|
|
417
|
+
<span class="method-name">set_relation</span><span
|
|
418
|
+
class="method-args">(&relation)</span>
|
|
419
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
420
|
+
</div>
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
<div class="method-description">
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
<div class="method-source-code" id="set_relation-source">
|
|
430
|
+
<pre>
|
|
431
|
+
<span class="ruby-comment"># File ds/trees/binary_heap.rb, line 17</span>
|
|
432
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">set_relation</span>(&<span class="ruby-identifier">relation</span>)
|
|
433
|
+
<span class="ruby-ivar">@relation</span> = <span class="ruby-identifier">relation</span>
|
|
434
|
+
<span class="ruby-keyword">end</span></pre>
|
|
435
|
+
</div><!-- set_relation-source -->
|
|
436
|
+
|
|
437
|
+
</div>
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
</div><!-- set_relation-method -->
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
<div id="to_a-method" class="method-detail ">
|
|
446
|
+
<a name="method-i-to_a"></a>
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
<div class="method-heading">
|
|
450
|
+
<span class="method-name">to_a</span><span
|
|
451
|
+
class="method-args">()</span>
|
|
452
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
453
|
+
</div>
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
<div class="method-description">
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
<div class="method-source-code" id="to_a-source">
|
|
463
|
+
<pre>
|
|
464
|
+
<span class="ruby-comment"># File ds/trees/binary_heap.rb, line 66</span>
|
|
465
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">to_a</span>
|
|
466
|
+
<span class="ruby-ivar">@data</span>
|
|
467
|
+
<span class="ruby-keyword">end</span></pre>
|
|
468
|
+
</div><!-- to_a-source -->
|
|
469
|
+
|
|
470
|
+
</div>
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
</div><!-- to_a-method -->
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
</div><!-- public-instance-method-details -->
|
|
479
|
+
|
|
480
|
+
</div><!-- 5Buntitled-5D -->
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
</div><!-- documentation -->
|
|
484
|
+
|
|
485
|
+
<div id="validator-badges">
|
|
486
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
487
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
|
488
|
+
Rdoc Generator</a> 2</small>.</p>
|
|
489
|
+
</div>
|
|
490
|
+
|
|
491
|
+
</body>
|
|
492
|
+
</html>
|
|
493
|
+
|