autoc 1.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES.md +3 -0
- data/README.md +149 -0
- data/cmake/AutoC.cmake +39 -0
- data/lib/autoc/allocators.rb +51 -0
- data/lib/autoc/association.rb +126 -0
- data/lib/autoc/box.rb +311 -0
- data/lib/autoc/cmake.rb +54 -0
- data/lib/autoc/collection.rb +83 -110
- data/lib/autoc/composite.rb +333 -0
- data/lib/autoc/cstring.rb +263 -0
- data/lib/autoc/function.rb +247 -0
- data/lib/autoc/hash_map.rb +328 -0
- data/lib/autoc/hash_set.rb +339 -0
- data/lib/autoc/hashers.rb +102 -0
- data/lib/autoc/list.rb +444 -0
- data/lib/autoc/module.rb +434 -0
- data/lib/autoc/openmp.rb +15 -0
- data/lib/autoc/primitive.rb +27 -0
- data/lib/autoc/ranges.rb +707 -0
- data/lib/autoc/record.rb +247 -0
- data/lib/autoc/scaffold/docs.rb +117 -0
- data/lib/autoc/scaffold/generic_value.rb +86 -0
- data/lib/autoc/scaffold/project.rb +75 -0
- data/lib/autoc/scaffold/test_cstring.rb +113 -0
- data/lib/autoc/scaffold/test_cstring_hash_set.rb +35 -0
- data/lib/autoc/scaffold/test_int_box.rb +22 -0
- data/lib/autoc/scaffold/test_int_hash_set.rb +448 -0
- data/lib/autoc/scaffold/test_int_list.rb +106 -0
- data/lib/autoc/scaffold/test_int_vector.rb +83 -0
- data/lib/autoc/scaffold/test_v2v_hash_map.rb +83 -0
- data/lib/autoc/scaffold/test_value_hash_set.rb +60 -0
- data/lib/autoc/scaffold/test_value_vector.rb +146 -0
- data/{test/test.rb → lib/autoc/scaffold/tests.rb} +179 -158
- data/lib/autoc/scaffold.rb +12 -0
- data/lib/autoc/sequential.rb +99 -0
- data/lib/autoc/set.rb +331 -0
- data/lib/autoc/std.rb +149 -0
- data/lib/autoc/type.rb +93 -531
- data/lib/autoc/vector.rb +290 -0
- data/lib/autoc.rb +4 -35
- metadata +55 -85
- data/.yardopts +0 -4
- data/CHANGES +0 -23
- data/README +0 -28
- data/doc/AutoC/Code.html +0 -523
- data/doc/AutoC/Collection.html +0 -1214
- data/doc/AutoC/HashMap.html +0 -1441
- data/doc/AutoC/HashSet.html +0 -916
- data/doc/AutoC/Iterators/Bidirectional.html +0 -204
- data/doc/AutoC/Iterators/Unidirectional.html +0 -200
- data/doc/AutoC/Iterators.html +0 -126
- data/doc/AutoC/List.html +0 -1039
- data/doc/AutoC/Maps.html +0 -290
- data/doc/AutoC/Module/File.html +0 -415
- data/doc/AutoC/Module/Header.html +0 -437
- data/doc/AutoC/Module/Source.html +0 -707
- data/doc/AutoC/Module.html +0 -948
- data/doc/AutoC/Priority.html +0 -138
- data/doc/AutoC/Queue.html +0 -1172
- data/doc/AutoC/Reference.html +0 -735
- data/doc/AutoC/Sets.html +0 -520
- data/doc/AutoC/String.html +0 -1394
- data/doc/AutoC/TreeMap.html +0 -1565
- data/doc/AutoC/TreeSet.html +0 -1447
- data/doc/AutoC/Type.html +0 -2148
- data/doc/AutoC/UserDefinedType.html +0 -1047
- data/doc/AutoC/Vector.html +0 -987
- data/doc/AutoC.html +0 -331
- data/doc/_index.html +0 -388
- data/doc/class_list.html +0 -51
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -58
- data/doc/css/style.css +0 -481
- data/doc/file.CHANGES.html +0 -117
- data/doc/file.README.html +0 -116
- data/doc/file_list.html +0 -61
- data/doc/frames.html +0 -17
- data/doc/index.html +0 -116
- data/doc/js/app.js +0 -243
- data/doc/js/full_list.js +0 -216
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -1307
- data/doc/top-level-namespace.html +0 -112
- data/lib/autoc/code.rb +0 -237
- data/lib/autoc/collection/hash_map.rb +0 -385
- data/lib/autoc/collection/hash_set.rb +0 -337
- data/lib/autoc/collection/iterator.rb +0 -39
- data/lib/autoc/collection/list.rb +0 -429
- data/lib/autoc/collection/map.rb +0 -41
- data/lib/autoc/collection/queue.rb +0 -517
- data/lib/autoc/collection/set.rb +0 -134
- data/lib/autoc/collection/tree_map.rb +0 -464
- data/lib/autoc/collection/tree_set.rb +0 -611
- data/lib/autoc/collection/vector.rb +0 -336
- data/lib/autoc/string.rb +0 -492
- data/test/test_auto.c +0 -7141
- data/test/test_auto.h +0 -753
- data/test/test_char_string.rb +0 -270
- data/test/test_int_list.rb +0 -35
- data/test/test_int_tree_set.rb +0 -111
- data/test/test_int_vector.rb +0 -34
- data/test/test_value_hash_map.rb +0 -162
- data/test/test_value_hash_set.rb +0 -173
- data/test/test_value_list.rb +0 -193
- data/test/test_value_queue.rb +0 -275
- data/test/test_value_tree_map.rb +0 -176
- data/test/test_value_tree_set.rb +0 -173
- data/test/test_value_vector.rb +0 -155
- data/test/value.rb +0 -80
@@ -1,464 +0,0 @@
|
|
1
|
-
require "autoc/collection"
|
2
|
-
require "autoc/collection/tree_set"
|
3
|
-
|
4
|
-
|
5
|
-
require "autoc/collection/map"
|
6
|
-
|
7
|
-
|
8
|
-
module AutoC
|
9
|
-
|
10
|
-
|
11
|
-
=begin
|
12
|
-
|
13
|
-
TreeMap< *_K_* => *_E_* > is a tree-based ordered random access container holding unique keys with each key having an element bound to it.
|
14
|
-
|
15
|
-
TreeMap is backed by {AutoC::TreeSet} container.
|
16
|
-
|
17
|
-
The collection's C++ counterpart is +std::map<>+ template class.
|
18
|
-
|
19
|
-
== Generated C interface
|
20
|
-
|
21
|
-
=== Collection management
|
22
|
-
|
23
|
-
[cols=2*]
|
24
|
-
|===
|
25
|
-
|*_void_* ~type~Copy(*_Type_* * +dst+, *_Type_* * +src+)
|
26
|
-
|
|
27
|
-
Create a new map +dst+ filled with the contents of +src+.
|
28
|
-
A copy operation is performed on all keys and values in +src+.
|
29
|
-
|
30
|
-
NOTE: Previous contents of +dst+ is overwritten.
|
31
|
-
|
32
|
-
|*_void_* ~type~Ctor(*_Type_* * +self+)
|
33
|
-
|
|
34
|
-
Create a new empty map +self+.
|
35
|
-
|
36
|
-
NOTE: Previous contents of +self+ is overwritten.
|
37
|
-
|
38
|
-
|*_void_* ~type~Dtor(*_Type_* * +self+)
|
39
|
-
|
|
40
|
-
Destroy map +self+.
|
41
|
-
Stored keys and values are destroyed as well by calling the respective destructors.
|
42
|
-
|
43
|
-
|*_int_* ~type~Equal(*_Type_* * +lt+, *_Type_* * +rt+)
|
44
|
-
|
|
45
|
-
Return non-zero value if maps +lt+ and +rt+ are considered equal by contents and zero value otherwise.
|
46
|
-
|
47
|
-
|*_size_t_* ~type~Identify(*_Type_* * +self+)
|
48
|
-
|
|
49
|
-
Return hash code for map +self+.
|
50
|
-
|===
|
51
|
-
|
52
|
-
=== Basic operations
|
53
|
-
|
54
|
-
[cols=2*]
|
55
|
-
|===
|
56
|
-
|*_int_* ~type~ContainsKey(*_Type_* * +self+, *_K_* +key+)
|
57
|
-
|
|
58
|
-
Return non-zero value if map +self+ contains an entry with a key considered equal to the key +key+ and zero value otherwise.
|
59
|
-
|
60
|
-
|*_int_* ~type~Empty(*_Type_* * +self+)
|
61
|
-
|
|
62
|
-
Return non-zero value if map +self+ contains no entries and zero value otherwise.
|
63
|
-
|
64
|
-
|*_E_* ~type~Get(*_Type_* * +self+, *_K_* +key+)
|
65
|
-
|
|
66
|
-
Return a _copy_ of the element in +self+ bound to a key which is considered equal to the key +key+.
|
67
|
-
|
68
|
-
WARNING: +self+ *must* contain such key otherwise the behavior is undefined. See ~type~ContainsKey().
|
69
|
-
|
70
|
-
|*_E_* ~type~PeekLowestElement(*_Type_* * +self+)
|
71
|
-
|
|
72
|
-
Return a _copy_ of an element bound to the lowest key in +self+.
|
73
|
-
|
74
|
-
WARNING: +self+ *must not* be empty otherwise the behavior is undefined. See ~type~Empty().
|
75
|
-
|
76
|
-
|*_K_* ~type~PeekLowestKey(*_Type_* * +self+)
|
77
|
-
|
|
78
|
-
Return a _copy_ of the lowest key in +self+.
|
79
|
-
|
80
|
-
WARNING: +self+ *must not* be empty otherwise the behavior is undefined. See ~type~Empty().
|
81
|
-
|
82
|
-
|*_E_* ~type~PeekHighestElement(*_Type_* * +self+)
|
83
|
-
|
|
84
|
-
Return a _copy_ of an element bound to the highest key in +self+.
|
85
|
-
|
86
|
-
WARNING: +self+ *must not* be empty otherwise the behavior is undefined. See ~type~Empty().
|
87
|
-
|
88
|
-
|*_K_* ~type~PeekHighestKey(*_Type_* * +self+)
|
89
|
-
|
|
90
|
-
Return a _copy_ of the highest key in +self+.
|
91
|
-
|
92
|
-
WARNING: +self+ *must not* be empty otherwise the behavior is undefined. See ~type~Empty().
|
93
|
-
|
94
|
-
|*_void_* ~type~Purge(*_Type_* * +self+)
|
95
|
-
|
|
96
|
-
Remove and destroy all keys and elements stored in +self+.
|
97
|
-
|
98
|
-
|*_int_* ~type~Put(*_Type_* * +self+, *_K_* +key+, *_E_* +value+)
|
99
|
-
|
|
100
|
-
Put a _copy_ of the element +value+ bound to a _copy_ of the key +key+ into +self+
|
101
|
-
*only if* there is no such key in +self+ which is considered equal to +key+.
|
102
|
-
|
103
|
-
Return non-zero value on successful put and zero value otherwise.
|
104
|
-
|
105
|
-
|*_int_* ~type~Replace(*_Type_* * +self+, *_K_* +key+, *_E_* +value+)
|
106
|
-
|
|
107
|
-
If +self+ contains a key which is considered equal to the key +key+,
|
108
|
-
remove and destroy that key along with an element bound to it
|
109
|
-
and put a new pair built of the _copies_ of +key+ and +value+,
|
110
|
-
otherwise no nothing.
|
111
|
-
|
112
|
-
Return non-zero value if the replacement was actually performed and zero value otherwise.
|
113
|
-
|
114
|
-
|*_int_* ~type~Remove(*_Type_* * +self+, *_K_* +key+)
|
115
|
-
|
|
116
|
-
Remove and destroy a key which is considered equal to the key +key+.
|
117
|
-
Destroy an element bound to that key.
|
118
|
-
|
119
|
-
Return non-zero value on successful key/element pair removal and zero value otherwise.
|
120
|
-
|
121
|
-
|*_size_t_* ~type~Size(*_Type_* * +self+)
|
122
|
-
|
|
123
|
-
Return number of key/element pairs stored in +self+.
|
124
|
-
|===
|
125
|
-
|
126
|
-
=== Iteration
|
127
|
-
|
128
|
-
[cols=2*]
|
129
|
-
|===
|
130
|
-
|*_void_* ~it~Ctor(*_IteratorType_* * +it+, *_Type_* * +self+)
|
131
|
-
|
|
132
|
-
Create a new ascending iterator +it+ on map +self+. See ~it~CtorEx().
|
133
|
-
|
134
|
-
NOTE: Previous contents of +it+ is overwritten.
|
135
|
-
|
136
|
-
|*_void_* ~it~CtorEx(*_IteratorType_* * +it+, *_Type_* * +self+, *_int_* +ascending+)
|
137
|
-
|
|
138
|
-
Create a new iterator +it+ on map +self+.
|
139
|
-
Non-zero value of +ascending+ specifies an ascending (+lowest to highest key traversal+) iterator, zero value specifies a descending (+highest to lowest key traversal+) iterator.
|
140
|
-
|
141
|
-
NOTE: Previous contents of +it+ is overwritten.
|
142
|
-
|
143
|
-
|*_int_* ~it~Move(*_IteratorType_* * +it+)
|
144
|
-
|
|
145
|
-
Advance iterator position of +it+ *and* return non-zero value if new position is valid and zero value otherwise.
|
146
|
-
|
147
|
-
|*_K_* ~it~GetKey(*_IteratorType_* * +it+)
|
148
|
-
|
|
149
|
-
Return a _copy_ of the key from a key/value pair pointed to by the iterator +it+.
|
150
|
-
|
151
|
-
WARNING: current position *must* be valid otherwise the behavior is undefined. See ~it~Move().
|
152
|
-
|
153
|
-
|*_E_* ~it~GetElement(*_IteratorType_* * +it+)
|
154
|
-
|
|
155
|
-
Return a _copy_ of the element from a key/element pair pointed to by the iterator +it+.
|
156
|
-
|
157
|
-
WARNING: current position *must* be valid otherwise the behavior is undefined. See ~it~Move().
|
158
|
-
|
159
|
-
|*_E_* ~it~Get(*_IteratorType_* * +it+)
|
160
|
-
|
|
161
|
-
Alias for ~it~GetElement().
|
162
|
-
|===
|
163
|
-
|
164
|
-
=end
|
165
|
-
class TreeMap < Collection
|
166
|
-
|
167
|
-
include Maps
|
168
|
-
|
169
|
-
attr_reader :key
|
170
|
-
|
171
|
-
alias :value :element
|
172
|
-
|
173
|
-
def hash; super ^ key.hash end
|
174
|
-
|
175
|
-
def ==(other) super && key == other.key end
|
176
|
-
|
177
|
-
alias :eql? :==
|
178
|
-
|
179
|
-
def entities; super << key end
|
180
|
-
|
181
|
-
def initialize(type, key_type, value_type, visibility = :public)
|
182
|
-
super(type, value_type, visibility)
|
183
|
-
@key = Type.coerce(key_type)
|
184
|
-
@entry = UserDefinedType.new(:type => entry, :identify => entryIdentify, :equal => entryEqual, :less => entryLess, :copy => entryCopy, :dtor => entryDtor)
|
185
|
-
@set = TreeSet.new(set, @entry, :static)
|
186
|
-
element_requirement(value)
|
187
|
-
key_requirement(key)
|
188
|
-
end
|
189
|
-
|
190
|
-
def copyable?; super && key.copyable? end
|
191
|
-
|
192
|
-
def comparable?; super && key.comparable? end
|
193
|
-
|
194
|
-
def hashable?; super && key.hashable? end
|
195
|
-
|
196
|
-
def write_intf_types(stream)
|
197
|
-
super
|
198
|
-
stream << %$
|
199
|
-
typedef struct #{@entry.type} #{@entry.type};
|
200
|
-
struct #{@entry.type} {
|
201
|
-
#{key.type} key;
|
202
|
-
#{value.type} value;
|
203
|
-
unsigned flags;
|
204
|
-
};
|
205
|
-
$
|
206
|
-
@set.write_intf_types(stream)
|
207
|
-
stream << %$
|
208
|
-
typedef struct #{type} #{type};
|
209
|
-
typedef struct #{it} #{it};
|
210
|
-
struct #{type} {
|
211
|
-
#{@set.type} entries;
|
212
|
-
};
|
213
|
-
struct #{it} {
|
214
|
-
#{@set.it} it;
|
215
|
-
};
|
216
|
-
$
|
217
|
-
end
|
218
|
-
|
219
|
-
def write_intf_decls(stream, declare, define)
|
220
|
-
super
|
221
|
-
stream << %$
|
222
|
-
#{declare} #{key.type} #{peekLowestKey}(#{type_ref});
|
223
|
-
#{declare} #{value.type} #{peekLowestElement}(#{type_ref});
|
224
|
-
#{declare} #{key.type} #{peekHighestKey}(#{type_ref});
|
225
|
-
#{declare} #{value.type} #{peekHighestElement}(#{type_ref});
|
226
|
-
#define #{itCtor}(self, type) #{itCtorEx}(self, type, 1)
|
227
|
-
#{declare} void #{itCtorEx}(#{it_ref}, #{type_ref}, int);
|
228
|
-
$
|
229
|
-
end
|
230
|
-
|
231
|
-
def write_impls(stream, define)
|
232
|
-
super
|
233
|
-
stream << %$
|
234
|
-
#define #{validValue} 1
|
235
|
-
#define #{validKey} 2
|
236
|
-
#define #{ownedValue} 4
|
237
|
-
#define #{ownedKey} 8
|
238
|
-
static #{@entry.type} #{entryKeyOnlyRef}(#{key.type_ref} key) {
|
239
|
-
#{@entry.type} entry;
|
240
|
-
entry.key = *key;
|
241
|
-
entry.flags = #{validKey};
|
242
|
-
return entry;
|
243
|
-
}
|
244
|
-
static #{@entry.type} #{entryKeyValueRef}(#{key.type_ref} key, #{value.type_ref} value) {
|
245
|
-
#{@entry.type} entry;
|
246
|
-
entry.key = *key;
|
247
|
-
entry.value = *value;
|
248
|
-
entry.flags = (#{validKey} | #{validValue});
|
249
|
-
return entry;
|
250
|
-
}
|
251
|
-
#define #{entryEqual}(lt, rt) #{entryEqualRef}(<, &rt)
|
252
|
-
static int #{entryEqualRef}(#{@entry.type}* lt, #{@entry.type}* rt) {
|
253
|
-
return #{key.equal("lt->key", "rt->key")};
|
254
|
-
}
|
255
|
-
#define #{entryLess}(lt, rt) #{entryLessRef}(<, &rt)
|
256
|
-
static int #{entryLessRef}(#{@entry.type}* lt, #{@entry.type}* rt) {
|
257
|
-
return #{key.less("lt->key", "rt->key")};
|
258
|
-
}
|
259
|
-
#define #{entryIdentify}(obj) #{entryIdentifyRef}(&obj)
|
260
|
-
static size_t #{entryIdentifyRef}(#{@entry.type}* entry) {
|
261
|
-
return #{key.identify("entry->key")};
|
262
|
-
}
|
263
|
-
#define #{entryCopy}(dst, src) #{entryCopyRef}(&dst, &src)
|
264
|
-
static void #{entryCopyRef}(#{@entry.type_ref} dst, #{@entry.type_ref} src) {
|
265
|
-
#{assert}(src->flags & #{validKey});
|
266
|
-
dst->flags = (#{validKey} | #{ownedKey});
|
267
|
-
#{key.copy("dst->key", "src->key")};
|
268
|
-
if(src->flags & #{validValue}) {
|
269
|
-
dst->flags |= (#{validValue} | #{ownedValue});
|
270
|
-
#{value.copy("dst->value", "src->value")};
|
271
|
-
}
|
272
|
-
}
|
273
|
-
#define #{entryDtor}(obj) #{entryDtorRef}(&obj)
|
274
|
-
static void #{entryDtorRef}(#{@entry.type}* entry) {
|
275
|
-
#{assert}(entry->flags & #{validKey});
|
276
|
-
if(entry->flags & #{ownedKey}) #{key.dtor("entry->key")};
|
277
|
-
if(entry->flags & #{validValue} && entry->flags & #{ownedValue}) #{value.dtor("entry->value")};
|
278
|
-
}
|
279
|
-
static #{@entry.type_ref} #{itGetEntryRef}(#{it_ref});
|
280
|
-
static int #{containsAllOf}(#{type_ref} self, #{type_ref} other) {
|
281
|
-
#{it} it;
|
282
|
-
#{itCtor}(&it, self);
|
283
|
-
while(#{itMove}(&it)) {
|
284
|
-
int found = 0;
|
285
|
-
#{@entry.type}* e = #{itGetEntryRef}(&it);
|
286
|
-
if(#{containsKey}(other, e->key)) {
|
287
|
-
#{value.type} other_value = #{get}(other, e->key);
|
288
|
-
found = #{value.equal("e->value", "other_value")};
|
289
|
-
#{value.dtor("other_value")};
|
290
|
-
}
|
291
|
-
if(!found) return 0;
|
292
|
-
}
|
293
|
-
return 1;
|
294
|
-
}
|
295
|
-
$
|
296
|
-
@set.write_intf_decls(stream, static, inline)
|
297
|
-
@set.write_impls(stream, static)
|
298
|
-
stream << %$
|
299
|
-
#{define} #{ctor.definition} {
|
300
|
-
#{assert}(self);
|
301
|
-
#{@set.ctor}(&self->entries);
|
302
|
-
}
|
303
|
-
#{define} #{dtor.definition} {
|
304
|
-
#{assert}(self);
|
305
|
-
#{@set.dtor}(&self->entries);
|
306
|
-
}
|
307
|
-
static int #{putEntryRef}(#{type_ref} self, #{@entry.type_ref} entry) {
|
308
|
-
int absent;
|
309
|
-
#{assert}(self);
|
310
|
-
#{assert}(entry);
|
311
|
-
absent = !#{containsKey}(self, entry->key);
|
312
|
-
if(absent) #{@set.put}(&self->entries, *entry);
|
313
|
-
return absent;
|
314
|
-
}
|
315
|
-
#{define} #{copy.definition} {
|
316
|
-
#{it} it;
|
317
|
-
#{assert}(src);
|
318
|
-
#{assert}(dst);
|
319
|
-
#{ctor}(dst);
|
320
|
-
#{itCtor}(&it, src);
|
321
|
-
while(#{itMove}(&it)) {
|
322
|
-
#{@entry.type}* e = #{itGetEntryRef}(&it);
|
323
|
-
#{putEntryRef}(dst, e);
|
324
|
-
}
|
325
|
-
}
|
326
|
-
#{define} #{equal.definition} {
|
327
|
-
#{assert}(lt);
|
328
|
-
#{assert}(rt);
|
329
|
-
return #{size}(lt) == #{size}(rt) && #{containsAllOf}(lt, rt) && #{containsAllOf}(rt, lt);
|
330
|
-
}
|
331
|
-
#{define} #{identify.definition} {
|
332
|
-
#{assert}(self);
|
333
|
-
return #{@set.identify}(&self->entries); /* TODO : make use of the values' hashes */
|
334
|
-
}
|
335
|
-
#{define} void #{purge}(#{type_ref} self) {
|
336
|
-
#{assert}(self);
|
337
|
-
#{@set.purge}(&self->entries);
|
338
|
-
}
|
339
|
-
#{define} size_t #{size}(#{type_ref} self) {
|
340
|
-
#{assert}(self);
|
341
|
-
return #{@set.size}(&self->entries);
|
342
|
-
}
|
343
|
-
#{define} int #{containsKey}(#{type_ref} self, #{key.type} key) {
|
344
|
-
int result;
|
345
|
-
#{@entry.type} entry;
|
346
|
-
#{assert}(self);
|
347
|
-
result = #{@set.contains}(&self->entries, entry = #{entryKeyOnlyRef}(&key));
|
348
|
-
#{@entry.dtor("entry")};
|
349
|
-
return result;
|
350
|
-
}
|
351
|
-
#{define} #{value.type} #{get}(#{type_ref} self, #{key.type} key) {
|
352
|
-
#{value.type} result;
|
353
|
-
#{@entry.type} entry, existing_entry;
|
354
|
-
#{assert}(self);
|
355
|
-
#{assert}(#{containsKey}(self, key));
|
356
|
-
existing_entry = #{@set.get}(&self->entries, entry = #{entryKeyOnlyRef}(&key));
|
357
|
-
#{value.copy("result", "existing_entry.value")};
|
358
|
-
#{@entry.dtor("existing_entry")};
|
359
|
-
#{@entry.dtor("entry")};
|
360
|
-
return result;
|
361
|
-
}
|
362
|
-
#{define} #{key.type} #{peekLowestKey}(#{type_ref} self) {
|
363
|
-
#{key.type} result;
|
364
|
-
#{@set.node}* node;
|
365
|
-
#{assert}(self);
|
366
|
-
#{assert}(!#{empty}(self));
|
367
|
-
node = #{@set.lowestNode}(&self->entries);
|
368
|
-
#{assert}(node);
|
369
|
-
#{key.copy("result", "node->element.key")};
|
370
|
-
return result;
|
371
|
-
}
|
372
|
-
#{define} #{value.type} #{peekLowestElement}(#{type_ref} self) {
|
373
|
-
#{value.type} result;
|
374
|
-
#{@set.node}* node;
|
375
|
-
#{assert}(self);
|
376
|
-
#{assert}(!#{empty}(self));
|
377
|
-
node = #{@set.lowestNode}(&self->entries);
|
378
|
-
#{assert}(node);
|
379
|
-
#{element.copy("result", "node->element.value")};
|
380
|
-
return result;
|
381
|
-
}
|
382
|
-
#{define} #{key.type} #{peekHighestKey}(#{type_ref} self) {
|
383
|
-
#{key.type} result;
|
384
|
-
#{@set.node}* node;
|
385
|
-
#{assert}(self);
|
386
|
-
#{assert}(!#{empty}(self));
|
387
|
-
node = #{@set.highestNode}(&self->entries);
|
388
|
-
#{assert}(node);
|
389
|
-
#{key.copy("result", "node->element.key")};
|
390
|
-
return result;
|
391
|
-
}
|
392
|
-
#{define} #{value.type} #{peekHighestElement}(#{type_ref} self) {
|
393
|
-
#{value.type} result;
|
394
|
-
#{@set.node}* node;
|
395
|
-
#{assert}(self);
|
396
|
-
#{assert}(!#{empty}(self));
|
397
|
-
node = #{@set.highestNode}(&self->entries);
|
398
|
-
#{assert}(node);
|
399
|
-
#{element.copy("result", "node->element.value")};
|
400
|
-
return result;
|
401
|
-
}
|
402
|
-
#{define} int #{put}(#{type_ref} self, #{key.type} key, #{value.type} value) {
|
403
|
-
int result;
|
404
|
-
#{@entry.type} entry;
|
405
|
-
#{assert}(self);
|
406
|
-
entry = #{entryKeyValueRef}(&key, &value);
|
407
|
-
result = #{putEntryRef}(self, &entry);
|
408
|
-
#{@entry.dtor("entry")};
|
409
|
-
return result;
|
410
|
-
}
|
411
|
-
#{define} int #{replace}(#{type_ref} self, #{key.type} key, #{value.type} value) {
|
412
|
-
int result;
|
413
|
-
#{@entry.type} entry;
|
414
|
-
#{assert}(self);
|
415
|
-
entry = #{entryKeyValueRef}(&key, &value);
|
416
|
-
result = #{@set.replace}(&self->entries, entry);
|
417
|
-
#{@entry.dtor("entry")};
|
418
|
-
return result;
|
419
|
-
}
|
420
|
-
#{define} int #{remove}(#{type_ref} self, #{key.type} key) {
|
421
|
-
int result;
|
422
|
-
#{@entry.type} entry;
|
423
|
-
#{assert}(self);
|
424
|
-
result = #{@set.remove}(&self->entries, entry = #{entryKeyOnlyRef}(&key));
|
425
|
-
#{@entry.dtor("entry")};
|
426
|
-
return result;
|
427
|
-
}
|
428
|
-
#{define} void #{itCtorEx}(#{it_ref} self, #{type_ref} map, int ascending) {
|
429
|
-
#{assert}(self);
|
430
|
-
#{assert}(map);
|
431
|
-
#{@set.itCtorEx}(&self->it, &map->entries, ascending);
|
432
|
-
}
|
433
|
-
#{define} int #{itMove}(#{it_ref} self) {
|
434
|
-
#{assert}(self);
|
435
|
-
return #{@set.itMove}(&self->it);
|
436
|
-
}
|
437
|
-
#{define} #{key.type} #{itGetKey}(#{it_ref} self) {
|
438
|
-
#{@entry.type_ref} e;
|
439
|
-
#{key.type} key;
|
440
|
-
#{assert}(self);
|
441
|
-
e = #{itGetEntryRef}(self);
|
442
|
-
#{key.copy("key", "e->key")};
|
443
|
-
return key;
|
444
|
-
}
|
445
|
-
#{define} #{value.type} #{itGetElement}(#{it_ref} self) {
|
446
|
-
#{@entry.type_ref} e;
|
447
|
-
#{value.type} value;
|
448
|
-
#{assert}(self);
|
449
|
-
e = #{itGetEntryRef}(self);
|
450
|
-
#{assert}(e->flags & #{validValue});
|
451
|
-
#{value.copy("value", "e->value")};
|
452
|
-
return value;
|
453
|
-
}
|
454
|
-
static #{@entry.type_ref} #{itGetEntryRef}(#{it_ref} self) {
|
455
|
-
#{assert}(self);
|
456
|
-
return #{@set.itGetRef}(&self->it);
|
457
|
-
}
|
458
|
-
$
|
459
|
-
end
|
460
|
-
|
461
|
-
end # TreeMap
|
462
|
-
|
463
|
-
|
464
|
-
end # AutoC
|