fast_trie 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +2 -2
- data/ext/trie/trie.c +15 -15
- metadata +3 -12
- data/ext/darray.o +0 -0
- data/ext/fileutils.o +0 -0
- data/ext/tail.o +0 -0
- data/ext/trie-private.o +0 -0
- data/ext/trie.bundle +0 -0
- data/ext/trie.o +0 -0
data/VERSION.yml
CHANGED
data/ext/trie/trie.c
CHANGED
@@ -81,7 +81,7 @@ static VALUE rb_trie_has_key(VALUE self, VALUE key) {
|
|
81
81
|
Trie *trie;
|
82
82
|
Data_Get_Struct(self, Trie, trie);
|
83
83
|
|
84
|
-
if(trie_has_key(trie, (TrieChar*)
|
84
|
+
if(trie_has_key(trie, (TrieChar*)RSTRING_PTR(key)))
|
85
85
|
return Qtrue;
|
86
86
|
else
|
87
87
|
return Qnil;
|
@@ -102,7 +102,7 @@ static VALUE rb_trie_get(VALUE self, VALUE key) {
|
|
102
102
|
Data_Get_Struct(self, Trie, trie);
|
103
103
|
|
104
104
|
TrieData data;
|
105
|
-
if(trie_retrieve(trie, (TrieChar*)
|
105
|
+
if(trie_retrieve(trie, (TrieChar*)RSTRING_PTR(key), &data))
|
106
106
|
return (VALUE)data;
|
107
107
|
else
|
108
108
|
return Qnil;
|
@@ -120,17 +120,17 @@ static VALUE rb_trie_add(VALUE self, VALUE args) {
|
|
120
120
|
Trie *trie;
|
121
121
|
Data_Get_Struct(self, Trie, trie);
|
122
122
|
|
123
|
-
int size =
|
123
|
+
int size = RARRAY_LEN(args);
|
124
124
|
if(size < 1 || size > 2)
|
125
125
|
return Qnil;
|
126
126
|
|
127
127
|
VALUE key;
|
128
|
-
key =
|
128
|
+
key = RARRAY_PTR(args)[0];
|
129
129
|
StringValue(key);
|
130
130
|
|
131
|
-
TrieData value = size == 2 ?
|
131
|
+
TrieData value = size == 2 ? RARRAY_PTR(args)[1] : TRIE_DATA_ERROR;
|
132
132
|
|
133
|
-
if(trie_store(trie, (TrieChar*)
|
133
|
+
if(trie_store(trie, (TrieChar*)RSTRING_PTR(key), value))
|
134
134
|
return Qtrue;
|
135
135
|
else
|
136
136
|
return Qnil;
|
@@ -149,7 +149,7 @@ static VALUE rb_trie_delete(VALUE self, VALUE key) {
|
|
149
149
|
Trie *trie;
|
150
150
|
Data_Get_Struct(self, Trie, trie);
|
151
151
|
|
152
|
-
if(trie_delete(trie, (TrieChar*)
|
152
|
+
if(trie_delete(trie, (TrieChar*)RSTRING_PTR(key)))
|
153
153
|
return Qtrue;
|
154
154
|
else
|
155
155
|
return Qnil;
|
@@ -195,10 +195,10 @@ static VALUE rb_trie_children(VALUE self, VALUE prefix) {
|
|
195
195
|
Trie *trie;
|
196
196
|
Data_Get_Struct(self, Trie, trie);
|
197
197
|
|
198
|
-
int prefix_size =
|
198
|
+
int prefix_size = RSTRING_LEN(prefix);
|
199
199
|
TrieState *state = trie_root(trie);
|
200
200
|
VALUE children = rb_ary_new();
|
201
|
-
TrieChar *char_prefix = (TrieChar*)
|
201
|
+
TrieChar *char_prefix = (TrieChar*)RSTRING_PTR(prefix);
|
202
202
|
|
203
203
|
const TrieChar *iterator = char_prefix;
|
204
204
|
while(*iterator != 0) {
|
@@ -273,8 +273,8 @@ static VALUE rb_trie_children_with_values(VALUE self, VALUE prefix) {
|
|
273
273
|
Trie *trie;
|
274
274
|
Data_Get_Struct(self, Trie, trie);
|
275
275
|
|
276
|
-
int prefix_size =
|
277
|
-
TrieChar *char_prefix = (TrieChar*)
|
276
|
+
int prefix_size = RSTRING_LEN(prefix);
|
277
|
+
TrieChar *char_prefix = (TrieChar*)RSTRING_PTR(prefix);
|
278
278
|
|
279
279
|
VALUE children = rb_ary_new();
|
280
280
|
|
@@ -398,10 +398,10 @@ static VALUE rb_trie_node_walk_bang(VALUE self, VALUE rchar) {
|
|
398
398
|
TrieState *state;
|
399
399
|
Data_Get_Struct(self, TrieState, state);
|
400
400
|
|
401
|
-
if(
|
401
|
+
if(RSTRING_LEN(rchar) != 1)
|
402
402
|
return Qnil;
|
403
403
|
|
404
|
-
Bool result = trie_state_walk(state, *
|
404
|
+
Bool result = trie_state_walk(state, *RSTRING_PTR(rchar));
|
405
405
|
|
406
406
|
if(result) {
|
407
407
|
rb_iv_set(self, "@state", rchar);
|
@@ -429,10 +429,10 @@ static VALUE rb_trie_node_walk(VALUE self, VALUE rchar) {
|
|
429
429
|
TrieState *state;
|
430
430
|
Data_Get_Struct(new_node, TrieState, state);
|
431
431
|
|
432
|
-
if(
|
432
|
+
if(RSTRING_LEN(rchar) != 1)
|
433
433
|
return Qnil;
|
434
434
|
|
435
|
-
Bool result = trie_state_walk(state, *
|
435
|
+
Bool result = trie_state_walk(state, *RSTRING_PTR(rchar));
|
436
436
|
|
437
437
|
if(result) {
|
438
438
|
rb_iv_set(new_node, "@state", rchar);
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_trie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 15
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
|
-
-
|
7
|
+
- 5
|
9
8
|
- 0
|
10
|
-
version: 0.
|
9
|
+
version: 0.5.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Tyler McMullen
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-12-21 00:00:00 -08:00
|
19
18
|
default_executable:
|
20
19
|
dependencies: []
|
21
20
|
|
@@ -31,12 +30,6 @@ extra_rdoc_files:
|
|
31
30
|
files:
|
32
31
|
- README.textile
|
33
32
|
- VERSION.yml
|
34
|
-
- ext/darray.o
|
35
|
-
- ext/fileutils.o
|
36
|
-
- ext/tail.o
|
37
|
-
- ext/trie-private.o
|
38
|
-
- ext/trie.bundle
|
39
|
-
- ext/trie.o
|
40
33
|
- ext/trie/darray.c
|
41
34
|
- ext/trie/darray.h
|
42
35
|
- ext/trie/extconf.rb
|
@@ -73,7 +66,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
66
|
requirements:
|
74
67
|
- - ">="
|
75
68
|
- !ruby/object:Gem::Version
|
76
|
-
hash: 3
|
77
69
|
segments:
|
78
70
|
- 0
|
79
71
|
version: "0"
|
@@ -82,7 +74,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
74
|
requirements:
|
83
75
|
- - ">="
|
84
76
|
- !ruby/object:Gem::Version
|
85
|
-
hash: 3
|
86
77
|
segments:
|
87
78
|
- 0
|
88
79
|
version: "0"
|
data/ext/darray.o
DELETED
Binary file
|
data/ext/fileutils.o
DELETED
Binary file
|
data/ext/tail.o
DELETED
Binary file
|
data/ext/trie-private.o
DELETED
Binary file
|
data/ext/trie.bundle
DELETED
Binary file
|
data/ext/trie.o
DELETED
Binary file
|