critbit 0.5.0-java → 0.5.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/config.rb +39 -108
- data/doc/Critbit.html +3351 -0
- data/doc/Critbit/Cursor.html +360 -0
- data/doc/Critbit/DeleteCursor.html +294 -0
- data/doc/Critbit/EachCursor.html +228 -0
- data/doc/Critbit/EachKeyCursor.html +228 -0
- data/doc/Critbit/EachValueCursor.html +228 -0
- data/doc/Critbit/ListCursor.html +456 -0
- data/doc/_index.html +176 -0
- data/doc/class_list.html +58 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/file.README.html +250 -0
- data/doc/file_list.html +60 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +250 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +181 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +345 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/critbit.rb +1 -3
- data/test/test_critbit.rb +3 -4
- data/version.rb +1 -1
- metadata +30 -23
- data/lib/env.rb +0 -12
- data/test/crit.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3c55d8346f867a66a561830841d6981f48364f9
|
4
|
+
data.tar.gz: 641c93eac5c62e17b50302de17f333820d080333
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1439dcc31bcf9388651a081827e44ee14880f854516e722dfbebd83f6cc23da88ebec14c0360bae3c729037d6bba99a8f9c00af7ef70b9da2416d826d21d066
|
7
|
+
data.tar.gz: a59fd51d4921e304590c5a53dd16621d8dbb533313e89ca9f07c6e9287be1a7df14060a4a5699e4b4f27744f3569266bfa58e95b3b1f229351d006725ece00d6
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Announcement
|
2
2
|
============
|
3
3
|
|
4
|
-
Critbit version 0.5 has been realeased. A crit bit tree, also known as a Binary Patricia
|
4
|
+
Critbit version 0.5.1 has been realeased. A crit bit tree, also known as a Binary Patricia
|
5
5
|
Trie is a trie (https://en.wikipedia.org/wiki/Trie), also called digital tree and sometimes
|
6
6
|
radix tree or prefix tree (as they
|
7
7
|
can be searched by prefixes), is an ordered tree data structure that is used to store a
|
@@ -133,6 +133,7 @@ Critbit installation and download:
|
|
133
133
|
==================================
|
134
134
|
|
135
135
|
+ Install Jruby
|
136
|
+
+ bundle install or manually with
|
136
137
|
+ jruby –S gem install critbit
|
137
138
|
|
138
139
|
Critbit Homepages:
|
@@ -149,5 +150,6 @@ Contributors are welcome.
|
|
149
150
|
Critbit History:
|
150
151
|
================
|
151
152
|
|
152
|
-
+
|
153
|
+
+ 30/12/2015: Version 0.5.1 - Tested with jruby 9.0.4, added bundler for development
|
154
|
+
+ 22/07/2015: Version 0.5.0 – Initial release.
|
153
155
|
|
data/config.rb
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
require 'rbconfig'
|
2
|
-
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
# $VENDOR_DEPEND=[]
|
2
|
+
require 'java'
|
3
|
+
|
4
|
+
#
|
5
|
+
# In principle should not be in this file. The right way of doing this is by executing
|
6
|
+
# bundler exec, but I don't know how to do this from inside emacs. So, should comment
|
7
|
+
# the next line before publishing the GEM. If not commented, this should be harmless
|
8
|
+
# anyway.
|
9
|
+
#
|
10
|
+
|
11
|
+
begin
|
12
|
+
require 'bundler/setup'
|
13
|
+
rescue LoadError
|
14
|
+
end
|
16
15
|
|
17
16
|
##########################################################################################
|
18
17
|
|
@@ -33,53 +32,11 @@ require 'rbconfig'
|
|
33
32
|
else 'default'
|
34
33
|
end
|
35
34
|
|
36
|
-
#---------------------------------------------------------------------------------------
|
37
|
-
# Add path to load path
|
38
|
-
#---------------------------------------------------------------------------------------
|
39
|
-
|
40
|
-
def mklib(path, home_path = true)
|
41
|
-
|
42
|
-
if (home_path)
|
43
|
-
lib = path + "/lib"
|
44
|
-
else
|
45
|
-
lib = path
|
46
|
-
end
|
47
|
-
|
48
|
-
$LOAD_PATH.insert(0, lib)
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
##########################################################################################
|
53
|
-
# Prepare environment to work inside Cygwin
|
54
|
-
##########################################################################################
|
55
|
-
|
56
|
-
if @platform == 'windows-cygwin'
|
57
|
-
|
58
|
-
#---------------------------------------------------------------------------------------
|
59
|
-
# Return the cygpath of a path
|
60
|
-
#---------------------------------------------------------------------------------------
|
61
|
-
|
62
|
-
def set_path(path)
|
63
|
-
`cygpath -a -p -m #{path}`.tr("\n", "")
|
64
|
-
end
|
65
|
-
|
66
|
-
else
|
67
|
-
|
68
|
-
#---------------------------------------------------------------------------------------
|
69
|
-
# Return the path
|
70
|
-
#---------------------------------------------------------------------------------------
|
71
|
-
|
72
|
-
def set_path(path)
|
73
|
-
path
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
35
|
#---------------------------------------------------------------------------------------
|
79
36
|
# Set the project directories
|
80
37
|
#---------------------------------------------------------------------------------------
|
81
38
|
|
82
|
-
class
|
39
|
+
class Critbit
|
83
40
|
|
84
41
|
@home_dir = File.expand_path File.dirname(__FILE__)
|
85
42
|
|
@@ -87,13 +44,13 @@ class CritbitRB
|
|
87
44
|
attr_reader :home_dir
|
88
45
|
end
|
89
46
|
|
90
|
-
@project_dir =
|
91
|
-
@doc_dir =
|
92
|
-
@lib_dir =
|
93
|
-
@src_dir =
|
94
|
-
@target_dir =
|
95
|
-
@test_dir =
|
96
|
-
@vendor_dir =
|
47
|
+
@project_dir = Critbit.home_dir + "/.."
|
48
|
+
@doc_dir = Critbit.home_dir + "/doc"
|
49
|
+
@lib_dir = Critbit.home_dir + "/lib"
|
50
|
+
@src_dir = Critbit.home_dir + "/src"
|
51
|
+
@target_dir = Critbit.home_dir + "/target"
|
52
|
+
@test_dir = Critbit.home_dir + "/test"
|
53
|
+
@vendor_dir = Critbit.home_dir + "/vendor"
|
97
54
|
|
98
55
|
class << self
|
99
56
|
attr_reader :project_dir
|
@@ -105,13 +62,13 @@ class CritbitRB
|
|
105
62
|
attr_reader :vendor_dir
|
106
63
|
end
|
107
64
|
|
108
|
-
@build_dir =
|
65
|
+
@build_dir = Critbit.src_dir + "/build"
|
109
66
|
|
110
67
|
class << self
|
111
68
|
attr_reader :build_dir
|
112
69
|
end
|
113
70
|
|
114
|
-
@classes_dir =
|
71
|
+
@classes_dir = Critbit.build_dir + "/classes"
|
115
72
|
|
116
73
|
class << self
|
117
74
|
attr_reader :classes_dir
|
@@ -119,55 +76,29 @@ class CritbitRB
|
|
119
76
|
|
120
77
|
end
|
121
78
|
|
122
|
-
|
123
|
-
#
|
124
|
-
|
79
|
+
#----------------------------------------------------------------------------------------
|
80
|
+
# If we need to test for coverage
|
81
|
+
#----------------------------------------------------------------------------------------
|
125
82
|
|
126
|
-
|
83
|
+
if $COVERAGE == 'true'
|
127
84
|
|
128
|
-
|
129
|
-
|
85
|
+
require 'simplecov'
|
86
|
+
|
87
|
+
SimpleCov.start do
|
88
|
+
@filters = []
|
89
|
+
add_group "Critbit"
|
90
|
+
end
|
130
91
|
|
131
92
|
end
|
132
93
|
|
133
|
-
$VENDOR_DEPEND.each do |dep|
|
134
|
-
vendor_depend(dep)
|
135
|
-
end if $VENDOR_DEPEND
|
136
|
-
|
137
94
|
##########################################################################################
|
138
|
-
#
|
95
|
+
# Load necessary jar files
|
139
96
|
##########################################################################################
|
140
97
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
# Set development dependencies
|
145
|
-
#---------------------------------------------------------------------------------------
|
146
|
-
|
147
|
-
def depend(name)
|
148
|
-
dependency_dir = CritbitRB.project_dir + "/" + name
|
149
|
-
mklib(dependency_dir)
|
150
|
-
end
|
151
|
-
|
152
|
-
# Add dependencies here
|
153
|
-
# depend(<other_gems>)
|
154
|
-
$DVLP_DEPEND.each do |dep|
|
155
|
-
depend(dep)
|
156
|
-
end if $DVLP_DEPEND
|
157
|
-
|
158
|
-
#----------------------------------------------------------------------------------------
|
159
|
-
# If we need to test for coverage
|
160
|
-
#----------------------------------------------------------------------------------------
|
161
|
-
|
162
|
-
if $COVERAGE == 'true'
|
163
|
-
|
164
|
-
require 'simplecov'
|
165
|
-
|
166
|
-
SimpleCov.start do
|
167
|
-
@filters = []
|
168
|
-
add_group "CritbitRB", "lib/mdarray"
|
169
|
-
end
|
170
|
-
|
171
|
-
end
|
98
|
+
Dir["#{Critbit.vendor_dir}/*.jar"].each do |jar|
|
99
|
+
require jar
|
100
|
+
end
|
172
101
|
|
102
|
+
Dir["#{Critbit.target_dir}/*.jar"].each do |jar|
|
103
|
+
require jar
|
173
104
|
end
|
data/doc/Critbit.html
ADDED
@@ -0,0 +1,3351 @@
|
|
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=utf-8" />
|
6
|
+
<title>
|
7
|
+
Class: Critbit
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7.6
|
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#!Critbit.html";
|
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 (C)</a> »
|
35
|
+
|
36
|
+
|
37
|
+
<span class="title">Critbit</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Class: Critbit
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
<dt class="r1">Inherits:</dt>
|
75
|
+
<dd class="r1">
|
76
|
+
<span class="inheritName">Object</span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next">Critbit</li>
|
82
|
+
|
83
|
+
</ul>
|
84
|
+
<a href="#" class="inheritanceTree">show all</a>
|
85
|
+
|
86
|
+
</dd>
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
<dt class="r2">Includes:</dt>
|
94
|
+
<dd class="r2">Enumerable</dd>
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
<dt class="r1 last">Defined in:</dt>
|
101
|
+
<dd class="r1 last">lib/critbit.rb</dd>
|
102
|
+
|
103
|
+
</dl>
|
104
|
+
<div class="clear"></div>
|
105
|
+
|
106
|
+
<h2>Defined Under Namespace</h2>
|
107
|
+
<p class="children">
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Critbit/Cursor.html" title="Critbit::Cursor (class)">Cursor</a></span>, <span class='object_link'><a href="Critbit/DeleteCursor.html" title="Critbit::DeleteCursor (class)">DeleteCursor</a></span>, <span class='object_link'><a href="Critbit/EachCursor.html" title="Critbit::EachCursor (class)">EachCursor</a></span>, <span class='object_link'><a href="Critbit/EachKeyCursor.html" title="Critbit::EachKeyCursor (class)">EachKeyCursor</a></span>, <span class='object_link'><a href="Critbit/EachValueCursor.html" title="Critbit::EachValueCursor (class)">EachValueCursor</a></span>, <span class='object_link'><a href="Critbit/ListCursor.html" title="Critbit::ListCursor (class)">ListCursor</a></span>
|
113
|
+
|
114
|
+
|
115
|
+
</p>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
121
|
+
<ul class="summary">
|
122
|
+
|
123
|
+
<li class="public ">
|
124
|
+
<span class="summary_signature">
|
125
|
+
|
126
|
+
<a href="#default-instance_method" title="#default (instance method)">- (Object) <strong>default</strong> </a>
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
</span>
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
<span class="summary_desc"><div class='inline'>
|
144
|
+
<p>Returns the value of attribute default.</p>
|
145
|
+
</div></span>
|
146
|
+
|
147
|
+
</li>
|
148
|
+
|
149
|
+
|
150
|
+
<li class="public ">
|
151
|
+
<span class="summary_signature">
|
152
|
+
|
153
|
+
<a href="#default_proc-instance_method" title="#default_proc (instance method)">- (Object) <strong>default_proc</strong> </a>
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
</span>
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
<span class="summary_desc"><div class='inline'>
|
171
|
+
<p>Returns the value of attribute default_proc.</p>
|
172
|
+
</div></span>
|
173
|
+
|
174
|
+
</li>
|
175
|
+
|
176
|
+
|
177
|
+
<li class="public ">
|
178
|
+
<span class="summary_signature">
|
179
|
+
|
180
|
+
<a href="#java_critbit-instance_method" title="#java_critbit (instance method)">- (Object) <strong>java_critbit</strong> </a>
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
</span>
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
<span class="note title readonly">readonly</span>
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
<span class="summary_desc"><div class='inline'>
|
200
|
+
<p>Returns the value of attribute java_critbit.</p>
|
201
|
+
</div></span>
|
202
|
+
|
203
|
+
</li>
|
204
|
+
|
205
|
+
|
206
|
+
<li class="public ">
|
207
|
+
<span class="summary_signature">
|
208
|
+
|
209
|
+
<a href="#prefix-instance_method" title="#prefix (instance method)">- (Object) <strong>prefix</strong> </a>
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
</span>
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
<span class="summary_desc"><div class='inline'>
|
227
|
+
<p>Returns the value of attribute prefix.</p>
|
228
|
+
</div></span>
|
229
|
+
|
230
|
+
</li>
|
231
|
+
|
232
|
+
|
233
|
+
</ul>
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
<h2>
|
240
|
+
Class Method Summary
|
241
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
242
|
+
</h2>
|
243
|
+
|
244
|
+
<ul class="summary">
|
245
|
+
|
246
|
+
<li class="public ">
|
247
|
+
<span class="summary_signature">
|
248
|
+
|
249
|
+
<a href="#%5B%5D-class_method" title="[] (class method)">+ (Object) <strong>[]</strong>(*args) </a>
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
</span>
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<span class="summary_desc"><div class='inline'>
|
264
|
+
<p>Critbit[ key, value, … ] → new_hash.</p>
|
265
|
+
</div></span>
|
266
|
+
|
267
|
+
</li>
|
268
|
+
|
269
|
+
|
270
|
+
<li class="public ">
|
271
|
+
<span class="summary_signature">
|
272
|
+
|
273
|
+
<a href="#try_convert-class_method" title="try_convert (class method)">+ (Object) <strong>try_convert</strong>(arg) </a>
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
</span>
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
<span class="summary_desc"><div class='inline'>
|
288
|
+
<p>————————————————————————————.</p>
|
289
|
+
</div></span>
|
290
|
+
|
291
|
+
</li>
|
292
|
+
|
293
|
+
|
294
|
+
</ul>
|
295
|
+
|
296
|
+
<h2>
|
297
|
+
Instance Method Summary
|
298
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
299
|
+
</h2>
|
300
|
+
|
301
|
+
<ul class="summary">
|
302
|
+
|
303
|
+
<li class="public ">
|
304
|
+
<span class="summary_signature">
|
305
|
+
|
306
|
+
<a href="#%5B%5D-instance_method" title="#[] (instance method)">- (Object) <strong>[]</strong>(key) </a>
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
</span>
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
<span class="summary_desc"><div class='inline'>
|
321
|
+
<p>Element Reference—Retrieves the value object corresponding to the key
|
322
|
+
object.</p>
|
323
|
+
</div></span>
|
324
|
+
|
325
|
+
</li>
|
326
|
+
|
327
|
+
|
328
|
+
<li class="public ">
|
329
|
+
<span class="summary_signature">
|
330
|
+
|
331
|
+
<a href="#%5B%5D%3D-instance_method" title="#[]= (instance method)">- (Object) <strong>[]=</strong>(key, val) </a>
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
(also: #store)
|
336
|
+
|
337
|
+
</span>
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
<span class="summary_desc"><div class='inline'>
|
348
|
+
<p>Associates the value given by value with the key given by key.</p>
|
349
|
+
</div></span>
|
350
|
+
|
351
|
+
</li>
|
352
|
+
|
353
|
+
|
354
|
+
<li class="public ">
|
355
|
+
<span class="summary_signature">
|
356
|
+
|
357
|
+
<a href="#assoc-instance_method" title="#assoc (instance method)">- (Object) <strong>assoc</strong>(key) </a>
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
</span>
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
<span class="summary_desc"><div class='inline'>
|
372
|
+
<p>Searches through the critbit comparing obj with the key using ==.</p>
|
373
|
+
</div></span>
|
374
|
+
|
375
|
+
</li>
|
376
|
+
|
377
|
+
|
378
|
+
<li class="public ">
|
379
|
+
<span class="summary_signature">
|
380
|
+
|
381
|
+
<a href="#clear-instance_method" title="#clear (instance method)">- (Object) <strong>clear</strong> </a>
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
</span>
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
<span class="summary_desc"><div class='inline'>
|
396
|
+
<p>Removes all key-value pairs from critbit.</p>
|
397
|
+
</div></span>
|
398
|
+
|
399
|
+
</li>
|
400
|
+
|
401
|
+
|
402
|
+
<li class="public ">
|
403
|
+
<span class="summary_signature">
|
404
|
+
|
405
|
+
<a href="#delete-instance_method" title="#delete (instance method)">- (Object) <strong>delete</strong>(key) </a>
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
</span>
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
<span class="summary_desc"><div class='inline'>
|
420
|
+
<p>Deletes the key-value pair and returns the value from critbit whose key is
|
421
|
+
equal to key.</p>
|
422
|
+
</div></span>
|
423
|
+
|
424
|
+
</li>
|
425
|
+
|
426
|
+
|
427
|
+
<li class="public ">
|
428
|
+
<span class="summary_signature">
|
429
|
+
|
430
|
+
<a href="#delete_if-instance_method" title="#delete_if (instance method)">- (Object) <strong>delete_if</strong>(prefix = nil, &block) </a>
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
(also: #reject!)
|
435
|
+
|
436
|
+
</span>
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
<span class="summary_desc"><div class='inline'>
|
447
|
+
<p>Deletes every key-value pair from hsh for which block evaluates to true.</p>
|
448
|
+
</div></span>
|
449
|
+
|
450
|
+
</li>
|
451
|
+
|
452
|
+
|
453
|
+
<li class="public ">
|
454
|
+
<span class="summary_signature">
|
455
|
+
|
456
|
+
<a href="#each-instance_method" title="#each (instance method)">- (Object) <strong>each</strong>(prefix = nil, &block) </a>
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
(also: #each_pair)
|
461
|
+
|
462
|
+
</span>
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
<span class="summary_desc"><div class='inline'>
|
473
|
+
<p>Calls block once for each key in critbit, passing the key-value pair as
|
474
|
+
parameters.</p>
|
475
|
+
</div></span>
|
476
|
+
|
477
|
+
</li>
|
478
|
+
|
479
|
+
|
480
|
+
<li class="public ">
|
481
|
+
<span class="summary_signature">
|
482
|
+
|
483
|
+
<a href="#each_key-instance_method" title="#each_key (instance method)">- (Object) <strong>each_key</strong>(prefix = nil, &block) </a>
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
</span>
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
<span class="summary_desc"><div class='inline'>
|
498
|
+
<p>Calls block once for each key in critbit, passing the key as a parameter.</p>
|
499
|
+
</div></span>
|
500
|
+
|
501
|
+
</li>
|
502
|
+
|
503
|
+
|
504
|
+
<li class="public ">
|
505
|
+
<span class="summary_signature">
|
506
|
+
|
507
|
+
<a href="#each_value-instance_method" title="#each_value (instance method)">- (Object) <strong>each_value</strong>(prefix = nil, &block) </a>
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
</span>
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
<span class="summary_desc"><div class='inline'>
|
522
|
+
<p>Calls block once for each value in critbit, passing the value as a
|
523
|
+
parameter.</p>
|
524
|
+
</div></span>
|
525
|
+
|
526
|
+
</li>
|
527
|
+
|
528
|
+
|
529
|
+
<li class="public ">
|
530
|
+
<span class="summary_signature">
|
531
|
+
|
532
|
+
<a href="#empty%3F-instance_method" title="#empty? (instance method)">- (Boolean) <strong>empty?</strong> </a>
|
533
|
+
|
534
|
+
|
535
|
+
|
536
|
+
</span>
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
<span class="summary_desc"><div class='inline'>
|
547
|
+
<p>Returns true if critbit contains no key-value pairs.</p>
|
548
|
+
</div></span>
|
549
|
+
|
550
|
+
</li>
|
551
|
+
|
552
|
+
|
553
|
+
<li class="public ">
|
554
|
+
<span class="summary_signature">
|
555
|
+
|
556
|
+
<a href="#eql%3F-instance_method" title="#eql? (instance method)">- (Boolean) <strong>eql?</strong>(other) </a>
|
557
|
+
|
558
|
+
|
559
|
+
|
560
|
+
</span>
|
561
|
+
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
|
570
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
571
|
+
|
572
|
+
</li>
|
573
|
+
|
574
|
+
|
575
|
+
<li class="public ">
|
576
|
+
<span class="summary_signature">
|
577
|
+
|
578
|
+
<a href="#fetch-instance_method" title="#fetch (instance method)">- (Object) <strong>fetch</strong>(key, default = nil, &block) </a>
|
579
|
+
|
580
|
+
|
581
|
+
|
582
|
+
</span>
|
583
|
+
|
584
|
+
|
585
|
+
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
|
592
|
+
<span class="summary_desc"><div class='inline'>
|
593
|
+
<p>Returns a value from the critbit for the given key.</p>
|
594
|
+
</div></span>
|
595
|
+
|
596
|
+
</li>
|
597
|
+
|
598
|
+
|
599
|
+
<li class="public ">
|
600
|
+
<span class="summary_signature">
|
601
|
+
|
602
|
+
<a href="#flatten-instance_method" title="#flatten (instance method)">- (Object) <strong>flatten</strong>(level = nil) </a>
|
603
|
+
|
604
|
+
|
605
|
+
|
606
|
+
</span>
|
607
|
+
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
|
612
|
+
|
613
|
+
|
614
|
+
|
615
|
+
|
616
|
+
<span class="summary_desc"><div class='inline'>
|
617
|
+
<p>Returns a new array that is a one-dimensional flattening of this critbit.</p>
|
618
|
+
</div></span>
|
619
|
+
|
620
|
+
</li>
|
621
|
+
|
622
|
+
|
623
|
+
<li class="public ">
|
624
|
+
<span class="summary_signature">
|
625
|
+
|
626
|
+
<a href="#has_key%3F-instance_method" title="#has_key? (instance method)">- (Boolean) <strong>has_key?</strong>(key) </a>
|
627
|
+
|
628
|
+
|
629
|
+
|
630
|
+
(also: #include?, #member?, #key?)
|
631
|
+
|
632
|
+
</span>
|
633
|
+
|
634
|
+
|
635
|
+
|
636
|
+
|
637
|
+
|
638
|
+
|
639
|
+
|
640
|
+
|
641
|
+
|
642
|
+
<span class="summary_desc"><div class='inline'>
|
643
|
+
<p>Returns true if the given key is present in critbit.</p>
|
644
|
+
</div></span>
|
645
|
+
|
646
|
+
</li>
|
647
|
+
|
648
|
+
|
649
|
+
<li class="public ">
|
650
|
+
<span class="summary_signature">
|
651
|
+
|
652
|
+
<a href="#has_value%3F-instance_method" title="#has_value? (instance method)">- (Boolean) <strong>has_value?</strong>(val) </a>
|
653
|
+
|
654
|
+
|
655
|
+
|
656
|
+
</span>
|
657
|
+
|
658
|
+
|
659
|
+
|
660
|
+
|
661
|
+
|
662
|
+
|
663
|
+
|
664
|
+
|
665
|
+
|
666
|
+
<span class="summary_desc"><div class='inline'>
|
667
|
+
<p>Returns true if the given value is present for some key in critbit.</p>
|
668
|
+
</div></span>
|
669
|
+
|
670
|
+
</li>
|
671
|
+
|
672
|
+
|
673
|
+
<li class="public ">
|
674
|
+
<span class="summary_signature">
|
675
|
+
|
676
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Object) <strong>initialize</strong>(default = nil, &block) </a>
|
677
|
+
|
678
|
+
|
679
|
+
|
680
|
+
</span>
|
681
|
+
|
682
|
+
|
683
|
+
<span class="note title constructor">constructor</span>
|
684
|
+
|
685
|
+
|
686
|
+
|
687
|
+
|
688
|
+
|
689
|
+
|
690
|
+
|
691
|
+
|
692
|
+
<span class="summary_desc"><div class='inline'>
|
693
|
+
<p>new → new_critbit.</p>
|
694
|
+
</div></span>
|
695
|
+
|
696
|
+
</li>
|
697
|
+
|
698
|
+
|
699
|
+
<li class="public ">
|
700
|
+
<span class="summary_signature">
|
701
|
+
|
702
|
+
<a href="#inspect-instance_method" title="#inspect (instance method)">- (Object) <strong>inspect</strong> </a>
|
703
|
+
|
704
|
+
|
705
|
+
|
706
|
+
(also: #to_s)
|
707
|
+
|
708
|
+
</span>
|
709
|
+
|
710
|
+
|
711
|
+
|
712
|
+
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
<span class="summary_desc"><div class='inline'>
|
719
|
+
<p>Return the contents of this critbit as a string.</p>
|
720
|
+
</div></span>
|
721
|
+
|
722
|
+
</li>
|
723
|
+
|
724
|
+
|
725
|
+
<li class="public ">
|
726
|
+
<span class="summary_signature">
|
727
|
+
|
728
|
+
<a href="#invert-instance_method" title="#invert (instance method)">- (Object) <strong>invert</strong> </a>
|
729
|
+
|
730
|
+
|
731
|
+
|
732
|
+
</span>
|
733
|
+
|
734
|
+
|
735
|
+
|
736
|
+
|
737
|
+
|
738
|
+
|
739
|
+
|
740
|
+
|
741
|
+
|
742
|
+
<span class="summary_desc"><div class='inline'>
|
743
|
+
<p>Returns a new critbit created by using critbit’s values as keys, and the
|
744
|
+
keys as values.</p>
|
745
|
+
</div></span>
|
746
|
+
|
747
|
+
</li>
|
748
|
+
|
749
|
+
|
750
|
+
<li class="public ">
|
751
|
+
<span class="summary_signature">
|
752
|
+
|
753
|
+
<a href="#keep_if-instance_method" title="#keep_if (instance method)">- (Object) <strong>keep_if</strong>(prefix = nil, &block) </a>
|
754
|
+
|
755
|
+
|
756
|
+
|
757
|
+
(also: #select!)
|
758
|
+
|
759
|
+
</span>
|
760
|
+
|
761
|
+
|
762
|
+
|
763
|
+
|
764
|
+
|
765
|
+
|
766
|
+
|
767
|
+
|
768
|
+
|
769
|
+
<span class="summary_desc"><div class='inline'>
|
770
|
+
<p>Deletes every key-value pair from critbit for which block evaluates to
|
771
|
+
false.</p>
|
772
|
+
</div></span>
|
773
|
+
|
774
|
+
</li>
|
775
|
+
|
776
|
+
|
777
|
+
<li class="public ">
|
778
|
+
<span class="summary_signature">
|
779
|
+
|
780
|
+
<a href="#key-instance_method" title="#key (instance method)">- (Object) <strong>key</strong>(val) </a>
|
781
|
+
|
782
|
+
|
783
|
+
|
784
|
+
</span>
|
785
|
+
|
786
|
+
|
787
|
+
|
788
|
+
|
789
|
+
|
790
|
+
|
791
|
+
|
792
|
+
|
793
|
+
|
794
|
+
<span class="summary_desc"><div class='inline'>
|
795
|
+
<p>Returns the key of an occurrence of a given value.</p>
|
796
|
+
</div></span>
|
797
|
+
|
798
|
+
</li>
|
799
|
+
|
800
|
+
|
801
|
+
<li class="public ">
|
802
|
+
<span class="summary_signature">
|
803
|
+
|
804
|
+
<a href="#keys-instance_method" title="#keys (instance method)">- (Object) <strong>keys</strong>(prefix = nil) </a>
|
805
|
+
|
806
|
+
|
807
|
+
|
808
|
+
</span>
|
809
|
+
|
810
|
+
|
811
|
+
|
812
|
+
|
813
|
+
|
814
|
+
|
815
|
+
|
816
|
+
|
817
|
+
|
818
|
+
<span class="summary_desc"><div class='inline'>
|
819
|
+
<p>Returns a new array populated with the keys from this critbit.</p>
|
820
|
+
</div></span>
|
821
|
+
|
822
|
+
</li>
|
823
|
+
|
824
|
+
|
825
|
+
<li class="public ">
|
826
|
+
<span class="summary_signature">
|
827
|
+
|
828
|
+
<a href="#max-instance_method" title="#max (instance method)">- (Object) <strong>max</strong> </a>
|
829
|
+
|
830
|
+
|
831
|
+
|
832
|
+
</span>
|
833
|
+
|
834
|
+
|
835
|
+
|
836
|
+
|
837
|
+
|
838
|
+
|
839
|
+
|
840
|
+
|
841
|
+
|
842
|
+
<span class="summary_desc"><div class='inline'>
|
843
|
+
<p>————————————————————————————.</p>
|
844
|
+
</div></span>
|
845
|
+
|
846
|
+
</li>
|
847
|
+
|
848
|
+
|
849
|
+
<li class="public ">
|
850
|
+
<span class="summary_signature">
|
851
|
+
|
852
|
+
<a href="#merge-instance_method" title="#merge (instance method)">- (Object) <strong>merge</strong>(other_critbit, &block) </a>
|
853
|
+
|
854
|
+
|
855
|
+
|
856
|
+
(also: #update)
|
857
|
+
|
858
|
+
</span>
|
859
|
+
|
860
|
+
|
861
|
+
|
862
|
+
|
863
|
+
|
864
|
+
|
865
|
+
|
866
|
+
|
867
|
+
|
868
|
+
<span class="summary_desc"><div class='inline'>
|
869
|
+
<p>Returns a new critbit containing the contents of other_critbit and the
|
870
|
+
contents of critbit.</p>
|
871
|
+
</div></span>
|
872
|
+
|
873
|
+
</li>
|
874
|
+
|
875
|
+
|
876
|
+
<li class="public ">
|
877
|
+
<span class="summary_signature">
|
878
|
+
|
879
|
+
<a href="#merge%21-instance_method" title="#merge! (instance method)">- (Object) <strong>merge!</strong>(other_critbit, &block) </a>
|
880
|
+
|
881
|
+
|
882
|
+
|
883
|
+
</span>
|
884
|
+
|
885
|
+
|
886
|
+
|
887
|
+
|
888
|
+
|
889
|
+
|
890
|
+
|
891
|
+
|
892
|
+
|
893
|
+
<span class="summary_desc"><div class='inline'>
|
894
|
+
<p>Returns a new critbit containing the contents of other_critbit and the
|
895
|
+
contents of critbit.</p>
|
896
|
+
</div></span>
|
897
|
+
|
898
|
+
</li>
|
899
|
+
|
900
|
+
|
901
|
+
<li class="public ">
|
902
|
+
<span class="summary_signature">
|
903
|
+
|
904
|
+
<a href="#min-instance_method" title="#min (instance method)">- (Object) <strong>min</strong> </a>
|
905
|
+
|
906
|
+
|
907
|
+
|
908
|
+
</span>
|
909
|
+
|
910
|
+
|
911
|
+
|
912
|
+
|
913
|
+
|
914
|
+
|
915
|
+
|
916
|
+
|
917
|
+
|
918
|
+
<span class="summary_desc"><div class='inline'>
|
919
|
+
<p>————————————————————————————.</p>
|
920
|
+
</div></span>
|
921
|
+
|
922
|
+
</li>
|
923
|
+
|
924
|
+
|
925
|
+
<li class="public ">
|
926
|
+
<span class="summary_signature">
|
927
|
+
|
928
|
+
<a href="#put_all-instance_method" title="#put_all (instance method)">- (Object) <strong>put_all</strong>(other_critbit) </a>
|
929
|
+
|
930
|
+
|
931
|
+
|
932
|
+
</span>
|
933
|
+
|
934
|
+
|
935
|
+
|
936
|
+
|
937
|
+
|
938
|
+
|
939
|
+
|
940
|
+
|
941
|
+
|
942
|
+
<span class="summary_desc"><div class='inline'>
|
943
|
+
<p>———————————————————————————— Merges the two critbits.</p>
|
944
|
+
</div></span>
|
945
|
+
|
946
|
+
</li>
|
947
|
+
|
948
|
+
|
949
|
+
<li class="public ">
|
950
|
+
<span class="summary_signature">
|
951
|
+
|
952
|
+
<a href="#rassoc-instance_method" title="#rassoc (instance method)">- (Object) <strong>rassoc</strong>(obj) </a>
|
953
|
+
|
954
|
+
|
955
|
+
|
956
|
+
</span>
|
957
|
+
|
958
|
+
|
959
|
+
|
960
|
+
|
961
|
+
|
962
|
+
|
963
|
+
|
964
|
+
|
965
|
+
|
966
|
+
<span class="summary_desc"><div class='inline'>
|
967
|
+
<p>Searches through the critbit comparing obj with the value using ==.</p>
|
968
|
+
</div></span>
|
969
|
+
|
970
|
+
</li>
|
971
|
+
|
972
|
+
|
973
|
+
<li class="public ">
|
974
|
+
<span class="summary_signature">
|
975
|
+
|
976
|
+
<a href="#remove-instance_method" title="#remove (instance method)">- (Object) <strong>remove</strong>(key) </a>
|
977
|
+
|
978
|
+
|
979
|
+
|
980
|
+
</span>
|
981
|
+
|
982
|
+
|
983
|
+
|
984
|
+
|
985
|
+
|
986
|
+
|
987
|
+
|
988
|
+
|
989
|
+
|
990
|
+
<span class="summary_desc"><div class='inline'>
|
991
|
+
<p>———————————————————————————— Removes the key value pair from the critbit.</p>
|
992
|
+
</div></span>
|
993
|
+
|
994
|
+
</li>
|
995
|
+
|
996
|
+
|
997
|
+
<li class="public ">
|
998
|
+
<span class="summary_signature">
|
999
|
+
|
1000
|
+
<a href="#size-instance_method" title="#size (instance method)">- (Object) <strong>size</strong> </a>
|
1001
|
+
|
1002
|
+
|
1003
|
+
|
1004
|
+
(also: #length)
|
1005
|
+
|
1006
|
+
</span>
|
1007
|
+
|
1008
|
+
|
1009
|
+
|
1010
|
+
|
1011
|
+
|
1012
|
+
|
1013
|
+
|
1014
|
+
|
1015
|
+
|
1016
|
+
<span class="summary_desc"><div class='inline'>
|
1017
|
+
<p>————————————————————————————.</p>
|
1018
|
+
</div></span>
|
1019
|
+
|
1020
|
+
</li>
|
1021
|
+
|
1022
|
+
|
1023
|
+
<li class="public ">
|
1024
|
+
<span class="summary_signature">
|
1025
|
+
|
1026
|
+
<a href="#values-instance_method" title="#values (instance method)">- (Object) <strong>values</strong>(prefix = nil) </a>
|
1027
|
+
|
1028
|
+
|
1029
|
+
|
1030
|
+
</span>
|
1031
|
+
|
1032
|
+
|
1033
|
+
|
1034
|
+
|
1035
|
+
|
1036
|
+
|
1037
|
+
|
1038
|
+
|
1039
|
+
|
1040
|
+
<span class="summary_desc"><div class='inline'>
|
1041
|
+
<p>————————————————————————————.</p>
|
1042
|
+
</div></span>
|
1043
|
+
|
1044
|
+
</li>
|
1045
|
+
|
1046
|
+
|
1047
|
+
</ul>
|
1048
|
+
|
1049
|
+
|
1050
|
+
|
1051
|
+
<div id="constructor_details" class="method_details_list">
|
1052
|
+
<h2>Constructor Details</h2>
|
1053
|
+
|
1054
|
+
<div class="method_details first">
|
1055
|
+
<h3 class="signature first" id="initialize-instance_method">
|
1056
|
+
|
1057
|
+
- (<tt>Object</tt>) <strong>initialize</strong>(default = nil, &block)
|
1058
|
+
|
1059
|
+
|
1060
|
+
|
1061
|
+
|
1062
|
+
|
1063
|
+
</h3><div class="docstring">
|
1064
|
+
<div class="discussion">
|
1065
|
+
|
1066
|
+
<p>new → new_critbit</p>
|
1067
|
+
|
1068
|
+
<p>new(obj) → new_critbit</p>
|
1069
|
+
|
1070
|
+
<p>new {|critbit, key| block } → new_critbit</p>
|
1071
|
+
|
1072
|
+
<p>Returns a new, empty critbit. If this critbit is subsequently accessed by a
|
1073
|
+
key that doesn’t correspond to a critbit entry, the value returned depends
|
1074
|
+
on the style of new used to create the critbit. In the first form, the
|
1075
|
+
access returns nil. If obj is specified, this single object will be used
|
1076
|
+
for all default values. If a block is specified, it will be called with the
|
1077
|
+
critbit object and the key, and should return the default value. It is the
|
1078
|
+
block’s responsibility to store the value in the critbit if required.</p>
|
1079
|
+
|
1080
|
+
|
1081
|
+
</div>
|
1082
|
+
</div>
|
1083
|
+
<div class="tags">
|
1084
|
+
<p class="tag_title">Parameters:</p>
|
1085
|
+
<ul class="param">
|
1086
|
+
|
1087
|
+
<li>
|
1088
|
+
|
1089
|
+
<span class='name'>default</span>
|
1090
|
+
|
1091
|
+
|
1092
|
+
<span class='type'>(<tt>Default</tt>)</span>
|
1093
|
+
|
1094
|
+
|
1095
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
1096
|
+
|
1097
|
+
|
1098
|
+
—
|
1099
|
+
<div class='inline'>
|
1100
|
+
<p>the default return value if the key is not found</p>
|
1101
|
+
</div>
|
1102
|
+
|
1103
|
+
</li>
|
1104
|
+
|
1105
|
+
<li>
|
1106
|
+
|
1107
|
+
<span class='name'>block</span>
|
1108
|
+
|
1109
|
+
|
1110
|
+
<span class='type'>(<tt>Block</tt>)</span>
|
1111
|
+
|
1112
|
+
|
1113
|
+
|
1114
|
+
—
|
1115
|
+
<div class='inline'>
|
1116
|
+
<p>the default block to be executed if key is not found</p>
|
1117
|
+
</div>
|
1118
|
+
|
1119
|
+
</li>
|
1120
|
+
|
1121
|
+
</ul>
|
1122
|
+
|
1123
|
+
|
1124
|
+
</div><table class="source_code">
|
1125
|
+
<tr>
|
1126
|
+
<td>
|
1127
|
+
<pre class="lines">
|
1128
|
+
|
1129
|
+
|
1130
|
+
124
|
1131
|
+
125
|
1132
|
+
126
|
1133
|
+
127
|
1134
|
+
128
|
1135
|
+
129</pre>
|
1136
|
+
</td>
|
1137
|
+
<td>
|
1138
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 124</span>
|
1139
|
+
|
1140
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_default'>default</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1141
|
+
<span class='ivar'>@default</span> <span class='op'>=</span> <span class='id identifier rubyid_default'>default</span>
|
1142
|
+
<span class='ivar'>@default_proc</span> <span class='op'>=</span> <span class='id identifier rubyid_block'>block</span>
|
1143
|
+
<span class='ivar'>@prefix</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
1144
|
+
<span class='ivar'>@java_critbit</span> <span class='op'>=</span> <span class='const'>MCritBitTree</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>StringKeyAnalyzer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
|
1145
|
+
<span class='kw'>end</span></pre>
|
1146
|
+
</td>
|
1147
|
+
</tr>
|
1148
|
+
</table>
|
1149
|
+
</div>
|
1150
|
+
|
1151
|
+
</div>
|
1152
|
+
|
1153
|
+
<div id="instance_attr_details" class="attr_details">
|
1154
|
+
<h2>Instance Attribute Details</h2>
|
1155
|
+
|
1156
|
+
|
1157
|
+
<span id="default=-instance_method"></span>
|
1158
|
+
<div class="method_details first">
|
1159
|
+
<h3 class="signature first" id="default-instance_method">
|
1160
|
+
|
1161
|
+
- (<tt>Object</tt>) <strong>default</strong>
|
1162
|
+
|
1163
|
+
|
1164
|
+
|
1165
|
+
|
1166
|
+
|
1167
|
+
</h3><div class="docstring">
|
1168
|
+
<div class="discussion">
|
1169
|
+
|
1170
|
+
<p>Returns the value of attribute default</p>
|
1171
|
+
|
1172
|
+
|
1173
|
+
</div>
|
1174
|
+
</div>
|
1175
|
+
<div class="tags">
|
1176
|
+
|
1177
|
+
|
1178
|
+
</div><table class="source_code">
|
1179
|
+
<tr>
|
1180
|
+
<td>
|
1181
|
+
<pre class="lines">
|
1182
|
+
|
1183
|
+
|
1184
|
+
38
|
1185
|
+
39
|
1186
|
+
40</pre>
|
1187
|
+
</td>
|
1188
|
+
<td>
|
1189
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 38</span>
|
1190
|
+
|
1191
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
|
1192
|
+
<span class='ivar'>@default</span>
|
1193
|
+
<span class='kw'>end</span></pre>
|
1194
|
+
</td>
|
1195
|
+
</tr>
|
1196
|
+
</table>
|
1197
|
+
</div>
|
1198
|
+
|
1199
|
+
|
1200
|
+
<span id="default_proc=-instance_method"></span>
|
1201
|
+
<div class="method_details ">
|
1202
|
+
<h3 class="signature " id="default_proc-instance_method">
|
1203
|
+
|
1204
|
+
- (<tt>Object</tt>) <strong>default_proc</strong>
|
1205
|
+
|
1206
|
+
|
1207
|
+
|
1208
|
+
|
1209
|
+
|
1210
|
+
</h3><div class="docstring">
|
1211
|
+
<div class="discussion">
|
1212
|
+
|
1213
|
+
<p>Returns the value of attribute default_proc</p>
|
1214
|
+
|
1215
|
+
|
1216
|
+
</div>
|
1217
|
+
</div>
|
1218
|
+
<div class="tags">
|
1219
|
+
|
1220
|
+
|
1221
|
+
</div><table class="source_code">
|
1222
|
+
<tr>
|
1223
|
+
<td>
|
1224
|
+
<pre class="lines">
|
1225
|
+
|
1226
|
+
|
1227
|
+
39
|
1228
|
+
40
|
1229
|
+
41</pre>
|
1230
|
+
</td>
|
1231
|
+
<td>
|
1232
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 39</span>
|
1233
|
+
|
1234
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_default_proc'>default_proc</span>
|
1235
|
+
<span class='ivar'>@default_proc</span>
|
1236
|
+
<span class='kw'>end</span></pre>
|
1237
|
+
</td>
|
1238
|
+
</tr>
|
1239
|
+
</table>
|
1240
|
+
</div>
|
1241
|
+
|
1242
|
+
|
1243
|
+
<span id=""></span>
|
1244
|
+
<div class="method_details ">
|
1245
|
+
<h3 class="signature " id="java_critbit-instance_method">
|
1246
|
+
|
1247
|
+
- (<tt>Object</tt>) <strong>java_critbit</strong> <span class="extras">(readonly)</span>
|
1248
|
+
|
1249
|
+
|
1250
|
+
|
1251
|
+
|
1252
|
+
|
1253
|
+
</h3><div class="docstring">
|
1254
|
+
<div class="discussion">
|
1255
|
+
|
1256
|
+
<p>Returns the value of attribute java_critbit</p>
|
1257
|
+
|
1258
|
+
|
1259
|
+
</div>
|
1260
|
+
</div>
|
1261
|
+
<div class="tags">
|
1262
|
+
|
1263
|
+
|
1264
|
+
</div><table class="source_code">
|
1265
|
+
<tr>
|
1266
|
+
<td>
|
1267
|
+
<pre class="lines">
|
1268
|
+
|
1269
|
+
|
1270
|
+
37
|
1271
|
+
38
|
1272
|
+
39</pre>
|
1273
|
+
</td>
|
1274
|
+
<td>
|
1275
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 37</span>
|
1276
|
+
|
1277
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_java_critbit'>java_critbit</span>
|
1278
|
+
<span class='ivar'>@java_critbit</span>
|
1279
|
+
<span class='kw'>end</span></pre>
|
1280
|
+
</td>
|
1281
|
+
</tr>
|
1282
|
+
</table>
|
1283
|
+
</div>
|
1284
|
+
|
1285
|
+
|
1286
|
+
<span id="prefix=-instance_method"></span>
|
1287
|
+
<div class="method_details ">
|
1288
|
+
<h3 class="signature " id="prefix-instance_method">
|
1289
|
+
|
1290
|
+
- (<tt>Object</tt>) <strong>prefix</strong>
|
1291
|
+
|
1292
|
+
|
1293
|
+
|
1294
|
+
|
1295
|
+
|
1296
|
+
</h3><div class="docstring">
|
1297
|
+
<div class="discussion">
|
1298
|
+
|
1299
|
+
<p>Returns the value of attribute prefix</p>
|
1300
|
+
|
1301
|
+
|
1302
|
+
</div>
|
1303
|
+
</div>
|
1304
|
+
<div class="tags">
|
1305
|
+
|
1306
|
+
|
1307
|
+
</div><table class="source_code">
|
1308
|
+
<tr>
|
1309
|
+
<td>
|
1310
|
+
<pre class="lines">
|
1311
|
+
|
1312
|
+
|
1313
|
+
40
|
1314
|
+
41
|
1315
|
+
42</pre>
|
1316
|
+
</td>
|
1317
|
+
<td>
|
1318
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 40</span>
|
1319
|
+
|
1320
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_prefix'>prefix</span>
|
1321
|
+
<span class='ivar'>@prefix</span>
|
1322
|
+
<span class='kw'>end</span></pre>
|
1323
|
+
</td>
|
1324
|
+
</tr>
|
1325
|
+
</table>
|
1326
|
+
</div>
|
1327
|
+
|
1328
|
+
</div>
|
1329
|
+
|
1330
|
+
|
1331
|
+
<div id="class_method_details" class="method_details_list">
|
1332
|
+
<h2>Class Method Details</h2>
|
1333
|
+
|
1334
|
+
|
1335
|
+
<div class="method_details first">
|
1336
|
+
<h3 class="signature first" id="[]-class_method">
|
1337
|
+
|
1338
|
+
+ (<tt>Object</tt>) <strong>[]</strong>(*args)
|
1339
|
+
|
1340
|
+
|
1341
|
+
|
1342
|
+
|
1343
|
+
|
1344
|
+
</h3><div class="docstring">
|
1345
|
+
<div class="discussion">
|
1346
|
+
|
1347
|
+
<p>Critbit[ key, value, … ] → new_hash</p>
|
1348
|
+
|
1349
|
+
<p>Critbit[ [ [key, value], … ] ] → new_hash</p>
|
1350
|
+
|
1351
|
+
<p>Critbit[ object ] → new_hash</p>
|
1352
|
+
|
1353
|
+
<p>Creates a new critbit populated with the given objects.</p>
|
1354
|
+
|
1355
|
+
<p>Similar to the literal hash { key => value, … }. In the first form, keys
|
1356
|
+
and values occur in pairs, so there must be an even number of arguments.</p>
|
1357
|
+
|
1358
|
+
<p>The second and third form take a single argument which is either an array
|
1359
|
+
of key-value pairs or an object convertible to a hash.</p>
|
1360
|
+
|
1361
|
+
|
1362
|
+
</div>
|
1363
|
+
</div>
|
1364
|
+
<div class="tags">
|
1365
|
+
<p class="tag_title">Parameters:</p>
|
1366
|
+
<ul class="param">
|
1367
|
+
|
1368
|
+
<li>
|
1369
|
+
|
1370
|
+
<span class='name'>args</span>
|
1371
|
+
|
1372
|
+
|
1373
|
+
<span class='type'>(<tt>Args</tt>)</span>
|
1374
|
+
|
1375
|
+
|
1376
|
+
|
1377
|
+
—
|
1378
|
+
<div class='inline'>
|
1379
|
+
<p>list of arguments in any of the above formats</p>
|
1380
|
+
</div>
|
1381
|
+
|
1382
|
+
</li>
|
1383
|
+
|
1384
|
+
</ul>
|
1385
|
+
|
1386
|
+
<p class="tag_title">Returns:</p>
|
1387
|
+
<ul class="return">
|
1388
|
+
|
1389
|
+
<li>
|
1390
|
+
|
1391
|
+
|
1392
|
+
<span class='type'></span>
|
1393
|
+
|
1394
|
+
|
1395
|
+
|
1396
|
+
|
1397
|
+
<div class='inline'>
|
1398
|
+
<p>a new Critbit</p>
|
1399
|
+
</div>
|
1400
|
+
|
1401
|
+
</li>
|
1402
|
+
|
1403
|
+
</ul>
|
1404
|
+
|
1405
|
+
</div><table class="source_code">
|
1406
|
+
<tr>
|
1407
|
+
<td>
|
1408
|
+
<pre class="lines">
|
1409
|
+
|
1410
|
+
|
1411
|
+
59
|
1412
|
+
60
|
1413
|
+
61
|
1414
|
+
62
|
1415
|
+
63
|
1416
|
+
64
|
1417
|
+
65
|
1418
|
+
66
|
1419
|
+
67
|
1420
|
+
68
|
1421
|
+
69
|
1422
|
+
70
|
1423
|
+
71
|
1424
|
+
72
|
1425
|
+
73
|
1426
|
+
74
|
1427
|
+
75
|
1428
|
+
76
|
1429
|
+
77
|
1430
|
+
78
|
1431
|
+
79
|
1432
|
+
80
|
1433
|
+
81
|
1434
|
+
82
|
1435
|
+
83
|
1436
|
+
84
|
1437
|
+
85
|
1438
|
+
86
|
1439
|
+
87
|
1440
|
+
88
|
1441
|
+
89
|
1442
|
+
90
|
1443
|
+
91
|
1444
|
+
92
|
1445
|
+
93
|
1446
|
+
94
|
1447
|
+
95
|
1448
|
+
96
|
1449
|
+
97</pre>
|
1450
|
+
</td>
|
1451
|
+
<td>
|
1452
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 59</span>
|
1453
|
+
|
1454
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='op'>[]</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
1455
|
+
|
1456
|
+
<span class='id identifier rubyid_crit'>crit</span> <span class='op'>=</span> <span class='const'>Critbit</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
1457
|
+
|
1458
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>1</span>
|
1459
|
+
|
1460
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Critbit</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
1461
|
+
<span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span>
|
1462
|
+
<span class='id identifier rubyid_crit'>crit</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_v'>v</span>
|
1463
|
+
<span class='kw'>end</span>
|
1464
|
+
<span class='kw'>elsif</span> <span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Array</span><span class='rparen'>)</span>
|
1465
|
+
<span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key_pair'>key_pair</span><span class='op'>|</span>
|
1466
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_key_pair'>key_pair</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Array</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='lparen'>(</span><span class='id identifier rubyid_key_pair'>key_pair</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>2</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
1467
|
+
<span class='id identifier rubyid_crit'>crit</span><span class='lbracket'>[</span><span class='id identifier rubyid_key_pair'>key_pair</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_key_pair'>key_pair</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
1468
|
+
<span class='kw'>else</span>
|
1469
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Illegal argument for Critbit </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key_pair'>key_pair</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
1470
|
+
<span class='kw'>end</span>
|
1471
|
+
<span class='kw'>end</span>
|
1472
|
+
<span class='kw'>else</span>
|
1473
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>illegal argument for Critbit</span><span class='tstring_end'>"</span></span>
|
1474
|
+
<span class='kw'>end</span>
|
1475
|
+
|
1476
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_crit'>crit</span>
|
1477
|
+
|
1478
|
+
<span class='kw'>end</span>
|
1479
|
+
|
1480
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>%</span> <span class='int'>2</span> <span class='op'>!=</span> <span class='int'>0</span><span class='rparen'>)</span>
|
1481
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>odd number of arguments for Critbit</span><span class='tstring_end'>"</span></span>
|
1482
|
+
<span class='kw'>else</span>
|
1483
|
+
<span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='int'>0</span>
|
1484
|
+
<span class='kw'>begin</span>
|
1485
|
+
<span class='id identifier rubyid_crit'>crit</span><span class='lbracket'>[</span><span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='op'>+</span><span class='int'>1</span><span class='rbracket'>]</span>
|
1486
|
+
<span class='id identifier rubyid_i'>i</span> <span class='op'>+=</span> <span class='int'>2</span>
|
1487
|
+
<span class='kw'>end</span> <span class='kw'>while</span> <span class='id identifier rubyid_i'>i</span> <span class='op'><</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
|
1488
|
+
<span class='kw'>end</span>
|
1489
|
+
|
1490
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_crit'>crit</span>
|
1491
|
+
|
1492
|
+
<span class='kw'>end</span></pre>
|
1493
|
+
</td>
|
1494
|
+
</tr>
|
1495
|
+
</table>
|
1496
|
+
</div>
|
1497
|
+
|
1498
|
+
<div class="method_details ">
|
1499
|
+
<h3 class="signature " id="try_convert-class_method">
|
1500
|
+
|
1501
|
+
+ (<tt>Object</tt>) <strong>try_convert</strong>(arg)
|
1502
|
+
|
1503
|
+
|
1504
|
+
|
1505
|
+
|
1506
|
+
|
1507
|
+
</h3><div class="docstring">
|
1508
|
+
<div class="discussion">
|
1509
|
+
<hr>
|
1510
|
+
<hr>
|
1511
|
+
|
1512
|
+
|
1513
|
+
</div>
|
1514
|
+
</div>
|
1515
|
+
<div class="tags">
|
1516
|
+
|
1517
|
+
|
1518
|
+
</div><table class="source_code">
|
1519
|
+
<tr>
|
1520
|
+
<td>
|
1521
|
+
<pre class="lines">
|
1522
|
+
|
1523
|
+
|
1524
|
+
103
|
1525
|
+
104
|
1526
|
+
105</pre>
|
1527
|
+
</td>
|
1528
|
+
<td>
|
1529
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 103</span>
|
1530
|
+
|
1531
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_try_convert'>try_convert</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='rparen'>)</span>
|
1532
|
+
|
1533
|
+
<span class='kw'>end</span></pre>
|
1534
|
+
</td>
|
1535
|
+
</tr>
|
1536
|
+
</table>
|
1537
|
+
</div>
|
1538
|
+
|
1539
|
+
</div>
|
1540
|
+
|
1541
|
+
<div id="instance_method_details" class="method_details_list">
|
1542
|
+
<h2>Instance Method Details</h2>
|
1543
|
+
|
1544
|
+
|
1545
|
+
<div class="method_details first">
|
1546
|
+
<h3 class="signature first" id="[]-instance_method">
|
1547
|
+
|
1548
|
+
- (<tt>Object</tt>) <strong>[]</strong>(key)
|
1549
|
+
|
1550
|
+
|
1551
|
+
|
1552
|
+
|
1553
|
+
|
1554
|
+
</h3><div class="docstring">
|
1555
|
+
<div class="discussion">
|
1556
|
+
|
1557
|
+
<p>Element Reference—Retrieves the value object corresponding to the key
|
1558
|
+
object. If not found, returns the default value (see Hash::new for
|
1559
|
+
details). the default_proc</p>
|
1560
|
+
|
1561
|
+
|
1562
|
+
</div>
|
1563
|
+
</div>
|
1564
|
+
<div class="tags">
|
1565
|
+
<p class="tag_title">Parameters:</p>
|
1566
|
+
<ul class="param">
|
1567
|
+
|
1568
|
+
<li>
|
1569
|
+
|
1570
|
+
<span class='name'>key</span>
|
1571
|
+
|
1572
|
+
|
1573
|
+
<span class='type'>(<tt>key</tt>)</span>
|
1574
|
+
|
1575
|
+
|
1576
|
+
|
1577
|
+
—
|
1578
|
+
<div class='inline'>
|
1579
|
+
<p>the key to be retrieved</p>
|
1580
|
+
</div>
|
1581
|
+
|
1582
|
+
</li>
|
1583
|
+
|
1584
|
+
</ul>
|
1585
|
+
|
1586
|
+
<p class="tag_title">Returns:</p>
|
1587
|
+
<ul class="return">
|
1588
|
+
|
1589
|
+
<li>
|
1590
|
+
|
1591
|
+
|
1592
|
+
<span class='type'></span>
|
1593
|
+
|
1594
|
+
|
1595
|
+
|
1596
|
+
|
1597
|
+
<div class='inline'>
|
1598
|
+
<p>the value reference by this key or the default value or result of executing</p>
|
1599
|
+
</div>
|
1600
|
+
|
1601
|
+
</li>
|
1602
|
+
|
1603
|
+
</ul>
|
1604
|
+
|
1605
|
+
</div><table class="source_code">
|
1606
|
+
<tr>
|
1607
|
+
<td>
|
1608
|
+
<pre class="lines">
|
1609
|
+
|
1610
|
+
|
1611
|
+
137
|
1612
|
+
138
|
1613
|
+
139
|
1614
|
+
140
|
1615
|
+
141
|
1616
|
+
142
|
1617
|
+
143
|
1618
|
+
144
|
1619
|
+
145
|
1620
|
+
146</pre>
|
1621
|
+
</td>
|
1622
|
+
<td>
|
1623
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 137</span>
|
1624
|
+
|
1625
|
+
<span class='kw'>def</span><span class='op'>[]</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
1626
|
+
|
1627
|
+
<span class='id identifier rubyid_val'>val</span> <span class='op'>=</span> <span class='id identifier rubyid_retrieve'>retrieve</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
1628
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_val'>val</span> <span class='op'>==</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
1629
|
+
<span class='id identifier rubyid_val'>val</span> <span class='op'>=</span> <span class='ivar'>@default</span>
|
1630
|
+
<span class='id identifier rubyid_val'>val</span> <span class='op'>=</span> <span class='ivar'>@default_proc</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='ivar'>@default_proc</span>
|
1631
|
+
<span class='kw'>end</span>
|
1632
|
+
<span class='id identifier rubyid_val'>val</span>
|
1633
|
+
|
1634
|
+
<span class='kw'>end</span></pre>
|
1635
|
+
</td>
|
1636
|
+
</tr>
|
1637
|
+
</table>
|
1638
|
+
</div>
|
1639
|
+
|
1640
|
+
<div class="method_details ">
|
1641
|
+
<h3 class="signature " id="[]=-instance_method">
|
1642
|
+
|
1643
|
+
- (<tt>Object</tt>) <strong>[]=</strong>(key, val)
|
1644
|
+
|
1645
|
+
|
1646
|
+
|
1647
|
+
<span class="aliases">Also known as:
|
1648
|
+
<span class="names"><span id='store-instance_method'>store</span></span>
|
1649
|
+
</span>
|
1650
|
+
|
1651
|
+
|
1652
|
+
|
1653
|
+
</h3><div class="docstring">
|
1654
|
+
<div class="discussion">
|
1655
|
+
|
1656
|
+
<p>Associates the value given by value with the key given by key.</p>
|
1657
|
+
|
1658
|
+
|
1659
|
+
</div>
|
1660
|
+
</div>
|
1661
|
+
<div class="tags">
|
1662
|
+
<p class="tag_title">Parameters:</p>
|
1663
|
+
<ul class="param">
|
1664
|
+
|
1665
|
+
<li>
|
1666
|
+
|
1667
|
+
<span class='name'>key</span>
|
1668
|
+
|
1669
|
+
|
1670
|
+
<span class='type'>(<tt>Key</tt>)</span>
|
1671
|
+
|
1672
|
+
|
1673
|
+
|
1674
|
+
—
|
1675
|
+
<div class='inline'>
|
1676
|
+
<p>the key element</p>
|
1677
|
+
</div>
|
1678
|
+
|
1679
|
+
</li>
|
1680
|
+
|
1681
|
+
<li>
|
1682
|
+
|
1683
|
+
<span class='name'>val</span>
|
1684
|
+
|
1685
|
+
|
1686
|
+
<span class='type'>(<tt>Value</tt>)</span>
|
1687
|
+
|
1688
|
+
|
1689
|
+
|
1690
|
+
—
|
1691
|
+
<div class='inline'>
|
1692
|
+
<p>the value associated with the key</p>
|
1693
|
+
</div>
|
1694
|
+
|
1695
|
+
</li>
|
1696
|
+
|
1697
|
+
</ul>
|
1698
|
+
|
1699
|
+
<p class="tag_title">Returns:</p>
|
1700
|
+
<ul class="return">
|
1701
|
+
|
1702
|
+
<li>
|
1703
|
+
|
1704
|
+
|
1705
|
+
<span class='type'></span>
|
1706
|
+
|
1707
|
+
|
1708
|
+
|
1709
|
+
|
1710
|
+
<div class='inline'>
|
1711
|
+
<p>the value associated with the key</p>
|
1712
|
+
</div>
|
1713
|
+
|
1714
|
+
</li>
|
1715
|
+
|
1716
|
+
</ul>
|
1717
|
+
|
1718
|
+
</div><table class="source_code">
|
1719
|
+
<tr>
|
1720
|
+
<td>
|
1721
|
+
<pre class="lines">
|
1722
|
+
|
1723
|
+
|
1724
|
+
153
|
1725
|
+
154
|
1726
|
+
155
|
1727
|
+
156</pre>
|
1728
|
+
</td>
|
1729
|
+
<td>
|
1730
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 153</span>
|
1731
|
+
|
1732
|
+
<span class='kw'>def</span><span class='op'>[]=</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
|
1733
|
+
<span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='kw'>if</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Symbol</span>
|
1734
|
+
<span class='ivar'>@java_critbit</span><span class='period'>.</span><span class='id identifier rubyid_put'>put</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
|
1735
|
+
<span class='kw'>end</span></pre>
|
1736
|
+
</td>
|
1737
|
+
</tr>
|
1738
|
+
</table>
|
1739
|
+
</div>
|
1740
|
+
|
1741
|
+
<div class="method_details ">
|
1742
|
+
<h3 class="signature " id="assoc-instance_method">
|
1743
|
+
|
1744
|
+
- (<tt>Object</tt>) <strong>assoc</strong>(key)
|
1745
|
+
|
1746
|
+
|
1747
|
+
|
1748
|
+
|
1749
|
+
|
1750
|
+
</h3><div class="docstring">
|
1751
|
+
<div class="discussion">
|
1752
|
+
|
1753
|
+
<p>Searches through the critbit comparing obj with the key using ==. Returns
|
1754
|
+
the key-value pair (two elements array) or nil if no match is found. See
|
1755
|
+
Array#assoc.</p>
|
1756
|
+
|
1757
|
+
|
1758
|
+
</div>
|
1759
|
+
</div>
|
1760
|
+
<div class="tags">
|
1761
|
+
<p class="tag_title">Parameters:</p>
|
1762
|
+
<ul class="param">
|
1763
|
+
|
1764
|
+
<li>
|
1765
|
+
|
1766
|
+
<span class='name'>key</span>
|
1767
|
+
|
1768
|
+
|
1769
|
+
<span class='type'>(<tt>Key</tt>)</span>
|
1770
|
+
|
1771
|
+
|
1772
|
+
|
1773
|
+
—
|
1774
|
+
<div class='inline'>
|
1775
|
+
<p>the key to search for</p>
|
1776
|
+
</div>
|
1777
|
+
|
1778
|
+
</li>
|
1779
|
+
|
1780
|
+
</ul>
|
1781
|
+
|
1782
|
+
<p class="tag_title">Returns:</p>
|
1783
|
+
<ul class="return">
|
1784
|
+
|
1785
|
+
<li>
|
1786
|
+
|
1787
|
+
|
1788
|
+
<span class='type'></span>
|
1789
|
+
|
1790
|
+
|
1791
|
+
|
1792
|
+
|
1793
|
+
<div class='inline'>
|
1794
|
+
<p>Array with two elements [key, value]</p>
|
1795
|
+
</div>
|
1796
|
+
|
1797
|
+
</li>
|
1798
|
+
|
1799
|
+
</ul>
|
1800
|
+
|
1801
|
+
</div><table class="source_code">
|
1802
|
+
<tr>
|
1803
|
+
<td>
|
1804
|
+
<pre class="lines">
|
1805
|
+
|
1806
|
+
|
1807
|
+
166
|
1808
|
+
167
|
1809
|
+
168</pre>
|
1810
|
+
</td>
|
1811
|
+
<td>
|
1812
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 166</span>
|
1813
|
+
|
1814
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_assoc'>assoc</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
1815
|
+
<span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_retrieve'>retrieve</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span><span class='rbracket'>]</span>
|
1816
|
+
<span class='kw'>end</span></pre>
|
1817
|
+
</td>
|
1818
|
+
</tr>
|
1819
|
+
</table>
|
1820
|
+
</div>
|
1821
|
+
|
1822
|
+
<div class="method_details ">
|
1823
|
+
<h3 class="signature " id="clear-instance_method">
|
1824
|
+
|
1825
|
+
- (<tt>Object</tt>) <strong>clear</strong>
|
1826
|
+
|
1827
|
+
|
1828
|
+
|
1829
|
+
|
1830
|
+
|
1831
|
+
</h3><div class="docstring">
|
1832
|
+
<div class="discussion">
|
1833
|
+
|
1834
|
+
<p>Removes all key-value pairs from critbit</p>
|
1835
|
+
|
1836
|
+
|
1837
|
+
</div>
|
1838
|
+
</div>
|
1839
|
+
<div class="tags">
|
1840
|
+
|
1841
|
+
|
1842
|
+
</div><table class="source_code">
|
1843
|
+
<tr>
|
1844
|
+
<td>
|
1845
|
+
<pre class="lines">
|
1846
|
+
|
1847
|
+
|
1848
|
+
172
|
1849
|
+
173
|
1850
|
+
174</pre>
|
1851
|
+
</td>
|
1852
|
+
<td>
|
1853
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 172</span>
|
1854
|
+
|
1855
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_clear'>clear</span>
|
1856
|
+
<span class='ivar'>@java_critbit</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span>
|
1857
|
+
<span class='kw'>end</span></pre>
|
1858
|
+
</td>
|
1859
|
+
</tr>
|
1860
|
+
</table>
|
1861
|
+
</div>
|
1862
|
+
|
1863
|
+
<div class="method_details ">
|
1864
|
+
<h3 class="signature " id="delete-instance_method">
|
1865
|
+
|
1866
|
+
- (<tt>Object</tt>) <strong>delete</strong>(key)
|
1867
|
+
|
1868
|
+
|
1869
|
+
|
1870
|
+
|
1871
|
+
|
1872
|
+
</h3><div class="docstring">
|
1873
|
+
<div class="discussion">
|
1874
|
+
|
1875
|
+
<p>Deletes the key-value pair and returns the value from critbit whose key is
|
1876
|
+
equal to key. If the key is not found, returns the default value. If the
|
1877
|
+
optional code block is given and the key is not found, pass in the key and
|
1878
|
+
return the result of block. to key</p>
|
1879
|
+
|
1880
|
+
|
1881
|
+
</div>
|
1882
|
+
</div>
|
1883
|
+
<div class="tags">
|
1884
|
+
<p class="tag_title">Parameters:</p>
|
1885
|
+
<ul class="param">
|
1886
|
+
|
1887
|
+
<li>
|
1888
|
+
|
1889
|
+
<span class='name'>key</span>
|
1890
|
+
|
1891
|
+
|
1892
|
+
<span class='type'>(<tt>Key</tt>)</span>
|
1893
|
+
|
1894
|
+
|
1895
|
+
|
1896
|
+
</li>
|
1897
|
+
|
1898
|
+
</ul>
|
1899
|
+
|
1900
|
+
<p class="tag_title">Returns:</p>
|
1901
|
+
<ul class="return">
|
1902
|
+
|
1903
|
+
<li>
|
1904
|
+
|
1905
|
+
|
1906
|
+
<span class='type'></span>
|
1907
|
+
|
1908
|
+
|
1909
|
+
|
1910
|
+
|
1911
|
+
<div class='inline'>
|
1912
|
+
<p>the value, the default value, or the result of applying the default block</p>
|
1913
|
+
</div>
|
1914
|
+
|
1915
|
+
</li>
|
1916
|
+
|
1917
|
+
</ul>
|
1918
|
+
|
1919
|
+
</div><table class="source_code">
|
1920
|
+
<tr>
|
1921
|
+
<td>
|
1922
|
+
<pre class="lines">
|
1923
|
+
|
1924
|
+
|
1925
|
+
198
|
1926
|
+
199
|
1927
|
+
200
|
1928
|
+
201
|
1929
|
+
202
|
1930
|
+
203
|
1931
|
+
204
|
1932
|
+
205
|
1933
|
+
206
|
1934
|
+
207
|
1935
|
+
208
|
1936
|
+
209
|
1937
|
+
210</pre>
|
1938
|
+
</td>
|
1939
|
+
<td>
|
1940
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 198</span>
|
1941
|
+
|
1942
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
1943
|
+
|
1944
|
+
<span class='id identifier rubyid_val'>val</span> <span class='op'>=</span> <span class='ivar'>@java_critbit</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
1945
|
+
<span class='comment'># key not found
|
1946
|
+
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_val'>val</span> <span class='op'>==</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
1947
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
1948
|
+
<span class='kw'>yield</span> <span class='id identifier rubyid_key'>key</span>
|
1949
|
+
<span class='kw'>end</span>
|
1950
|
+
<span class='ivar'>@default</span>
|
1951
|
+
<span class='kw'>end</span>
|
1952
|
+
<span class='id identifier rubyid_val'>val</span>
|
1953
|
+
|
1954
|
+
<span class='kw'>end</span></pre>
|
1955
|
+
</td>
|
1956
|
+
</tr>
|
1957
|
+
</table>
|
1958
|
+
</div>
|
1959
|
+
|
1960
|
+
<div class="method_details ">
|
1961
|
+
<h3 class="signature " id="delete_if-instance_method">
|
1962
|
+
|
1963
|
+
- (<tt>Object</tt>) <strong>delete_if</strong>(prefix = nil, &block)
|
1964
|
+
|
1965
|
+
|
1966
|
+
|
1967
|
+
<span class="aliases">Also known as:
|
1968
|
+
<span class="names"><span id='reject!-instance_method'>reject!</span></span>
|
1969
|
+
</span>
|
1970
|
+
|
1971
|
+
|
1972
|
+
|
1973
|
+
</h3><div class="docstring">
|
1974
|
+
<div class="discussion">
|
1975
|
+
|
1976
|
+
<p>Deletes every key-value pair from hsh for which block evaluates to true.</p>
|
1977
|
+
|
1978
|
+
<p>If no block is given, an enumerator is returned instead.</p>
|
1979
|
+
|
1980
|
+
|
1981
|
+
</div>
|
1982
|
+
</div>
|
1983
|
+
<div class="tags">
|
1984
|
+
|
1985
|
+
|
1986
|
+
</div><table class="source_code">
|
1987
|
+
<tr>
|
1988
|
+
<td>
|
1989
|
+
<pre class="lines">
|
1990
|
+
|
1991
|
+
|
1992
|
+
216
|
1993
|
+
217
|
1994
|
+
218
|
1995
|
+
219
|
1996
|
+
220
|
1997
|
+
221
|
1998
|
+
222
|
1999
|
+
223
|
2000
|
+
224
|
2001
|
+
225</pre>
|
2002
|
+
</td>
|
2003
|
+
<td>
|
2004
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 216</span>
|
2005
|
+
|
2006
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_delete_if'>delete_if</span><span class='lparen'>(</span><span class='id identifier rubyid_prefix'>prefix</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2007
|
+
|
2008
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
2009
|
+
<span class='id identifier rubyid_cursor'>cursor</span> <span class='op'>=</span> <span class='const'>Critbit</span><span class='op'>::</span><span class='const'>DeleteCursor</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2010
|
+
<span class='id identifier rubyid__get'>_get</span><span class='lparen'>(</span><span class='id identifier rubyid_cursor'>cursor</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span><span class='rparen'>)</span>
|
2011
|
+
<span class='kw'>else</span>
|
2012
|
+
<span class='id identifier rubyid_to_enum'>to_enum</span><span class='lparen'>(</span><span class='symbol'>:each</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span><span class='rparen'>)</span>
|
2013
|
+
<span class='kw'>end</span>
|
2014
|
+
|
2015
|
+
<span class='kw'>end</span></pre>
|
2016
|
+
</td>
|
2017
|
+
</tr>
|
2018
|
+
</table>
|
2019
|
+
</div>
|
2020
|
+
|
2021
|
+
<div class="method_details ">
|
2022
|
+
<h3 class="signature " id="each-instance_method">
|
2023
|
+
|
2024
|
+
- (<tt>Object</tt>) <strong>each</strong>(prefix = nil, &block)
|
2025
|
+
|
2026
|
+
|
2027
|
+
|
2028
|
+
<span class="aliases">Also known as:
|
2029
|
+
<span class="names"><span id='each_pair-instance_method'>each_pair</span></span>
|
2030
|
+
</span>
|
2031
|
+
|
2032
|
+
|
2033
|
+
|
2034
|
+
</h3><div class="docstring">
|
2035
|
+
<div class="discussion">
|
2036
|
+
|
2037
|
+
<p>Calls block once for each key in critbit, passing the key-value pair as
|
2038
|
+
parameters.</p>
|
2039
|
+
|
2040
|
+
<p>If no block is given, an enumerator is returned instead.</p>
|
2041
|
+
|
2042
|
+
|
2043
|
+
</div>
|
2044
|
+
</div>
|
2045
|
+
<div class="tags">
|
2046
|
+
|
2047
|
+
|
2048
|
+
</div><table class="source_code">
|
2049
|
+
<tr>
|
2050
|
+
<td>
|
2051
|
+
<pre class="lines">
|
2052
|
+
|
2053
|
+
|
2054
|
+
233
|
2055
|
+
234
|
2056
|
+
235
|
2057
|
+
236
|
2058
|
+
237
|
2059
|
+
238
|
2060
|
+
239
|
2061
|
+
240
|
2062
|
+
241
|
2063
|
+
242</pre>
|
2064
|
+
</td>
|
2065
|
+
<td>
|
2066
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 233</span>
|
2067
|
+
|
2068
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='id identifier rubyid_prefix'>prefix</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2069
|
+
|
2070
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
2071
|
+
<span class='id identifier rubyid_cursor'>cursor</span> <span class='op'>=</span> <span class='const'>Critbit</span><span class='op'>::</span><span class='const'>EachCursor</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2072
|
+
<span class='id identifier rubyid__get'>_get</span><span class='lparen'>(</span><span class='id identifier rubyid_cursor'>cursor</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span><span class='rparen'>)</span>
|
2073
|
+
<span class='kw'>else</span>
|
2074
|
+
<span class='id identifier rubyid_to_enum'>to_enum</span><span class='lparen'>(</span><span class='symbol'>:each</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span><span class='rparen'>)</span>
|
2075
|
+
<span class='kw'>end</span>
|
2076
|
+
|
2077
|
+
<span class='kw'>end</span></pre>
|
2078
|
+
</td>
|
2079
|
+
</tr>
|
2080
|
+
</table>
|
2081
|
+
</div>
|
2082
|
+
|
2083
|
+
<div class="method_details ">
|
2084
|
+
<h3 class="signature " id="each_key-instance_method">
|
2085
|
+
|
2086
|
+
- (<tt>Object</tt>) <strong>each_key</strong>(prefix = nil, &block)
|
2087
|
+
|
2088
|
+
|
2089
|
+
|
2090
|
+
|
2091
|
+
|
2092
|
+
</h3><div class="docstring">
|
2093
|
+
<div class="discussion">
|
2094
|
+
|
2095
|
+
<p>Calls block once for each key in critbit, passing the key as a parameter.</p>
|
2096
|
+
|
2097
|
+
<p>If no block is given, an enumerator is returned instead.</p>
|
2098
|
+
|
2099
|
+
|
2100
|
+
</div>
|
2101
|
+
</div>
|
2102
|
+
<div class="tags">
|
2103
|
+
|
2104
|
+
|
2105
|
+
</div><table class="source_code">
|
2106
|
+
<tr>
|
2107
|
+
<td>
|
2108
|
+
<pre class="lines">
|
2109
|
+
|
2110
|
+
|
2111
|
+
251
|
2112
|
+
252
|
2113
|
+
253
|
2114
|
+
254
|
2115
|
+
255
|
2116
|
+
256
|
2117
|
+
257
|
2118
|
+
258
|
2119
|
+
259
|
2120
|
+
260</pre>
|
2121
|
+
</td>
|
2122
|
+
<td>
|
2123
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 251</span>
|
2124
|
+
|
2125
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_each_key'>each_key</span><span class='lparen'>(</span><span class='id identifier rubyid_prefix'>prefix</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2126
|
+
|
2127
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
2128
|
+
<span class='id identifier rubyid_cursor'>cursor</span> <span class='op'>=</span> <span class='const'>Critbit</span><span class='op'>::</span><span class='const'>EachKeyCursor</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2129
|
+
<span class='id identifier rubyid__get'>_get</span><span class='lparen'>(</span><span class='id identifier rubyid_cursor'>cursor</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span><span class='rparen'>)</span>
|
2130
|
+
<span class='kw'>else</span>
|
2131
|
+
<span class='id identifier rubyid_to_enum'>to_enum</span><span class='lparen'>(</span><span class='symbol'>:each</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span><span class='rparen'>)</span>
|
2132
|
+
<span class='kw'>end</span>
|
2133
|
+
|
2134
|
+
<span class='kw'>end</span></pre>
|
2135
|
+
</td>
|
2136
|
+
</tr>
|
2137
|
+
</table>
|
2138
|
+
</div>
|
2139
|
+
|
2140
|
+
<div class="method_details ">
|
2141
|
+
<h3 class="signature " id="each_value-instance_method">
|
2142
|
+
|
2143
|
+
- (<tt>Object</tt>) <strong>each_value</strong>(prefix = nil, &block)
|
2144
|
+
|
2145
|
+
|
2146
|
+
|
2147
|
+
|
2148
|
+
|
2149
|
+
</h3><div class="docstring">
|
2150
|
+
<div class="discussion">
|
2151
|
+
|
2152
|
+
<p>Calls block once for each value in critbit, passing the value as a
|
2153
|
+
parameter.</p>
|
2154
|
+
|
2155
|
+
<p>If no block is given, an enumerator is returned instead.</p>
|
2156
|
+
|
2157
|
+
|
2158
|
+
</div>
|
2159
|
+
</div>
|
2160
|
+
<div class="tags">
|
2161
|
+
|
2162
|
+
|
2163
|
+
</div><table class="source_code">
|
2164
|
+
<tr>
|
2165
|
+
<td>
|
2166
|
+
<pre class="lines">
|
2167
|
+
|
2168
|
+
|
2169
|
+
266
|
2170
|
+
267
|
2171
|
+
268
|
2172
|
+
269
|
2173
|
+
270
|
2174
|
+
271
|
2175
|
+
272
|
2176
|
+
273
|
2177
|
+
274
|
2178
|
+
275</pre>
|
2179
|
+
</td>
|
2180
|
+
<td>
|
2181
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 266</span>
|
2182
|
+
|
2183
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_each_value'>each_value</span><span class='lparen'>(</span><span class='id identifier rubyid_prefix'>prefix</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2184
|
+
|
2185
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
2186
|
+
<span class='id identifier rubyid_cursor'>cursor</span> <span class='op'>=</span> <span class='const'>Critbit</span><span class='op'>::</span><span class='const'>EachValueCursor</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2187
|
+
<span class='id identifier rubyid__get'>_get</span><span class='lparen'>(</span><span class='id identifier rubyid_cursor'>cursor</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span><span class='rparen'>)</span>
|
2188
|
+
<span class='kw'>else</span>
|
2189
|
+
<span class='id identifier rubyid_to_enum'>to_enum</span><span class='lparen'>(</span><span class='symbol'>:each</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span><span class='rparen'>)</span>
|
2190
|
+
<span class='kw'>end</span>
|
2191
|
+
|
2192
|
+
<span class='kw'>end</span></pre>
|
2193
|
+
</td>
|
2194
|
+
</tr>
|
2195
|
+
</table>
|
2196
|
+
</div>
|
2197
|
+
|
2198
|
+
<div class="method_details ">
|
2199
|
+
<h3 class="signature " id="empty?-instance_method">
|
2200
|
+
|
2201
|
+
- (<tt>Boolean</tt>) <strong>empty?</strong>
|
2202
|
+
|
2203
|
+
|
2204
|
+
|
2205
|
+
|
2206
|
+
|
2207
|
+
</h3><div class="docstring">
|
2208
|
+
<div class="discussion">
|
2209
|
+
|
2210
|
+
<p>Returns true if critbit contains no key-value pairs.</p>
|
2211
|
+
|
2212
|
+
|
2213
|
+
</div>
|
2214
|
+
</div>
|
2215
|
+
<div class="tags">
|
2216
|
+
|
2217
|
+
<p class="tag_title">Returns:</p>
|
2218
|
+
<ul class="return">
|
2219
|
+
|
2220
|
+
<li>
|
2221
|
+
|
2222
|
+
|
2223
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
2224
|
+
|
2225
|
+
|
2226
|
+
|
2227
|
+
</li>
|
2228
|
+
|
2229
|
+
</ul>
|
2230
|
+
|
2231
|
+
</div><table class="source_code">
|
2232
|
+
<tr>
|
2233
|
+
<td>
|
2234
|
+
<pre class="lines">
|
2235
|
+
|
2236
|
+
|
2237
|
+
279
|
2238
|
+
280
|
2239
|
+
281</pre>
|
2240
|
+
</td>
|
2241
|
+
<td>
|
2242
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 279</span>
|
2243
|
+
|
2244
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_empty?'>empty?</span>
|
2245
|
+
<span class='ivar'>@size</span> <span class='op'>==</span> <span class='int'>0</span>
|
2246
|
+
<span class='kw'>end</span></pre>
|
2247
|
+
</td>
|
2248
|
+
</tr>
|
2249
|
+
</table>
|
2250
|
+
</div>
|
2251
|
+
|
2252
|
+
<div class="method_details ">
|
2253
|
+
<h3 class="signature " id="eql?-instance_method">
|
2254
|
+
|
2255
|
+
- (<tt>Boolean</tt>) <strong>eql?</strong>(other)
|
2256
|
+
|
2257
|
+
|
2258
|
+
|
2259
|
+
|
2260
|
+
|
2261
|
+
</h3><div class="docstring">
|
2262
|
+
<div class="discussion">
|
2263
|
+
|
2264
|
+
|
2265
|
+
</div>
|
2266
|
+
</div>
|
2267
|
+
<div class="tags">
|
2268
|
+
|
2269
|
+
<p class="tag_title">Returns:</p>
|
2270
|
+
<ul class="return">
|
2271
|
+
|
2272
|
+
<li>
|
2273
|
+
|
2274
|
+
|
2275
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
2276
|
+
|
2277
|
+
|
2278
|
+
|
2279
|
+
</li>
|
2280
|
+
|
2281
|
+
</ul>
|
2282
|
+
|
2283
|
+
</div><table class="source_code">
|
2284
|
+
<tr>
|
2285
|
+
<td>
|
2286
|
+
<pre class="lines">
|
2287
|
+
|
2288
|
+
|
2289
|
+
284
|
2290
|
+
285
|
2291
|
+
286
|
2292
|
+
287
|
2293
|
+
288
|
2294
|
+
289
|
2295
|
+
290
|
2296
|
+
291
|
2297
|
+
292
|
2298
|
+
293
|
2299
|
+
294
|
2300
|
+
295
|
2301
|
+
296
|
2302
|
+
297
|
2303
|
+
298
|
2304
|
+
299
|
2305
|
+
300
|
2306
|
+
301
|
2307
|
+
302
|
2308
|
+
303
|
2309
|
+
304
|
2310
|
+
305
|
2311
|
+
306
|
2312
|
+
307
|
2313
|
+
308
|
2314
|
+
309
|
2315
|
+
310
|
2316
|
+
311
|
2317
|
+
312
|
2318
|
+
313
|
2319
|
+
314
|
2320
|
+
315
|
2321
|
+
316</pre>
|
2322
|
+
</td>
|
2323
|
+
<td>
|
2324
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 284</span>
|
2325
|
+
|
2326
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_eql?'>eql?</span><span class='lparen'>(</span><span class='id identifier rubyid_other'>other</span><span class='rparen'>)</span>
|
2327
|
+
|
2328
|
+
<span class='id identifier rubyid_cr1'>cr1</span> <span class='op'>=</span> <span class='id identifier rubyid_each'>each</span>
|
2329
|
+
<span class='id identifier rubyid_cr2'>cr2</span> <span class='op'>=</span> <span class='id identifier rubyid_other'>other</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span>
|
2330
|
+
|
2331
|
+
<span class='kw'>begin</span>
|
2332
|
+
<span class='id identifier rubyid_p1'>p1</span> <span class='op'>=</span> <span class='id identifier rubyid_cr1'>cr1</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span>
|
2333
|
+
<span class='id identifier rubyid_p2'>p2</span> <span class='op'>=</span> <span class='id identifier rubyid_cr2'>cr2</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span>
|
2334
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_p1'>p1</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='id identifier rubyid_p2'>p2</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_p1'>p1</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='id identifier rubyid_p2'>p2</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
2335
|
+
<span class='kw'>return</span> <span class='kw'>false</span>
|
2336
|
+
<span class='kw'>end</span>
|
2337
|
+
<span class='kw'>rescue</span> <span class='const'>StopIteration</span>
|
2338
|
+
<span class='kw'>break</span>
|
2339
|
+
<span class='kw'>end</span> <span class='kw'>while</span> <span class='kw'>true</span>
|
2340
|
+
|
2341
|
+
<span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='int'>0</span>
|
2342
|
+
<span class='kw'>begin</span>
|
2343
|
+
<span class='id identifier rubyid_cr1'>cr1</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span>
|
2344
|
+
<span class='kw'>rescue</span> <span class='const'>StopIteration</span>
|
2345
|
+
<span class='id identifier rubyid_i'>i</span> <span class='op'>+=</span> <span class='int'>1</span>
|
2346
|
+
<span class='kw'>end</span>
|
2347
|
+
|
2348
|
+
<span class='kw'>begin</span>
|
2349
|
+
<span class='id identifier rubyid_cr2'>cr2</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span>
|
2350
|
+
<span class='kw'>rescue</span> <span class='const'>StopIteration</span>
|
2351
|
+
<span class='id identifier rubyid_i'>i</span> <span class='op'>+=</span> <span class='int'>1</span>
|
2352
|
+
<span class='kw'>end</span>
|
2353
|
+
|
2354
|
+
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id identifier rubyid_i'>i</span> <span class='op'>!=</span> <span class='int'>2</span>
|
2355
|
+
|
2356
|
+
<span class='kw'>return</span> <span class='kw'>true</span>
|
2357
|
+
|
2358
|
+
<span class='kw'>end</span></pre>
|
2359
|
+
</td>
|
2360
|
+
</tr>
|
2361
|
+
</table>
|
2362
|
+
</div>
|
2363
|
+
|
2364
|
+
<div class="method_details ">
|
2365
|
+
<h3 class="signature " id="fetch-instance_method">
|
2366
|
+
|
2367
|
+
- (<tt>Object</tt>) <strong>fetch</strong>(key, default = nil, &block)
|
2368
|
+
|
2369
|
+
|
2370
|
+
|
2371
|
+
|
2372
|
+
|
2373
|
+
</h3><div class="docstring">
|
2374
|
+
<div class="discussion">
|
2375
|
+
|
2376
|
+
<p>Returns a value from the critbit for the given key. If the key can’t be
|
2377
|
+
found, there are several options: With no other arguments, it will raise an
|
2378
|
+
KeyError exception; if default is given, then that will be returned; if the
|
2379
|
+
optional code block is specified, then that will be run and its result
|
2380
|
+
returned.</p>
|
2381
|
+
|
2382
|
+
|
2383
|
+
</div>
|
2384
|
+
</div>
|
2385
|
+
<div class="tags">
|
2386
|
+
|
2387
|
+
|
2388
|
+
</div><table class="source_code">
|
2389
|
+
<tr>
|
2390
|
+
<td>
|
2391
|
+
<pre class="lines">
|
2392
|
+
|
2393
|
+
|
2394
|
+
323
|
2395
|
+
324
|
2396
|
+
325
|
2397
|
+
326
|
2398
|
+
327
|
2399
|
+
328
|
2400
|
+
329
|
2401
|
+
330
|
2402
|
+
331
|
2403
|
+
332
|
2404
|
+
333
|
2405
|
+
334
|
2406
|
+
335
|
2407
|
+
336
|
2408
|
+
337
|
2409
|
+
338
|
2410
|
+
339</pre>
|
2411
|
+
</td>
|
2412
|
+
<td>
|
2413
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 323</span>
|
2414
|
+
|
2415
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_default'>default</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2416
|
+
|
2417
|
+
<span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='kw'>if</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Symbol</span>
|
2418
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='ivar'>@java_critbit</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
2419
|
+
|
2420
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span> <span class='op'>==</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
2421
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_default'>default</span> <span class='op'>!=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
2422
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_default'>default</span>
|
2423
|
+
<span class='kw'>elsif</span> <span class='lparen'>(</span><span class='id identifier rubyid_block_given?'>block_given?</span><span class='rparen'>)</span>
|
2424
|
+
<span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
2425
|
+
<span class='kw'>else</span>
|
2426
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>KeyError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>key '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>' not found</span><span class='tstring_end'>"</span></span>
|
2427
|
+
<span class='kw'>end</span>
|
2428
|
+
<span class='kw'>end</span>
|
2429
|
+
<span class='id identifier rubyid_res'>res</span>
|
2430
|
+
|
2431
|
+
<span class='kw'>end</span></pre>
|
2432
|
+
</td>
|
2433
|
+
</tr>
|
2434
|
+
</table>
|
2435
|
+
</div>
|
2436
|
+
|
2437
|
+
<div class="method_details ">
|
2438
|
+
<h3 class="signature " id="flatten-instance_method">
|
2439
|
+
|
2440
|
+
- (<tt>Object</tt>) <strong>flatten</strong>(level = nil)
|
2441
|
+
|
2442
|
+
|
2443
|
+
|
2444
|
+
|
2445
|
+
|
2446
|
+
</h3><div class="docstring">
|
2447
|
+
<div class="discussion">
|
2448
|
+
|
2449
|
+
<p>Returns a new array that is a one-dimensional flattening of this critbit.
|
2450
|
+
That is, for every key or value that is an array, extract its elements into
|
2451
|
+
the new array. The optional level argument determines the level of
|
2452
|
+
recursion to flatten if the value is a hash. If value is an Array it will
|
2453
|
+
call array.flatten</p>
|
2454
|
+
|
2455
|
+
|
2456
|
+
</div>
|
2457
|
+
</div>
|
2458
|
+
<div class="tags">
|
2459
|
+
|
2460
|
+
|
2461
|
+
</div><table class="source_code">
|
2462
|
+
<tr>
|
2463
|
+
<td>
|
2464
|
+
<pre class="lines">
|
2465
|
+
|
2466
|
+
|
2467
|
+
346
|
2468
|
+
347
|
2469
|
+
348
|
2470
|
+
349
|
2471
|
+
350
|
2472
|
+
351
|
2473
|
+
352
|
2474
|
+
353
|
2475
|
+
354
|
2476
|
+
355
|
2477
|
+
356
|
2478
|
+
357
|
2479
|
+
358
|
2480
|
+
359
|
2481
|
+
360</pre>
|
2482
|
+
</td>
|
2483
|
+
<td>
|
2484
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 346</span>
|
2485
|
+
|
2486
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_flatten'>flatten</span><span class='lparen'>(</span><span class='id identifier rubyid_level'>level</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
2487
|
+
|
2488
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='const'>Array</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
2489
|
+
<span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
2490
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'><<</span> <span class='id identifier rubyid_key'>key</span>
|
2491
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_value'>value</span>
|
2492
|
+
<span class='kw'>when</span> <span class='lparen'>(</span><span class='const'>Array</span> <span class='op'>||</span> <span class='const'>Hash</span> <span class='op'>||</span> <span class='const'>Critbit</span><span class='rparen'>)</span>
|
2493
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_level'>level</span><span class='rparen'>)</span><span class='op'>?</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_concat'>concat</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='lparen'>(</span><span class='id identifier rubyid_level'>level</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_concat'>concat</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='rparen'>)</span>
|
2494
|
+
<span class='kw'>else</span>
|
2495
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:flatten</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='op'>?</span> <span class='id identifier rubyid_res'>res</span> <span class='op'><<</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span> <span class='op'>:</span> <span class='id identifier rubyid_res'>res</span> <span class='op'><<</span> <span class='id identifier rubyid_value'>value</span>
|
2496
|
+
<span class='kw'>end</span>
|
2497
|
+
<span class='kw'>end</span>
|
2498
|
+
<span class='id identifier rubyid_res'>res</span>
|
2499
|
+
|
2500
|
+
<span class='kw'>end</span></pre>
|
2501
|
+
</td>
|
2502
|
+
</tr>
|
2503
|
+
</table>
|
2504
|
+
</div>
|
2505
|
+
|
2506
|
+
<div class="method_details ">
|
2507
|
+
<h3 class="signature " id="has_key?-instance_method">
|
2508
|
+
|
2509
|
+
- (<tt>Boolean</tt>) <strong>has_key?</strong>(key)
|
2510
|
+
|
2511
|
+
|
2512
|
+
|
2513
|
+
<span class="aliases">Also known as:
|
2514
|
+
<span class="names"><span id='include?-instance_method'>include?</span>, <span id='member?-instance_method'>member?</span>, <span id='key?-instance_method'>key?</span></span>
|
2515
|
+
</span>
|
2516
|
+
|
2517
|
+
|
2518
|
+
|
2519
|
+
</h3><div class="docstring">
|
2520
|
+
<div class="discussion">
|
2521
|
+
|
2522
|
+
<p>Returns true if the given key is present in critbit</p>
|
2523
|
+
|
2524
|
+
|
2525
|
+
</div>
|
2526
|
+
</div>
|
2527
|
+
<div class="tags">
|
2528
|
+
|
2529
|
+
<p class="tag_title">Returns:</p>
|
2530
|
+
<ul class="return">
|
2531
|
+
|
2532
|
+
<li>
|
2533
|
+
|
2534
|
+
|
2535
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
2536
|
+
|
2537
|
+
|
2538
|
+
|
2539
|
+
</li>
|
2540
|
+
|
2541
|
+
</ul>
|
2542
|
+
|
2543
|
+
</div><table class="source_code">
|
2544
|
+
<tr>
|
2545
|
+
<td>
|
2546
|
+
<pre class="lines">
|
2547
|
+
|
2548
|
+
|
2549
|
+
364
|
2550
|
+
365
|
2551
|
+
366</pre>
|
2552
|
+
</td>
|
2553
|
+
<td>
|
2554
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 364</span>
|
2555
|
+
|
2556
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
2557
|
+
<span class='ivar'>@java_critbit</span><span class='period'>.</span><span class='id identifier rubyid_containsKey'>containsKey</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
2558
|
+
<span class='kw'>end</span></pre>
|
2559
|
+
</td>
|
2560
|
+
</tr>
|
2561
|
+
</table>
|
2562
|
+
</div>
|
2563
|
+
|
2564
|
+
<div class="method_details ">
|
2565
|
+
<h3 class="signature " id="has_value?-instance_method">
|
2566
|
+
|
2567
|
+
- (<tt>Boolean</tt>) <strong>has_value?</strong>(val)
|
2568
|
+
|
2569
|
+
|
2570
|
+
|
2571
|
+
|
2572
|
+
|
2573
|
+
</h3><div class="docstring">
|
2574
|
+
<div class="discussion">
|
2575
|
+
|
2576
|
+
<p>Returns true if the given value is present for some key in critbit.</p>
|
2577
|
+
|
2578
|
+
|
2579
|
+
</div>
|
2580
|
+
</div>
|
2581
|
+
<div class="tags">
|
2582
|
+
|
2583
|
+
<p class="tag_title">Returns:</p>
|
2584
|
+
<ul class="return">
|
2585
|
+
|
2586
|
+
<li>
|
2587
|
+
|
2588
|
+
|
2589
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
2590
|
+
|
2591
|
+
|
2592
|
+
|
2593
|
+
</li>
|
2594
|
+
|
2595
|
+
</ul>
|
2596
|
+
|
2597
|
+
</div><table class="source_code">
|
2598
|
+
<tr>
|
2599
|
+
<td>
|
2600
|
+
<pre class="lines">
|
2601
|
+
|
2602
|
+
|
2603
|
+
376
|
2604
|
+
377
|
2605
|
+
378</pre>
|
2606
|
+
</td>
|
2607
|
+
<td>
|
2608
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 376</span>
|
2609
|
+
|
2610
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_has_value?'>has_value?</span><span class='lparen'>(</span><span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
|
2611
|
+
<span class='ivar'>@java_critbit</span><span class='period'>.</span><span class='id identifier rubyid_containsValue'>containsValue</span><span class='lparen'>(</span><span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
|
2612
|
+
<span class='kw'>end</span></pre>
|
2613
|
+
</td>
|
2614
|
+
</tr>
|
2615
|
+
</table>
|
2616
|
+
</div>
|
2617
|
+
|
2618
|
+
<div class="method_details ">
|
2619
|
+
<h3 class="signature " id="inspect-instance_method">
|
2620
|
+
|
2621
|
+
- (<tt>Object</tt>) <strong>inspect</strong>
|
2622
|
+
|
2623
|
+
|
2624
|
+
|
2625
|
+
<span class="aliases">Also known as:
|
2626
|
+
<span class="names"><span id='to_s-instance_method'>to_s</span></span>
|
2627
|
+
</span>
|
2628
|
+
|
2629
|
+
|
2630
|
+
|
2631
|
+
</h3><div class="docstring">
|
2632
|
+
<div class="discussion">
|
2633
|
+
|
2634
|
+
<p>Return the contents of this critbit as a string.</p>
|
2635
|
+
|
2636
|
+
|
2637
|
+
</div>
|
2638
|
+
</div>
|
2639
|
+
<div class="tags">
|
2640
|
+
|
2641
|
+
|
2642
|
+
</div><table class="source_code">
|
2643
|
+
<tr>
|
2644
|
+
<td>
|
2645
|
+
<pre class="lines">
|
2646
|
+
|
2647
|
+
|
2648
|
+
382
|
2649
|
+
383
|
2650
|
+
384
|
2651
|
+
385
|
2652
|
+
386
|
2653
|
+
387
|
2654
|
+
388
|
2655
|
+
389
|
2656
|
+
390
|
2657
|
+
391</pre>
|
2658
|
+
</td>
|
2659
|
+
<td>
|
2660
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 382</span>
|
2661
|
+
|
2662
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_inspect'>inspect</span>
|
2663
|
+
|
2664
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>{</span><span class='tstring_end'>"</span></span>
|
2665
|
+
<span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
2666
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>\"=></span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_value'>value</span><span class='embexpr_end'>}</span><span class='tstring_content'>,</span><span class='tstring_end'>"</span></span>
|
2667
|
+
<span class='kw'>end</span>
|
2668
|
+
<span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='op'>-</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'>}</span><span class='tstring_end'>"</span></span>
|
2669
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_res'>res</span>
|
2670
|
+
|
2671
|
+
<span class='kw'>end</span></pre>
|
2672
|
+
</td>
|
2673
|
+
</tr>
|
2674
|
+
</table>
|
2675
|
+
</div>
|
2676
|
+
|
2677
|
+
<div class="method_details ">
|
2678
|
+
<h3 class="signature " id="invert-instance_method">
|
2679
|
+
|
2680
|
+
- (<tt>Object</tt>) <strong>invert</strong>
|
2681
|
+
|
2682
|
+
|
2683
|
+
|
2684
|
+
|
2685
|
+
|
2686
|
+
</h3><div class="docstring">
|
2687
|
+
<div class="discussion">
|
2688
|
+
|
2689
|
+
<p>Returns a new critbit created by using critbit’s values as keys, and the
|
2690
|
+
keys as values.</p>
|
2691
|
+
|
2692
|
+
|
2693
|
+
</div>
|
2694
|
+
</div>
|
2695
|
+
<div class="tags">
|
2696
|
+
|
2697
|
+
|
2698
|
+
</div><table class="source_code">
|
2699
|
+
<tr>
|
2700
|
+
<td>
|
2701
|
+
<pre class="lines">
|
2702
|
+
|
2703
|
+
|
2704
|
+
400
|
2705
|
+
401
|
2706
|
+
402
|
2707
|
+
403
|
2708
|
+
404
|
2709
|
+
405
|
2710
|
+
406
|
2711
|
+
407
|
2712
|
+
408</pre>
|
2713
|
+
</td>
|
2714
|
+
<td>
|
2715
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 400</span>
|
2716
|
+
|
2717
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_invert'>invert</span>
|
2718
|
+
|
2719
|
+
<span class='id identifier rubyid_crit'>crit</span> <span class='op'>=</span> <span class='const'>Critbit</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
2720
|
+
<span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
2721
|
+
<span class='id identifier rubyid_crit'>crit</span><span class='lbracket'>[</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span>
|
2722
|
+
<span class='kw'>end</span>
|
2723
|
+
<span class='id identifier rubyid_crit'>crit</span>
|
2724
|
+
|
2725
|
+
<span class='kw'>end</span></pre>
|
2726
|
+
</td>
|
2727
|
+
</tr>
|
2728
|
+
</table>
|
2729
|
+
</div>
|
2730
|
+
|
2731
|
+
<div class="method_details ">
|
2732
|
+
<h3 class="signature " id="keep_if-instance_method">
|
2733
|
+
|
2734
|
+
- (<tt>Object</tt>) <strong>keep_if</strong>(prefix = nil, &block)
|
2735
|
+
|
2736
|
+
|
2737
|
+
|
2738
|
+
<span class="aliases">Also known as:
|
2739
|
+
<span class="names"><span id='select!-instance_method'>select!</span></span>
|
2740
|
+
</span>
|
2741
|
+
|
2742
|
+
|
2743
|
+
|
2744
|
+
</h3><div class="docstring">
|
2745
|
+
<div class="discussion">
|
2746
|
+
|
2747
|
+
<p>Deletes every key-value pair from critbit for which block evaluates to
|
2748
|
+
false.</p>
|
2749
|
+
|
2750
|
+
|
2751
|
+
</div>
|
2752
|
+
</div>
|
2753
|
+
<div class="tags">
|
2754
|
+
|
2755
|
+
|
2756
|
+
</div><table class="source_code">
|
2757
|
+
<tr>
|
2758
|
+
<td>
|
2759
|
+
<pre class="lines">
|
2760
|
+
|
2761
|
+
|
2762
|
+
412
|
2763
|
+
413
|
2764
|
+
414
|
2765
|
+
415
|
2766
|
+
416
|
2767
|
+
417
|
2768
|
+
418
|
2769
|
+
419
|
2770
|
+
420
|
2771
|
+
421</pre>
|
2772
|
+
</td>
|
2773
|
+
<td>
|
2774
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 412</span>
|
2775
|
+
|
2776
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_keep_if'>keep_if</span><span class='lparen'>(</span><span class='id identifier rubyid_prefix'>prefix</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2777
|
+
|
2778
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
2779
|
+
<span class='id identifier rubyid_cursor'>cursor</span> <span class='op'>=</span> <span class='const'>Critbit</span><span class='op'>::</span><span class='const'>DeleteCursor</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2780
|
+
<span class='id identifier rubyid__get'>_get</span><span class='lparen'>(</span><span class='id identifier rubyid_cursor'>cursor</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span><span class='rparen'>)</span>
|
2781
|
+
<span class='kw'>else</span>
|
2782
|
+
<span class='id identifier rubyid_to_enum'>to_enum</span><span class='lparen'>(</span><span class='symbol'>:each</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span><span class='rparen'>)</span>
|
2783
|
+
<span class='kw'>end</span>
|
2784
|
+
|
2785
|
+
<span class='kw'>end</span></pre>
|
2786
|
+
</td>
|
2787
|
+
</tr>
|
2788
|
+
</table>
|
2789
|
+
</div>
|
2790
|
+
|
2791
|
+
<div class="method_details ">
|
2792
|
+
<h3 class="signature " id="key-instance_method">
|
2793
|
+
|
2794
|
+
- (<tt>Object</tt>) <strong>key</strong>(val)
|
2795
|
+
|
2796
|
+
|
2797
|
+
|
2798
|
+
|
2799
|
+
|
2800
|
+
</h3><div class="docstring">
|
2801
|
+
<div class="discussion">
|
2802
|
+
|
2803
|
+
<p>Returns the key of an occurrence of a given value. If the value is not
|
2804
|
+
found, returns nil.</p>
|
2805
|
+
|
2806
|
+
|
2807
|
+
</div>
|
2808
|
+
</div>
|
2809
|
+
<div class="tags">
|
2810
|
+
|
2811
|
+
|
2812
|
+
</div><table class="source_code">
|
2813
|
+
<tr>
|
2814
|
+
<td>
|
2815
|
+
<pre class="lines">
|
2816
|
+
|
2817
|
+
|
2818
|
+
428
|
2819
|
+
429
|
2820
|
+
430
|
2821
|
+
431
|
2822
|
+
432
|
2823
|
+
433
|
2824
|
+
434
|
2825
|
+
435</pre>
|
2826
|
+
</td>
|
2827
|
+
<td>
|
2828
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 428</span>
|
2829
|
+
|
2830
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_key'>key</span><span class='lparen'>(</span><span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
|
2831
|
+
|
2832
|
+
<span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
2833
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_key'>key</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span> <span class='op'>==</span> <span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
|
2834
|
+
<span class='kw'>end</span>
|
2835
|
+
<span class='kw'>return</span> <span class='kw'>nil</span>
|
2836
|
+
|
2837
|
+
<span class='kw'>end</span></pre>
|
2838
|
+
</td>
|
2839
|
+
</tr>
|
2840
|
+
</table>
|
2841
|
+
</div>
|
2842
|
+
|
2843
|
+
<div class="method_details ">
|
2844
|
+
<h3 class="signature " id="keys-instance_method">
|
2845
|
+
|
2846
|
+
- (<tt>Object</tt>) <strong>keys</strong>(prefix = nil)
|
2847
|
+
|
2848
|
+
|
2849
|
+
|
2850
|
+
|
2851
|
+
|
2852
|
+
</h3><div class="docstring">
|
2853
|
+
<div class="discussion">
|
2854
|
+
|
2855
|
+
<p>Returns a new array populated with the keys from this critbit</p>
|
2856
|
+
|
2857
|
+
|
2858
|
+
</div>
|
2859
|
+
</div>
|
2860
|
+
<div class="tags">
|
2861
|
+
|
2862
|
+
|
2863
|
+
</div><table class="source_code">
|
2864
|
+
<tr>
|
2865
|
+
<td>
|
2866
|
+
<pre class="lines">
|
2867
|
+
|
2868
|
+
|
2869
|
+
439
|
2870
|
+
440
|
2871
|
+
441
|
2872
|
+
442</pre>
|
2873
|
+
</td>
|
2874
|
+
<td>
|
2875
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 439</span>
|
2876
|
+
|
2877
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_keys'>keys</span><span class='lparen'>(</span><span class='id identifier rubyid_prefix'>prefix</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
2878
|
+
<span class='id identifier rubyid_cursor'>cursor</span> <span class='op'>=</span> <span class='const'>Critbit</span><span class='op'>::</span><span class='const'>ListCursor</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='symbol'>:key</span><span class='rparen'>)</span>
|
2879
|
+
<span class='id identifier rubyid__get'>_get</span><span class='lparen'>(</span><span class='id identifier rubyid_cursor'>cursor</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_list'>list</span>
|
2880
|
+
<span class='kw'>end</span></pre>
|
2881
|
+
</td>
|
2882
|
+
</tr>
|
2883
|
+
</table>
|
2884
|
+
</div>
|
2885
|
+
|
2886
|
+
<div class="method_details ">
|
2887
|
+
<h3 class="signature " id="max-instance_method">
|
2888
|
+
|
2889
|
+
- (<tt>Object</tt>) <strong>max</strong>
|
2890
|
+
|
2891
|
+
|
2892
|
+
|
2893
|
+
|
2894
|
+
|
2895
|
+
</h3><div class="docstring">
|
2896
|
+
<div class="discussion">
|
2897
|
+
<hr>
|
2898
|
+
<hr>
|
2899
|
+
|
2900
|
+
|
2901
|
+
</div>
|
2902
|
+
</div>
|
2903
|
+
<div class="tags">
|
2904
|
+
|
2905
|
+
|
2906
|
+
</div><table class="source_code">
|
2907
|
+
<tr>
|
2908
|
+
<td>
|
2909
|
+
<pre class="lines">
|
2910
|
+
|
2911
|
+
|
2912
|
+
546
|
2913
|
+
547
|
2914
|
+
548</pre>
|
2915
|
+
</td>
|
2916
|
+
<td>
|
2917
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 546</span>
|
2918
|
+
|
2919
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_max'>max</span>
|
2920
|
+
<span class='ivar'>@java_critbit</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>
|
2921
|
+
<span class='kw'>end</span></pre>
|
2922
|
+
</td>
|
2923
|
+
</tr>
|
2924
|
+
</table>
|
2925
|
+
</div>
|
2926
|
+
|
2927
|
+
<div class="method_details ">
|
2928
|
+
<h3 class="signature " id="merge-instance_method">
|
2929
|
+
|
2930
|
+
- (<tt>Object</tt>) <strong>merge</strong>(other_critbit, &block)
|
2931
|
+
|
2932
|
+
|
2933
|
+
|
2934
|
+
<span class="aliases">Also known as:
|
2935
|
+
<span class="names"><span id='update-instance_method'>update</span></span>
|
2936
|
+
</span>
|
2937
|
+
|
2938
|
+
|
2939
|
+
|
2940
|
+
</h3><div class="docstring">
|
2941
|
+
<div class="discussion">
|
2942
|
+
|
2943
|
+
<p>Returns a new critbit containing the contents of other_critbit and the
|
2944
|
+
contents of critbit. If no block is specified, the value for entries with
|
2945
|
+
duplicate keys will be that of other_critbit. Otherwise the value for each
|
2946
|
+
duplicate key is determined by calling the block with the key, its value in
|
2947
|
+
critbit and its value in other_critbit.</p>
|
2948
|
+
|
2949
|
+
|
2950
|
+
</div>
|
2951
|
+
</div>
|
2952
|
+
<div class="tags">
|
2953
|
+
|
2954
|
+
|
2955
|
+
</div><table class="source_code">
|
2956
|
+
<tr>
|
2957
|
+
<td>
|
2958
|
+
<pre class="lines">
|
2959
|
+
|
2960
|
+
|
2961
|
+
449
|
2962
|
+
450
|
2963
|
+
451
|
2964
|
+
452
|
2965
|
+
453
|
2966
|
+
454
|
2967
|
+
455
|
2968
|
+
456
|
2969
|
+
457
|
2970
|
+
458
|
2971
|
+
459
|
2972
|
+
460
|
2973
|
+
461
|
2974
|
+
462
|
2975
|
+
463
|
2976
|
+
464</pre>
|
2977
|
+
</td>
|
2978
|
+
<td>
|
2979
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 449</span>
|
2980
|
+
|
2981
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_other_critbit'>other_critbit</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2982
|
+
|
2983
|
+
<span class='id identifier rubyid_crit'>crit</span> <span class='op'>=</span> <span class='const'>Critbit</span><span class='lbracket'>[</span><span class='kw'>self</span><span class='rbracket'>]</span>
|
2984
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_block_given?'>block_given?</span><span class='rparen'>)</span>
|
2985
|
+
<span class='id identifier rubyid_other_critbit'>other_critbit</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
2986
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
2987
|
+
<span class='id identifier rubyid_crit'>crit</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
2988
|
+
<span class='kw'>end</span>
|
2989
|
+
<span class='kw'>else</span>
|
2990
|
+
<span class='id identifier rubyid_other_critbit'>other_critbit</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
2991
|
+
<span class='id identifier rubyid_crit'>crit</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
2992
|
+
<span class='kw'>end</span>
|
2993
|
+
<span class='kw'>end</span>
|
2994
|
+
<span class='id identifier rubyid_crit'>crit</span>
|
2995
|
+
|
2996
|
+
<span class='kw'>end</span></pre>
|
2997
|
+
</td>
|
2998
|
+
</tr>
|
2999
|
+
</table>
|
3000
|
+
</div>
|
3001
|
+
|
3002
|
+
<div class="method_details ">
|
3003
|
+
<h3 class="signature " id="merge!-instance_method">
|
3004
|
+
|
3005
|
+
- (<tt>Object</tt>) <strong>merge!</strong>(other_critbit, &block)
|
3006
|
+
|
3007
|
+
|
3008
|
+
|
3009
|
+
|
3010
|
+
|
3011
|
+
</h3><div class="docstring">
|
3012
|
+
<div class="discussion">
|
3013
|
+
|
3014
|
+
<p>Returns a new critbit containing the contents of other_critbit and the
|
3015
|
+
contents of critbit. If no block is specified, the value for entries with
|
3016
|
+
duplicate keys will be that of other_critbit. Otherwise the value for each
|
3017
|
+
duplicate key is determined by calling the block with the key, its value in
|
3018
|
+
critbit and its value in other_critbit.</p>
|
3019
|
+
|
3020
|
+
|
3021
|
+
</div>
|
3022
|
+
</div>
|
3023
|
+
<div class="tags">
|
3024
|
+
|
3025
|
+
|
3026
|
+
</div><table class="source_code">
|
3027
|
+
<tr>
|
3028
|
+
<td>
|
3029
|
+
<pre class="lines">
|
3030
|
+
|
3031
|
+
|
3032
|
+
473
|
3033
|
+
474
|
3034
|
+
475
|
3035
|
+
476
|
3036
|
+
477
|
3037
|
+
478
|
3038
|
+
479
|
3039
|
+
480
|
3040
|
+
481
|
3041
|
+
482
|
3042
|
+
483
|
3043
|
+
484
|
3044
|
+
485
|
3045
|
+
486
|
3046
|
+
487</pre>
|
3047
|
+
</td>
|
3048
|
+
<td>
|
3049
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 473</span>
|
3050
|
+
|
3051
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='id identifier rubyid_other_critbit'>other_critbit</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
3052
|
+
|
3053
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_block_given?'>block_given?</span><span class='rparen'>)</span>
|
3054
|
+
<span class='id identifier rubyid_other_critbit'>other_critbit</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
3055
|
+
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
3056
|
+
<span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
3057
|
+
<span class='kw'>end</span>
|
3058
|
+
<span class='kw'>else</span>
|
3059
|
+
<span class='id identifier rubyid_other_critbit'>other_critbit</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
3060
|
+
<span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
3061
|
+
<span class='kw'>end</span>
|
3062
|
+
<span class='kw'>end</span>
|
3063
|
+
<span class='kw'>self</span>
|
3064
|
+
|
3065
|
+
<span class='kw'>end</span></pre>
|
3066
|
+
</td>
|
3067
|
+
</tr>
|
3068
|
+
</table>
|
3069
|
+
</div>
|
3070
|
+
|
3071
|
+
<div class="method_details ">
|
3072
|
+
<h3 class="signature " id="min-instance_method">
|
3073
|
+
|
3074
|
+
- (<tt>Object</tt>) <strong>min</strong>
|
3075
|
+
|
3076
|
+
|
3077
|
+
|
3078
|
+
|
3079
|
+
|
3080
|
+
</h3><div class="docstring">
|
3081
|
+
<div class="discussion">
|
3082
|
+
<hr>
|
3083
|
+
<hr>
|
3084
|
+
|
3085
|
+
|
3086
|
+
</div>
|
3087
|
+
</div>
|
3088
|
+
<div class="tags">
|
3089
|
+
|
3090
|
+
|
3091
|
+
</div><table class="source_code">
|
3092
|
+
<tr>
|
3093
|
+
<td>
|
3094
|
+
<pre class="lines">
|
3095
|
+
|
3096
|
+
|
3097
|
+
538
|
3098
|
+
539
|
3099
|
+
540</pre>
|
3100
|
+
</td>
|
3101
|
+
<td>
|
3102
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 538</span>
|
3103
|
+
|
3104
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_min'>min</span>
|
3105
|
+
<span class='ivar'>@java_critbit</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span>
|
3106
|
+
<span class='kw'>end</span></pre>
|
3107
|
+
</td>
|
3108
|
+
</tr>
|
3109
|
+
</table>
|
3110
|
+
</div>
|
3111
|
+
|
3112
|
+
<div class="method_details ">
|
3113
|
+
<h3 class="signature " id="put_all-instance_method">
|
3114
|
+
|
3115
|
+
- (<tt>Object</tt>) <strong>put_all</strong>(other_critbit)
|
3116
|
+
|
3117
|
+
|
3118
|
+
|
3119
|
+
|
3120
|
+
|
3121
|
+
</h3><div class="docstring">
|
3122
|
+
<div class="discussion">
|
3123
|
+
<hr>
|
3124
|
+
|
3125
|
+
<p>Merges the two critbits. Should be significantly faster than method merge.</p>
|
3126
|
+
<hr>
|
3127
|
+
|
3128
|
+
|
3129
|
+
</div>
|
3130
|
+
</div>
|
3131
|
+
<div class="tags">
|
3132
|
+
|
3133
|
+
|
3134
|
+
</div><table class="source_code">
|
3135
|
+
<tr>
|
3136
|
+
<td>
|
3137
|
+
<pre class="lines">
|
3138
|
+
|
3139
|
+
|
3140
|
+
554
|
3141
|
+
555
|
3142
|
+
556</pre>
|
3143
|
+
</td>
|
3144
|
+
<td>
|
3145
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 554</span>
|
3146
|
+
|
3147
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_put_all'>put_all</span><span class='lparen'>(</span><span class='id identifier rubyid_other_critbit'>other_critbit</span><span class='rparen'>)</span>
|
3148
|
+
<span class='ivar'>@java_critbit</span><span class='period'>.</span><span class='id identifier rubyid_putAll'>putAll</span><span class='lparen'>(</span><span class='id identifier rubyid_other_critbit'>other_critbit</span><span class='period'>.</span><span class='id identifier rubyid_java_critbit'>java_critbit</span><span class='rparen'>)</span>
|
3149
|
+
<span class='kw'>end</span></pre>
|
3150
|
+
</td>
|
3151
|
+
</tr>
|
3152
|
+
</table>
|
3153
|
+
</div>
|
3154
|
+
|
3155
|
+
<div class="method_details ">
|
3156
|
+
<h3 class="signature " id="rassoc-instance_method">
|
3157
|
+
|
3158
|
+
- (<tt>Object</tt>) <strong>rassoc</strong>(obj)
|
3159
|
+
|
3160
|
+
|
3161
|
+
|
3162
|
+
|
3163
|
+
|
3164
|
+
</h3><div class="docstring">
|
3165
|
+
<div class="discussion">
|
3166
|
+
|
3167
|
+
<p>Searches through the critbit comparing obj with the value using ==. Returns
|
3168
|
+
the first key-value pair (two-element array) that matches. See also
|
3169
|
+
Array#rassoc.</p>
|
3170
|
+
|
3171
|
+
|
3172
|
+
</div>
|
3173
|
+
</div>
|
3174
|
+
<div class="tags">
|
3175
|
+
|
3176
|
+
|
3177
|
+
</div><table class="source_code">
|
3178
|
+
<tr>
|
3179
|
+
<td>
|
3180
|
+
<pre class="lines">
|
3181
|
+
|
3182
|
+
|
3183
|
+
500
|
3184
|
+
501
|
3185
|
+
502
|
3186
|
+
503
|
3187
|
+
504
|
3188
|
+
505
|
3189
|
+
506
|
3190
|
+
507</pre>
|
3191
|
+
</td>
|
3192
|
+
<td>
|
3193
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 500</span>
|
3194
|
+
|
3195
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_rassoc'>rassoc</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='rparen'>)</span>
|
3196
|
+
|
3197
|
+
<span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
3198
|
+
<span class='kw'>return</span> <span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_obj'>obj</span> <span class='op'>==</span> <span class='id identifier rubyid_value'>value</span>
|
3199
|
+
<span class='kw'>end</span>
|
3200
|
+
<span class='kw'>nil</span>
|
3201
|
+
|
3202
|
+
<span class='kw'>end</span></pre>
|
3203
|
+
</td>
|
3204
|
+
</tr>
|
3205
|
+
</table>
|
3206
|
+
</div>
|
3207
|
+
|
3208
|
+
<div class="method_details ">
|
3209
|
+
<h3 class="signature " id="remove-instance_method">
|
3210
|
+
|
3211
|
+
- (<tt>Object</tt>) <strong>remove</strong>(key)
|
3212
|
+
|
3213
|
+
|
3214
|
+
|
3215
|
+
|
3216
|
+
|
3217
|
+
</h3><div class="docstring">
|
3218
|
+
<div class="discussion">
|
3219
|
+
<hr>
|
3220
|
+
|
3221
|
+
<p>Removes the key value pair from the critbit. If no key is found, nil is
|
3222
|
+
returned.</p>
|
3223
|
+
<hr>
|
3224
|
+
|
3225
|
+
|
3226
|
+
</div>
|
3227
|
+
</div>
|
3228
|
+
<div class="tags">
|
3229
|
+
|
3230
|
+
|
3231
|
+
</div><table class="source_code">
|
3232
|
+
<tr>
|
3233
|
+
<td>
|
3234
|
+
<pre class="lines">
|
3235
|
+
|
3236
|
+
|
3237
|
+
562
|
3238
|
+
563
|
3239
|
+
564</pre>
|
3240
|
+
</td>
|
3241
|
+
<td>
|
3242
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 562</span>
|
3243
|
+
|
3244
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
3245
|
+
<span class='ivar'>@java_critbit</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
3246
|
+
<span class='kw'>end</span></pre>
|
3247
|
+
</td>
|
3248
|
+
</tr>
|
3249
|
+
</table>
|
3250
|
+
</div>
|
3251
|
+
|
3252
|
+
<div class="method_details ">
|
3253
|
+
<h3 class="signature " id="size-instance_method">
|
3254
|
+
|
3255
|
+
- (<tt>Object</tt>) <strong>size</strong>
|
3256
|
+
|
3257
|
+
|
3258
|
+
|
3259
|
+
<span class="aliases">Also known as:
|
3260
|
+
<span class="names"><span id='length-instance_method'>length</span></span>
|
3261
|
+
</span>
|
3262
|
+
|
3263
|
+
|
3264
|
+
|
3265
|
+
</h3><div class="docstring">
|
3266
|
+
<div class="discussion">
|
3267
|
+
<hr>
|
3268
|
+
<hr>
|
3269
|
+
|
3270
|
+
|
3271
|
+
</div>
|
3272
|
+
</div>
|
3273
|
+
<div class="tags">
|
3274
|
+
|
3275
|
+
|
3276
|
+
</div><table class="source_code">
|
3277
|
+
<tr>
|
3278
|
+
<td>
|
3279
|
+
<pre class="lines">
|
3280
|
+
|
3281
|
+
|
3282
|
+
513
|
3283
|
+
514
|
3284
|
+
515</pre>
|
3285
|
+
</td>
|
3286
|
+
<td>
|
3287
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 513</span>
|
3288
|
+
|
3289
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_size'>size</span>
|
3290
|
+
<span class='ivar'>@java_critbit</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
3291
|
+
<span class='kw'>end</span></pre>
|
3292
|
+
</td>
|
3293
|
+
</tr>
|
3294
|
+
</table>
|
3295
|
+
</div>
|
3296
|
+
|
3297
|
+
<div class="method_details ">
|
3298
|
+
<h3 class="signature " id="values-instance_method">
|
3299
|
+
|
3300
|
+
- (<tt>Object</tt>) <strong>values</strong>(prefix = nil)
|
3301
|
+
|
3302
|
+
|
3303
|
+
|
3304
|
+
|
3305
|
+
|
3306
|
+
</h3><div class="docstring">
|
3307
|
+
<div class="discussion">
|
3308
|
+
<hr>
|
3309
|
+
<hr>
|
3310
|
+
|
3311
|
+
|
3312
|
+
</div>
|
3313
|
+
</div>
|
3314
|
+
<div class="tags">
|
3315
|
+
|
3316
|
+
|
3317
|
+
</div><table class="source_code">
|
3318
|
+
<tr>
|
3319
|
+
<td>
|
3320
|
+
<pre class="lines">
|
3321
|
+
|
3322
|
+
|
3323
|
+
523
|
3324
|
+
524
|
3325
|
+
525
|
3326
|
+
526</pre>
|
3327
|
+
</td>
|
3328
|
+
<td>
|
3329
|
+
<pre class="code"><span class="info file"># File 'lib/critbit.rb', line 523</span>
|
3330
|
+
|
3331
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_values'>values</span><span class='lparen'>(</span><span class='id identifier rubyid_prefix'>prefix</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
3332
|
+
<span class='id identifier rubyid_cursor'>cursor</span> <span class='op'>=</span> <span class='const'>Critbit</span><span class='op'>::</span><span class='const'>ListCursor</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='symbol'>:value</span><span class='rparen'>)</span>
|
3333
|
+
<span class='id identifier rubyid__get'>_get</span><span class='lparen'>(</span><span class='id identifier rubyid_cursor'>cursor</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_list'>list</span>
|
3334
|
+
<span class='kw'>end</span></pre>
|
3335
|
+
</td>
|
3336
|
+
</tr>
|
3337
|
+
</table>
|
3338
|
+
</div>
|
3339
|
+
|
3340
|
+
</div>
|
3341
|
+
|
3342
|
+
</div>
|
3343
|
+
|
3344
|
+
<div id="footer">
|
3345
|
+
Generated on Wed Jul 22 14:04:05 2015 by
|
3346
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
3347
|
+
0.8.7.6 (ruby-2.2.2).
|
3348
|
+
</div>
|
3349
|
+
|
3350
|
+
</body>
|
3351
|
+
</html>
|