rrlist 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/Gemfile +5 -0
- data/README.md +158 -0
- data/Rakefile +1 -0
- data/doc/RRArchive.html +555 -0
- data/doc/RRComposite.html +639 -0
- data/doc/RRList/Functions.html +675 -0
- data/doc/RRList/List.html +2277 -0
- data/doc/RRList/Stores.html +115 -0
- data/doc/RRList/Stores/InMemoryArray.html +609 -0
- data/doc/RRListStore.html +115 -0
- data/doc/RRListStore/InMemoryArray.html +580 -0
- data/doc/RRMath.html +634 -0
- data/doc/RRlist.html +131 -0
- data/doc/_index.html +170 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +338 -0
- data/doc/file.README.html +227 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +227 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +268 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/rrlist.rb +3 -0
- data/lib/rrlist/functions.rb +80 -0
- data/lib/rrlist/list.rb +212 -0
- data/lib/rrlist/stores.rb +45 -0
- data/lib/rrlist/version.rb +3 -0
- data/rrlist.gemspec +27 -0
- data/spec/lib/rrlist/functions_spec.rb +19 -0
- data/spec/lib/rrlist/list_spec.rb +416 -0
- data/spec/spec_helper.rb +36 -0
- metadata +167 -0
@@ -0,0 +1,227 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII" />
|
6
|
+
<title>
|
7
|
+
File: README
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.6.1
|
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
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '';
|
20
|
+
framesUrl = "frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="_index.html">Index</a> »
|
35
|
+
<span class="title">File: README</span>
|
36
|
+
|
37
|
+
|
38
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search">
|
42
|
+
|
43
|
+
<a class="full_list_link" id="class_list_link"
|
44
|
+
href="class_list.html">
|
45
|
+
Class List
|
46
|
+
</a>
|
47
|
+
|
48
|
+
<a class="full_list_link" id="method_list_link"
|
49
|
+
href="method_list.html">
|
50
|
+
Method List
|
51
|
+
</a>
|
52
|
+
|
53
|
+
<a class="full_list_link" id="file_list_link"
|
54
|
+
href="file_list.html">
|
55
|
+
File List
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<iframe id="search_frame"></iframe>
|
63
|
+
|
64
|
+
<div id="content"><div id='filecontents'><h1>WORK IN PROGRESS (ready soon)</h1>
|
65
|
+
|
66
|
+
<h1>RRList</h1>
|
67
|
+
|
68
|
+
<p>Inspired by <code>RRDTool</code></p>
|
69
|
+
|
70
|
+
<p>Basically, you can add elements to a list, but the sizes remains constant over time.</p>
|
71
|
+
|
72
|
+
<p>If you add an element to to the list that is out of the range, moves the cursor forward and items at the lower indexes are lost.</p>
|
73
|
+
|
74
|
+
<p>For example with a list of size 5:</p>
|
75
|
+
|
76
|
+
<pre class="code ruby"><code class="ruby"><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span><span class='int'>2</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='int'>5</span><span class='rbracket'>]</span>
|
77
|
+
<span class='id identifier rubyid_add'>add</span> <span class='int'>6</span>
|
78
|
+
<span class='lbracket'>[</span><span class='int'>2</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='int'>5</span><span class='comma'>,</span><span class='int'>6</span><span class='rbracket'>]</span>
|
79
|
+
<span class='id identifier rubyid_add'>add</span> <span class='int'>7</span>
|
80
|
+
<span class='lbracket'>[</span><span class='int'>3</span><span class='comma'>,</span><span class='int'>4</span><span class='comma'>,</span><span class='int'>5</span><span class='comma'>,</span><span class='int'>6</span><span class='comma'>,</span><span class='int'>7</span><span class='rbracket'>]</span>
|
81
|
+
<span class='id identifier rubyid_add'>add</span> <span class='int'>20</span>
|
82
|
+
<span class='lbracket'>[</span><span class='kw'>nil</span><span class='comma'>,</span><span class='kw'>nil</span><span class='comma'>,</span><span class='kw'>nil</span><span class='comma'>,</span><span class='kw'>nil</span><span class='comma'>,</span><span class='int'>20</span><span class='rbracket'>]</span>
|
83
|
+
</code></pre>
|
84
|
+
|
85
|
+
<h1>Install</h1>
|
86
|
+
|
87
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_install'>install</span> <span class='id identifier rubyid_rrlist'>rrlist</span>
|
88
|
+
</code></pre>
|
89
|
+
|
90
|
+
<p>or</p>
|
91
|
+
|
92
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>rrlist</span><span class='tstring_end'>'</span></span>
|
93
|
+
</code></pre>
|
94
|
+
|
95
|
+
<p>or</p>
|
96
|
+
|
97
|
+
<pre class="code ruby"><code class="ruby">git clone ...
|
98
|
+
rake install
|
99
|
+
</code></pre>
|
100
|
+
|
101
|
+
<h1>Usage</h1>
|
102
|
+
|
103
|
+
<pre class="code ruby"><code class="ruby"> <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>rrlist</span><span class='tstring_end'>'</span></span>
|
104
|
+
</code></pre>
|
105
|
+
|
106
|
+
<p><em>Basic manipulation</em></p>
|
107
|
+
|
108
|
+
<pre class="code ruby"><code class="ruby"> <span class='id identifier rubyid_rrlist'>rrlist</span> <span class='op'>=</span> <span class='const'>RRList</span><span class='op'>::</span><span class='const'>List</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='symbol'>:size</span> <span class='op'>=></span> <span class='int'>10</span>
|
109
|
+
|
110
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
|
111
|
+
</span>
|
112
|
+
<span class='int'>1</span><span class='period'>.</span><span class='id identifier rubyid_upto'>upto</span><span class='lparen'>(</span><span class='int'>100</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
113
|
+
|
114
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
|
115
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 91
|
116
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 100
|
117
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='int'>93</span><span class='rparen'>)</span> <span class='comment'>#=> 93
|
118
|
+
</span>
|
119
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='int'>101</span><span class='rparen'>)</span>
|
120
|
+
|
121
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [92, 93, 94, 95, 96, 97, 98, 99, 100, 101]
|
122
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 92
|
123
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 101
|
124
|
+
</span>
|
125
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>any object</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
126
|
+
|
127
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [93, 94, 95, 96, 97, 98, 99, 100, 101, "any object"]
|
128
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 93
|
129
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 102
|
130
|
+
</span>
|
131
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>105</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>A</span><span class='tstring_end'>"</span></span>
|
132
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [96, 97, 98, 99, 100, 101, "any object", nil, nil, "A"]
|
133
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 96
|
134
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_max_index'>max_index</span> <span class='comment'>#=> 105
|
135
|
+
</span>
|
136
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>2000</span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>B</span><span class='tstring_end'>"</span></span>
|
137
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>105</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>A</span><span class='tstring_end'>"</span></span>
|
138
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [nil, nil, nil, nil, nil, nil, nil, nil, nil, "B"]
|
139
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 1991
|
140
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_max_index'>max_index</span> <span class='comment'>#=> 2000
|
141
|
+
</span></code></pre>
|
142
|
+
|
143
|
+
<p><em>Looping</em></p>
|
144
|
+
|
145
|
+
<pre class="code ruby"><code class="ruby"> rrlist = RRList::List.new :size => 10
|
146
|
+
|
147
|
+
1.upto(100) { |n| rrlist.add(n) }
|
148
|
+
|
149
|
+
rrlist.each { |value| ... }
|
150
|
+
rrlist.each_with_index { |value,index| puts "#{value} #{index}" }
|
151
|
+
# => 91 91
|
152
|
+
# => 92 92
|
153
|
+
....
|
154
|
+
</code></pre>
|
155
|
+
|
156
|
+
<p><em>Ranges</em></p>
|
157
|
+
|
158
|
+
<p>A range of indexs grouped in the same position.
|
159
|
+
For a renge of 3 for indexes 0,1,2 the value goes in position 1</p>
|
160
|
+
|
161
|
+
<pre class="code ruby"><code class="ruby"> <span class='id identifier rubyid_rrlist'>rrlist</span> <span class='op'>=</span> <span class='const'>RRList</span><span class='op'>::</span><span class='const'>List</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='symbol'>:size</span> <span class='op'>=></span> <span class='int'>10</span><span class='comma'>,</span> <span class='symbol'>:range</span> <span class='op'>=></span> <span class='int'>3</span>
|
162
|
+
|
163
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>0</span><span class='comma'>,</span> <span class='int'>0</span>
|
164
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [0, nil, nil, nil, nil, nil, nil, nil, nil, nil]
|
165
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>1</span><span class='comma'>,</span> <span class='int'>1</span>
|
166
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [1, nil, nil, nil, nil, nil, nil, nil, nil, nil]
|
167
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>2</span><span class='comma'>,</span> <span class='int'>2</span>
|
168
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [2, nil, nil, nil, nil, nil, nil, nil, nil, nil]
|
169
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>3</span><span class='comma'>,</span> <span class='int'>3</span>
|
170
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [2, 3, nil, nil, nil, nil, nil, nil, nil, nil]
|
171
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>4</span><span class='comma'>,</span> <span class='int'>4</span>
|
172
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [2, 4, nil, nil, nil, nil, nil, nil, nil, nil]
|
173
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>5</span><span class='comma'>,</span> <span class='int'>5</span>
|
174
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [2, 5, nil, nil, nil, nil, nil, nil, nil, nil]
|
175
|
+
</span>
|
176
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span> <span class='op'>=</span> <span class='const'>RRList</span><span class='op'>::</span><span class='const'>List</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='symbol'>:size</span> <span class='op'>=></span> <span class='int'>10</span><span class='comma'>,</span> <span class='symbol'>:range</span> <span class='op'>=></span> <span class='int'>5</span>
|
177
|
+
|
178
|
+
<span class='int'>0</span><span class='period'>.</span><span class='id identifier rubyid_upto'>upto</span><span class='lparen'>(</span><span class='int'>100</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
179
|
+
|
180
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [59, 64, 69, 74, 79, 84, 89, 94, 99, 100]
|
181
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 55
|
182
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_max_index'>max_index</span> <span class='comment'>#=> 100
|
183
|
+
</span></code></pre>
|
184
|
+
|
185
|
+
<p><em>Functions</em></p>
|
186
|
+
|
187
|
+
<p>To sum all the values added to a range</p>
|
188
|
+
|
189
|
+
<pre class="code ruby"><code class="ruby"> <span class='id identifier rubyid_rrlist'>rrlist</span> <span class='op'>=</span> <span class='const'>RRList</span><span class='op'>::</span><span class='const'>List</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='symbol'>:size</span> <span class='op'>=></span> <span class='int'>10</span><span class='comma'>,</span> <span class='symbol'>:range</span> <span class='op'>=></span> <span class='int'>5</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_index'>index</span><span class='comma'>,</span> <span class='id identifier rubyid_old_value'>old_value</span><span class='comma'>,</span> <span class='id identifier rubyid_new_value'>new_value</span><span class='op'>|</span>
|
190
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_old_value'>old_value</span><span class='op'>||</span><span class='int'>0</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='id identifier rubyid_new_value'>new_value</span>
|
191
|
+
<span class='kw'>end</span>
|
192
|
+
|
193
|
+
<span class='int'>0</span><span class='period'>.</span><span class='id identifier rubyid_upto'>upto</span><span class='lparen'>(</span><span class='int'>100</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
194
|
+
|
195
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [285, 310, 335, 360, 385, 410, 435, 460, 485, 100]
|
196
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 55
|
197
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_max_index'>max_index</span> <span class='comment'>#=> 100
|
198
|
+
</span></code></pre>
|
199
|
+
|
200
|
+
<p><em>Array API</em></p>
|
201
|
+
|
202
|
+
<pre class="code ruby"><code class="ruby"> <span class='id identifier rubyid_rrlist'>rrlist</span> <span class='op'>=</span> <span class='const'>RRList</span><span class='op'>::</span><span class='const'>List</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='symbol'>:size</span> <span class='op'>=></span> <span class='int'>10</span>
|
203
|
+
|
204
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
|
205
|
+
</span>
|
206
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>a</span><span class='tstring_end'>"</span></span>
|
207
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [nil, "a", nil, nil, nil, nil, nil, nil, nil, nil]
|
208
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='comment'>#=> "a"
|
209
|
+
</span>
|
210
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>b</span><span class='tstring_end'>"</span></span>
|
211
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [nil, "a", "b", nil, nil, nil, nil, nil, nil, nil]
|
212
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> <span class='comment'>#=> "b"
|
213
|
+
</span>
|
214
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>c</span><span class='tstring_end'>"</span></span>
|
215
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [nil, "a", "b", "c", nil, nil, nil, nil, nil, nil]
|
216
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='lbracket'>[</span><span class='int'>3</span><span class='rbracket'>]</span> <span class='comment'>#=> "c"
|
217
|
+
</span></code></pre>
|
218
|
+
</div></div>
|
219
|
+
|
220
|
+
<div id="footer">
|
221
|
+
Generated on Fri May 31 08:53:01 2013 by
|
222
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
223
|
+
0.8.6.1 (ruby-1.9.2).
|
224
|
+
</div>
|
225
|
+
|
226
|
+
</body>
|
227
|
+
</html>
|
data/doc/file_list.html
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
|
7
|
+
<link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
|
9
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
16
|
+
|
17
|
+
|
18
|
+
<base id="base_target" target="_parent" />
|
19
|
+
</head>
|
20
|
+
<body>
|
21
|
+
<script type="text/javascript" charset="utf-8">
|
22
|
+
if (window.top.frames.main) {
|
23
|
+
document.getElementById('base_target').target = 'main';
|
24
|
+
document.body.className = 'frames';
|
25
|
+
}
|
26
|
+
</script>
|
27
|
+
<div id="content">
|
28
|
+
<h1 id="full_list_header">File List</h1>
|
29
|
+
<div id="nav">
|
30
|
+
|
31
|
+
<span><a target="_self" href="class_list.html">
|
32
|
+
Classes
|
33
|
+
</a></span>
|
34
|
+
|
35
|
+
<span><a target="_self" href="method_list.html">
|
36
|
+
Methods
|
37
|
+
</a></span>
|
38
|
+
|
39
|
+
<span><a target="_self" href="file_list.html">
|
40
|
+
Files
|
41
|
+
</a></span>
|
42
|
+
|
43
|
+
</div>
|
44
|
+
<div id="search">Search: <input type="text" /></div>
|
45
|
+
|
46
|
+
<ul id="full_list" class="file">
|
47
|
+
|
48
|
+
|
49
|
+
<li class="r1"><span class="object_link"><a href="index.html" title="README">README</a></a></li>
|
50
|
+
|
51
|
+
|
52
|
+
</ul>
|
53
|
+
</div>
|
54
|
+
</body>
|
55
|
+
</html>
|
data/doc/frames.html
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
7
|
+
<title>Documentation by YARD 0.8.6.1</title>
|
8
|
+
</head>
|
9
|
+
<script type="text/javascript" charset="utf-8">
|
10
|
+
window.onload = function() {
|
11
|
+
var match = window.location.hash.match(/^#!(.+)/);
|
12
|
+
var name = 'index.html';
|
13
|
+
if (match) {
|
14
|
+
name = unescape(match[1]);
|
15
|
+
}
|
16
|
+
document.writeln('<frameset cols="20%,*">' +
|
17
|
+
'<frame name="list" src="class_list.html" />' +
|
18
|
+
'<frame name="main" src="' + name + '" />' +
|
19
|
+
'</frameset>');
|
20
|
+
}
|
21
|
+
</script>
|
22
|
+
<noscript>
|
23
|
+
<frameset cols="20%,*">
|
24
|
+
<frame name="list" src="class_list.html" />
|
25
|
+
<frame name="main" src="index.html" />
|
26
|
+
</frameset>
|
27
|
+
</noscript>
|
28
|
+
</html>
|
data/doc/index.html
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII" />
|
6
|
+
<title>
|
7
|
+
File: README
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.6.1
|
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
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '';
|
20
|
+
framesUrl = "frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="_index.html">Index</a> »
|
35
|
+
<span class="title">File: README</span>
|
36
|
+
|
37
|
+
|
38
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search">
|
42
|
+
|
43
|
+
<a class="full_list_link" id="class_list_link"
|
44
|
+
href="class_list.html">
|
45
|
+
Class List
|
46
|
+
</a>
|
47
|
+
|
48
|
+
<a class="full_list_link" id="method_list_link"
|
49
|
+
href="method_list.html">
|
50
|
+
Method List
|
51
|
+
</a>
|
52
|
+
|
53
|
+
<a class="full_list_link" id="file_list_link"
|
54
|
+
href="file_list.html">
|
55
|
+
File List
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<iframe id="search_frame"></iframe>
|
63
|
+
|
64
|
+
<div id="content"><div id='filecontents'><h1>WORK IN PROGRESS (ready soon)</h1>
|
65
|
+
|
66
|
+
<h1>RRList</h1>
|
67
|
+
|
68
|
+
<p>Inspired by <code>RRDTool</code></p>
|
69
|
+
|
70
|
+
<p>Basically, you can add elements to a list, but the sizes remains constant over time.</p>
|
71
|
+
|
72
|
+
<p>If you add an element to to the list that is out of the range, moves the cursor forward and items at the lower indexes are lost.</p>
|
73
|
+
|
74
|
+
<p>For example with a list of size 5:</p>
|
75
|
+
|
76
|
+
<pre class="code ruby"><code class="ruby"><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span><span class='int'>2</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='int'>5</span><span class='rbracket'>]</span>
|
77
|
+
<span class='id identifier rubyid_add'>add</span> <span class='int'>6</span>
|
78
|
+
<span class='lbracket'>[</span><span class='int'>2</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='int'>5</span><span class='comma'>,</span><span class='int'>6</span><span class='rbracket'>]</span>
|
79
|
+
<span class='id identifier rubyid_add'>add</span> <span class='int'>7</span>
|
80
|
+
<span class='lbracket'>[</span><span class='int'>3</span><span class='comma'>,</span><span class='int'>4</span><span class='comma'>,</span><span class='int'>5</span><span class='comma'>,</span><span class='int'>6</span><span class='comma'>,</span><span class='int'>7</span><span class='rbracket'>]</span>
|
81
|
+
<span class='id identifier rubyid_add'>add</span> <span class='int'>20</span>
|
82
|
+
<span class='lbracket'>[</span><span class='kw'>nil</span><span class='comma'>,</span><span class='kw'>nil</span><span class='comma'>,</span><span class='kw'>nil</span><span class='comma'>,</span><span class='kw'>nil</span><span class='comma'>,</span><span class='int'>20</span><span class='rbracket'>]</span>
|
83
|
+
</code></pre>
|
84
|
+
|
85
|
+
<h1>Install</h1>
|
86
|
+
|
87
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_install'>install</span> <span class='id identifier rubyid_rrlist'>rrlist</span>
|
88
|
+
</code></pre>
|
89
|
+
|
90
|
+
<p>or</p>
|
91
|
+
|
92
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>rrlist</span><span class='tstring_end'>'</span></span>
|
93
|
+
</code></pre>
|
94
|
+
|
95
|
+
<p>or</p>
|
96
|
+
|
97
|
+
<pre class="code ruby"><code class="ruby">git clone ...
|
98
|
+
rake install
|
99
|
+
</code></pre>
|
100
|
+
|
101
|
+
<h1>Usage</h1>
|
102
|
+
|
103
|
+
<pre class="code ruby"><code class="ruby"> <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>rrlist</span><span class='tstring_end'>'</span></span>
|
104
|
+
</code></pre>
|
105
|
+
|
106
|
+
<p><em>Basic manipulation</em></p>
|
107
|
+
|
108
|
+
<pre class="code ruby"><code class="ruby"> <span class='id identifier rubyid_rrlist'>rrlist</span> <span class='op'>=</span> <span class='const'>RRList</span><span class='op'>::</span><span class='const'>List</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='symbol'>:size</span> <span class='op'>=></span> <span class='int'>10</span>
|
109
|
+
|
110
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
|
111
|
+
</span>
|
112
|
+
<span class='int'>1</span><span class='period'>.</span><span class='id identifier rubyid_upto'>upto</span><span class='lparen'>(</span><span class='int'>100</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
113
|
+
|
114
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
|
115
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 91
|
116
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 100
|
117
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='int'>93</span><span class='rparen'>)</span> <span class='comment'>#=> 93
|
118
|
+
</span>
|
119
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='int'>101</span><span class='rparen'>)</span>
|
120
|
+
|
121
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [92, 93, 94, 95, 96, 97, 98, 99, 100, 101]
|
122
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 92
|
123
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 101
|
124
|
+
</span>
|
125
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>any object</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
126
|
+
|
127
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [93, 94, 95, 96, 97, 98, 99, 100, 101, "any object"]
|
128
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 93
|
129
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 102
|
130
|
+
</span>
|
131
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>105</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>A</span><span class='tstring_end'>"</span></span>
|
132
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [96, 97, 98, 99, 100, 101, "any object", nil, nil, "A"]
|
133
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 96
|
134
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_max_index'>max_index</span> <span class='comment'>#=> 105
|
135
|
+
</span>
|
136
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>2000</span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>B</span><span class='tstring_end'>"</span></span>
|
137
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>105</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>A</span><span class='tstring_end'>"</span></span>
|
138
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [nil, nil, nil, nil, nil, nil, nil, nil, nil, "B"]
|
139
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 1991
|
140
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_max_index'>max_index</span> <span class='comment'>#=> 2000
|
141
|
+
</span></code></pre>
|
142
|
+
|
143
|
+
<p><em>Looping</em></p>
|
144
|
+
|
145
|
+
<pre class="code ruby"><code class="ruby"> rrlist = RRList::List.new :size => 10
|
146
|
+
|
147
|
+
1.upto(100) { |n| rrlist.add(n) }
|
148
|
+
|
149
|
+
rrlist.each { |value| ... }
|
150
|
+
rrlist.each_with_index { |value,index| puts "#{value} #{index}" }
|
151
|
+
# => 91 91
|
152
|
+
# => 92 92
|
153
|
+
....
|
154
|
+
</code></pre>
|
155
|
+
|
156
|
+
<p><em>Ranges</em></p>
|
157
|
+
|
158
|
+
<p>A range of indexs grouped in the same position.
|
159
|
+
For a renge of 3 for indexes 0,1,2 the value goes in position 1</p>
|
160
|
+
|
161
|
+
<pre class="code ruby"><code class="ruby"> <span class='id identifier rubyid_rrlist'>rrlist</span> <span class='op'>=</span> <span class='const'>RRList</span><span class='op'>::</span><span class='const'>List</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='symbol'>:size</span> <span class='op'>=></span> <span class='int'>10</span><span class='comma'>,</span> <span class='symbol'>:range</span> <span class='op'>=></span> <span class='int'>3</span>
|
162
|
+
|
163
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>0</span><span class='comma'>,</span> <span class='int'>0</span>
|
164
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [0, nil, nil, nil, nil, nil, nil, nil, nil, nil]
|
165
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>1</span><span class='comma'>,</span> <span class='int'>1</span>
|
166
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [1, nil, nil, nil, nil, nil, nil, nil, nil, nil]
|
167
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>2</span><span class='comma'>,</span> <span class='int'>2</span>
|
168
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [2, nil, nil, nil, nil, nil, nil, nil, nil, nil]
|
169
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>3</span><span class='comma'>,</span> <span class='int'>3</span>
|
170
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [2, 3, nil, nil, nil, nil, nil, nil, nil, nil]
|
171
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>4</span><span class='comma'>,</span> <span class='int'>4</span>
|
172
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [2, 4, nil, nil, nil, nil, nil, nil, nil, nil]
|
173
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add_at'>add_at</span> <span class='int'>5</span><span class='comma'>,</span> <span class='int'>5</span>
|
174
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [2, 5, nil, nil, nil, nil, nil, nil, nil, nil]
|
175
|
+
</span>
|
176
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span> <span class='op'>=</span> <span class='const'>RRList</span><span class='op'>::</span><span class='const'>List</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='symbol'>:size</span> <span class='op'>=></span> <span class='int'>10</span><span class='comma'>,</span> <span class='symbol'>:range</span> <span class='op'>=></span> <span class='int'>5</span>
|
177
|
+
|
178
|
+
<span class='int'>0</span><span class='period'>.</span><span class='id identifier rubyid_upto'>upto</span><span class='lparen'>(</span><span class='int'>100</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
179
|
+
|
180
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [59, 64, 69, 74, 79, 84, 89, 94, 99, 100]
|
181
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 55
|
182
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_max_index'>max_index</span> <span class='comment'>#=> 100
|
183
|
+
</span></code></pre>
|
184
|
+
|
185
|
+
<p><em>Functions</em></p>
|
186
|
+
|
187
|
+
<p>To sum all the values added to a range</p>
|
188
|
+
|
189
|
+
<pre class="code ruby"><code class="ruby"> <span class='id identifier rubyid_rrlist'>rrlist</span> <span class='op'>=</span> <span class='const'>RRList</span><span class='op'>::</span><span class='const'>List</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='symbol'>:size</span> <span class='op'>=></span> <span class='int'>10</span><span class='comma'>,</span> <span class='symbol'>:range</span> <span class='op'>=></span> <span class='int'>5</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_index'>index</span><span class='comma'>,</span> <span class='id identifier rubyid_old_value'>old_value</span><span class='comma'>,</span> <span class='id identifier rubyid_new_value'>new_value</span><span class='op'>|</span>
|
190
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_old_value'>old_value</span><span class='op'>||</span><span class='int'>0</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='id identifier rubyid_new_value'>new_value</span>
|
191
|
+
<span class='kw'>end</span>
|
192
|
+
|
193
|
+
<span class='int'>0</span><span class='period'>.</span><span class='id identifier rubyid_upto'>upto</span><span class='lparen'>(</span><span class='int'>100</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
194
|
+
|
195
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [285, 310, 335, 360, 385, 410, 435, 460, 485, 100]
|
196
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_min_index'>min_index</span> <span class='comment'>#=> 55
|
197
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_max_index'>max_index</span> <span class='comment'>#=> 100
|
198
|
+
</span></code></pre>
|
199
|
+
|
200
|
+
<p><em>Array API</em></p>
|
201
|
+
|
202
|
+
<pre class="code ruby"><code class="ruby"> <span class='id identifier rubyid_rrlist'>rrlist</span> <span class='op'>=</span> <span class='const'>RRList</span><span class='op'>::</span><span class='const'>List</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='symbol'>:size</span> <span class='op'>=></span> <span class='int'>10</span>
|
203
|
+
|
204
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
|
205
|
+
</span>
|
206
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>a</span><span class='tstring_end'>"</span></span>
|
207
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [nil, "a", nil, nil, nil, nil, nil, nil, nil, nil]
|
208
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='comment'>#=> "a"
|
209
|
+
</span>
|
210
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>b</span><span class='tstring_end'>"</span></span>
|
211
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [nil, "a", "b", nil, nil, nil, nil, nil, nil, nil]
|
212
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> <span class='comment'>#=> "b"
|
213
|
+
</span>
|
214
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>c</span><span class='tstring_end'>"</span></span>
|
215
|
+
<span class='id identifier rubyid_rrlist'>rrlist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span> <span class='comment'>#=> [nil, "a", "b", "c", nil, nil, nil, nil, nil, nil]
|
216
|
+
</span> <span class='id identifier rubyid_rrlist'>rrlist</span><span class='lbracket'>[</span><span class='int'>3</span><span class='rbracket'>]</span> <span class='comment'>#=> "c"
|
217
|
+
</span></code></pre>
|
218
|
+
</div></div>
|
219
|
+
|
220
|
+
<div id="footer">
|
221
|
+
Generated on Fri May 31 08:53:01 2013 by
|
222
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
223
|
+
0.8.6.1 (ruby-1.9.2).
|
224
|
+
</div>
|
225
|
+
|
226
|
+
</body>
|
227
|
+
</html>
|