autoc 1.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +4 -0
  3. data/doc/AutoC.html +55 -55
  4. data/doc/AutoC/Code.html +60 -57
  5. data/doc/AutoC/Collection.html +134 -124
  6. data/doc/AutoC/HashMap.html +147 -185
  7. data/doc/AutoC/HashSet.html +114 -325
  8. data/doc/AutoC/Iterators.html +126 -0
  9. data/doc/AutoC/Iterators/Bidirectional.html +204 -0
  10. data/doc/AutoC/Iterators/Unidirectional.html +200 -0
  11. data/doc/AutoC/List.html +81 -76
  12. data/doc/AutoC/Maps.html +290 -0
  13. data/doc/AutoC/Module.html +72 -69
  14. data/doc/AutoC/Module/File.html +55 -52
  15. data/doc/AutoC/Module/Header.html +55 -52
  16. data/doc/AutoC/Module/Source.html +63 -60
  17. data/doc/AutoC/Priority.html +57 -57
  18. data/doc/AutoC/Queue.html +75 -74
  19. data/doc/AutoC/Reference.html +92 -91
  20. data/doc/AutoC/Sets.html +520 -0
  21. data/doc/AutoC/String.html +70 -69
  22. data/doc/AutoC/TreeMap.html +1565 -0
  23. data/doc/AutoC/TreeSet.html +1447 -0
  24. data/doc/AutoC/Type.html +184 -110
  25. data/doc/AutoC/UserDefinedType.html +102 -102
  26. data/doc/AutoC/Vector.html +100 -91
  27. data/doc/_index.html +97 -33
  28. data/doc/class_list.html +24 -31
  29. data/doc/css/full_list.css +32 -31
  30. data/doc/css/style.css +220 -78
  31. data/doc/file.CHANGES.html +37 -30
  32. data/doc/file.README.html +29 -30
  33. data/doc/file_list.html +29 -31
  34. data/doc/frames.html +7 -16
  35. data/doc/index.html +29 -30
  36. data/doc/js/app.js +100 -76
  37. data/doc/js/full_list.js +170 -135
  38. data/doc/method_list.html +877 -431
  39. data/doc/top-level-namespace.html +35 -35
  40. data/lib/autoc.rb +4 -2
  41. data/lib/autoc/collection.rb +10 -4
  42. data/lib/autoc/collection/hash_map.rb +22 -41
  43. data/lib/autoc/collection/hash_set.rb +13 -120
  44. data/lib/autoc/collection/iterator.rb +39 -0
  45. data/lib/autoc/collection/list.rb +7 -5
  46. data/lib/autoc/collection/map.rb +41 -0
  47. data/lib/autoc/collection/queue.rb +8 -8
  48. data/lib/autoc/collection/set.rb +134 -0
  49. data/lib/autoc/collection/tree_map.rb +464 -0
  50. data/lib/autoc/collection/tree_set.rb +611 -0
  51. data/lib/autoc/collection/vector.rb +8 -4
  52. data/lib/autoc/string.rb +1 -1
  53. data/lib/autoc/type.rb +3 -0
  54. data/test/test.rb +2 -2
  55. data/test/test_auto.c +7141 -0
  56. data/test/test_auto.h +753 -0
  57. data/test/test_int_tree_set.rb +111 -0
  58. data/test/test_value_hash_map.rb +1 -1
  59. data/test/test_value_hash_set.rb +1 -1
  60. data/test/test_value_tree_map.rb +176 -0
  61. data/test/test_value_tree_set.rb +173 -0
  62. metadata +21 -5
@@ -1,12 +1,12 @@
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">
1
+ <!DOCTYPE html>
2
+ <html>
4
3
  <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Documentation by YARD 0.8.7.6
9
+ &mdash; Documentation by YARD 0.9.5
10
10
 
11
11
  </title>
12
12
 
@@ -15,9 +15,8 @@
15
15
  <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
16
 
17
17
  <script type="text/javascript" charset="utf-8">
18
- hasFrames = window.top.frames.main ? true : false;
18
+ pathId = "";
19
19
  relpath = '';
20
- framesUrl = "frames.html#!top-level-namespace.html";
21
20
  </script>
22
21
 
23
22
 
@@ -28,58 +27,58 @@
28
27
 
29
28
  </head>
30
29
  <body>
31
- <div id="header">
32
- <div id="menu">
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
33
38
 
34
39
  <a href="_index.html">Index</a> &raquo;
35
40
 
36
41
 
37
42
  <span class="title">Top Level Namespace</span>
38
43
 
39
-
40
- <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
44
  </div>
42
45
 
43
- <div id="search">
46
+ <div id="search">
44
47
 
45
48
  <a class="full_list_link" id="class_list_link"
46
49
  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
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
58
56
  </a>
59
57
 
60
58
  </div>
61
- <div class="clear"></div>
62
- </div>
59
+ <div class="clear"></div>
60
+ </div>
63
61
 
64
- <iframe id="search_frame"></iframe>
62
+ <iframe id="search_frame" src="class_list.html"></iframe>
65
63
 
66
- <div id="content"><h1>Top Level Namespace
64
+ <div id="content"><h1>Top Level Namespace
67
65
 
68
66
 
69
67
 
70
68
  </h1>
69
+ <div class="box_info">
70
+
71
71
 
72
- <dl class="box">
73
72
 
74
73
 
75
-
76
74
 
77
-
78
75
 
79
76
 
77
+
78
+
79
+
80
80
 
81
- </dl>
82
- <div class="clear"></div>
81
+ </div>
83
82
 
84
83
  <h2>Defined Under Namespace</h2>
85
84
  <p class="children">
@@ -102,11 +101,12 @@
102
101
 
103
102
  </div>
104
103
 
105
- <div id="footer">
106
- Generated on Thu Mar 17 13:32:50 2016 by
104
+ <div id="footer">
105
+ Generated on Wed Oct 12 12:27:11 2016 by
107
106
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
- 0.8.7.6 (ruby-2.2.4).
107
+ 0.9.5 (ruby-2.3.1).
109
108
  </div>
110
109
 
110
+ </div>
111
111
  </body>
112
112
  </html>
@@ -22,7 +22,7 @@ Should the major incompatible changes be made, the new release 2.0 will be intro
22
22
 
23
23
  =end
24
24
  module AutoC
25
- VERSION = "1.3"
25
+ VERSION = "1.4"
26
26
  end # AutoC
27
27
 
28
28
 
@@ -34,4 +34,6 @@ require "autoc/collection/list"
34
34
  require "autoc/collection/queue"
35
35
  require "autoc/collection/vector"
36
36
  require "autoc/collection/hash_set"
37
- require "autoc/collection/hash_map"
37
+ require "autoc/collection/hash_map"
38
+ require "autoc/collection/tree_set"
39
+ require "autoc/collection/tree_map"
@@ -13,17 +13,23 @@ module AutoC
13
13
 
14
14
  - {AutoC::Reference} counted reference type
15
15
 
16
+ - {AutoC::String} string builder type with value semantics
17
+
16
18
  == Implemented collections
17
19
 
18
20
  - {AutoC::Vector} resizable array
19
21
 
20
- - {AutoC::List} single linked list
22
+ - {AutoC::List} singly linked list
23
+
24
+ - {AutoC::Queue} doubly linked list
25
+
26
+ - {AutoC::HashSet} hash-based unordered set
21
27
 
22
- - {AutoC::Queue} double linked list
28
+ - {AutoC::HashMap} hash-based unordered map
23
29
 
24
- - {AutoC::HashSet} hash-based set
30
+ - {AutoC::TreeSet} tree-based sorted set
25
31
 
26
- - {AutoC::HashMap} hash-based map
32
+ - {AutoC::TreeMap} tree-based sorted map
27
33
 
28
34
  == Ruby side operation
29
35
 
@@ -2,12 +2,17 @@ require "autoc/collection"
2
2
  require "autoc/collection/hash_set"
3
3
 
4
4
 
5
+ require "autoc/collection/map"
6
+
7
+
5
8
  module AutoC
6
9
 
7
10
 
8
11
  =begin
9
12
 
10
- HashSet is a hash-based unordered random access container holding unique keys with each key having an element bound to it.
13
+ HashMap< *_K_* => *_E_* > is a hash-based unordered random access container holding unique keys with each key having an element bound to it.
14
+
15
+ HashMap is backed by {AutoC::HashSet} container.
11
16
 
12
17
  The collection's C++ counterpart is +std::unordered_map<>+ template class.
13
18
 
@@ -129,6 +134,8 @@ Alias for ~it~GetElement().
129
134
  =end
130
135
  class HashMap < Collection
131
136
 
137
+ include Maps
138
+
132
139
  attr_reader :key
133
140
 
134
141
  alias :value :element
@@ -158,11 +165,6 @@ class HashMap < Collection
158
165
 
159
166
  def write_intf_types(stream)
160
167
  super
161
- stream << %$
162
- /***
163
- **** #{type}<#{key.type},#{value.type}> (#{self.class})
164
- ***/
165
- $ if public?
166
168
  stream << %$
167
169
  typedef struct #{@entry.type} #{@entry.type};
168
170
  struct #{@entry.type} {
@@ -187,45 +189,28 @@ class HashMap < Collection
187
189
  def write_intf_decls(stream, declare, define)
188
190
  super
189
191
  stream << %$
190
- #{declare} #{ctor.declaration};
191
- #{declare} #{dtor.declaration};
192
- #{declare} #{copy.declaration};
193
- #{declare} #{equal.declaration};
194
- #{declare} #{identify.declaration};
195
- #{declare} void #{purge}(#{type_ref});
196
- #{declare} size_t #{size}(#{type_ref});
197
- #define #{empty}(self) (#{size}(self) == 0)
198
- #{declare} int #{containsKey}(#{type_ref}, #{key.type});
199
- #{declare} #{value.type} #{get}(#{type_ref}, #{key.type});
200
- #{declare} int #{put}(#{type_ref}, #{key.type}, #{value.type});
201
- #{declare} int #{replace}(#{type_ref}, #{key.type}, #{value.type});
202
- #{declare} int #{remove}(#{type_ref}, #{key.type});
203
192
  #{declare} void #{itCtor}(#{it_ref}, #{type_ref});
204
- #{declare} int #{itMove}(#{it_ref});
205
- #{declare} #{key.type} #{itGetKey}(#{it_ref});
206
- #{declare} #{value.type} #{itGetElement}(#{it_ref});
207
- #define #{itGet}(it) #{itGetElement}(it)
208
193
  $
209
194
  end
210
195
 
211
196
  def write_impls(stream, define)
212
197
  super
213
198
  stream << %$
214
- #define AUTOC_VALID_VALUE 1
215
- #define AUTOC_VALID_KEY 2
216
- #define AUTOC_OWNED_VALUE 4
217
- #define AUTOC_OWNED_KEY 8
199
+ #define #{validValue} 1
200
+ #define #{validKey} 2
201
+ #define #{ownedValue} 4
202
+ #define #{ownedKey} 8
218
203
  static #{@entry.type} #{entryKeyOnlyRef}(#{key.type_ref} key) {
219
204
  #{@entry.type} entry;
220
205
  entry.key = *key;
221
- entry.flags = AUTOC_VALID_KEY;
206
+ entry.flags = #{validKey};
222
207
  return entry;
223
208
  }
224
209
  static #{@entry.type} #{entryKeyValueRef}(#{key.type_ref} key, #{value.type_ref} value) {
225
210
  #{@entry.type} entry;
226
211
  entry.key = *key;
227
212
  entry.value = *value;
228
- entry.flags = (AUTOC_VALID_KEY | AUTOC_VALID_VALUE);
213
+ entry.flags = (#{validKey} | #{validValue});
229
214
  return entry;
230
215
  }
231
216
  #define #{entryIdentify}(obj) #{entryIdentifyRef}(&obj)
@@ -238,19 +223,19 @@ class HashMap < Collection
238
223
  }
239
224
  #define #{entryCopy}(dst, src) #{entryCopyRef}(&dst, &src)
240
225
  static void #{entryCopyRef}(#{@entry.type_ref} dst, #{@entry.type_ref} src) {
241
- #{assert}(src->flags & AUTOC_VALID_KEY);
242
- dst->flags = (AUTOC_VALID_KEY | AUTOC_OWNED_KEY);
226
+ #{assert}(src->flags & #{validKey});
227
+ dst->flags = (#{validKey} | #{ownedKey});
243
228
  #{key.copy("dst->key", "src->key")};
244
- if(src->flags & AUTOC_VALID_VALUE) {
245
- dst->flags |= (AUTOC_VALID_VALUE | AUTOC_OWNED_VALUE);
229
+ if(src->flags & #{validValue}) {
230
+ dst->flags |= (#{validValue} | #{ownedValue});
246
231
  #{value.copy("dst->value", "src->value")};
247
232
  }
248
233
  }
249
234
  #define #{entryDtor}(obj) #{entryDtorRef}(&obj)
250
235
  static void #{entryDtorRef}(#{@entry.type}* entry) {
251
- #{assert}(entry->flags & AUTOC_VALID_KEY);
252
- if(entry->flags & AUTOC_OWNED_KEY) #{key.dtor("entry->key")};
253
- if(entry->flags & AUTOC_VALID_VALUE && entry->flags & AUTOC_OWNED_VALUE) #{value.dtor("entry->value")};
236
+ #{assert}(entry->flags & #{validKey});
237
+ if(entry->flags & #{ownedKey}) #{key.dtor("entry->key")};
238
+ if(entry->flags & #{validValue} && entry->flags & #{ownedValue}) #{value.dtor("entry->value")};
254
239
  }
255
240
  static #{@entry.type_ref} #{itGetEntryRef}(#{it_ref});
256
241
  static int #{containsAllOf}(#{type_ref} self, #{type_ref} other) {
@@ -383,7 +368,7 @@ class HashMap < Collection
383
368
  #{value.type} value;
384
369
  #{assert}(self);
385
370
  e = #{itGetEntryRef}(self);
386
- #{assert}(e->flags & AUTOC_VALID_VALUE);
371
+ #{assert}(e->flags & #{validValue});
387
372
  #{value.copy("value", "e->value")};
388
373
  return value;
389
374
  }
@@ -391,10 +376,6 @@ class HashMap < Collection
391
376
  #{assert}(self);
392
377
  return #{@set.itGetRef}(&self->it);
393
378
  }
394
- #undef AUTOC_VALID_VALUE
395
- #undef AUTOC_VALID_KEY
396
- #undef AUTOC_OWNED_VALUE
397
- #undef AUTOC_OWNED_KEY
398
379
  $
399
380
  end
400
381
 
@@ -2,12 +2,16 @@ require "autoc/collection"
2
2
  require "autoc/collection/list"
3
3
 
4
4
 
5
+ require "autoc/collection/set"
6
+ require "autoc/collection/iterator"
7
+
8
+
5
9
  module AutoC
6
10
 
7
11
 
8
12
  =begin
9
13
 
10
- HashSet is a hash-based unordered container holding unique elements.
14
+ HashSet< *_E_* > is a hash-based unordered container holding unique elements.
11
15
 
12
16
  The collection's C++ counterpart is +std::unordered_set<>+ template class.
13
17
 
@@ -145,19 +149,21 @@ WARNING: current position *must* be valid otherwise the behavior is undefined. S
145
149
  =end
146
150
  class HashSet < Collection
147
151
 
152
+ include Sets
153
+ include Iterators::Unidirectional
154
+
148
155
  def initialize(*args)
149
156
  super
150
157
  @list = List.new(list, element, :static)
151
158
  key_requirement(element)
152
159
  end
153
160
 
161
+ def write_intf_decls(stream, declare, define)
162
+ super
163
+ end
164
+
154
165
  def write_intf_types(stream)
155
166
  super
156
- stream << %$
157
- /***
158
- **** #{type}<#{element.type}> (#{self.class})
159
- ***/
160
- $ if public?
161
167
  @list.write_intf_types(stream)
162
168
  stream << %$
163
169
  typedef struct #{type} #{type};
@@ -176,38 +182,11 @@ class HashSet < Collection
176
182
  $
177
183
  end
178
184
 
179
- def write_intf_decls(stream, declare, define)
180
- super
181
- stream << %$
182
- #{declare} #{ctor.declaration};
183
- #{declare} #{dtor.declaration};
184
- #{declare} #{copy.declaration};
185
- #{declare} #{equal.declaration};
186
- #{declare} #{identify.declaration};
187
- #{declare} void #{purge}(#{type_ref});
188
- #{declare} int #{contains}(#{type_ref}, #{element.type});
189
- #{declare} #{element.type} #{get}(#{type_ref}, #{element.type});
190
- #{declare} size_t #{size}(#{type_ref});
191
- #define #{empty}(self) (#{size}(self) == 0)
192
- #{declare} int #{put}(#{type_ref}, #{element.type});
193
- #{declare} int #{replace}(#{type_ref}, #{element.type});
194
- #{declare} int #{remove}(#{type_ref}, #{element.type});
195
- #{declare} void #{exclude}(#{type_ref}, #{type_ref});
196
- #{declare} void #{retain}(#{type_ref}, #{type_ref});
197
- #{declare} void #{include}(#{type_ref}, #{type_ref});
198
- #{declare} void #{invert}(#{type_ref}, #{type_ref});
199
- #{declare} void #{itCtor}(#{it_ref}, #{type_ref});
200
- #{declare} int #{itMove}(#{it_ref});
201
- #{declare} #{element.type} #{itGet}(#{it_ref});
202
- $
203
- end
204
-
205
185
  def write_impls(stream, define)
206
- super
207
186
  @list.write_intf_decls(stream, static, inline)
208
187
  @list.write_impls(stream, static)
188
+ super
209
189
  stream << %$
210
- static #{element.type_ref} #{itGetRef}(#{it_ref});
211
190
  static void #{rehash}(#{type_ref} self) {
212
191
  #{@list.type_ref} buckets;
213
192
  size_t index, bucket_count, size, fill;
@@ -254,16 +233,6 @@ class HashSet < Collection
254
233
  self->bucket_count = bucket_count;
255
234
  self->size = size;
256
235
  }
257
- static int #{containsAllOf}(#{type_ref} self, #{type_ref} other) {
258
- #{it} it;
259
- #{itCtor}(&it, self);
260
- while(#{itMove}(&it)) {
261
- int found = 0;
262
- if(#{contains}(other, *#{itGetRef}(&it))) found = 1;
263
- if(!found) return 0;
264
- }
265
- return 1;
266
- }
267
236
  #{define} #{ctor.definition} {
268
237
  #{assert}(self);
269
238
  self->min_bucket_count = 16;
@@ -283,31 +252,6 @@ class HashSet < Collection
283
252
  }
284
253
  #{free}(self->buckets);
285
254
  }
286
- #{define} #{copy.definition} {
287
- #{it} it;
288
- #{assert}(src);
289
- #{assert}(dst);
290
- #{ctor}(dst);
291
- #{itCtor}(&it, src);
292
- while(#{itMove}(&it)) #{put}(dst, *#{itGetRef}(&it));
293
- }
294
- #{define} #{equal.definition} {
295
- #{assert}(lt);
296
- #{assert}(rt);
297
- return #{size}(lt) == #{size}(rt) && #{containsAllOf}(lt, rt) && #{containsAllOf}(rt, lt);
298
- }
299
- #{define} #{identify.definition} {
300
- #{it} it;
301
- size_t result = 0;
302
- #{assert}(self);
303
- #{itCtor}(&it, self);
304
- while(#{itMove}(&it)) {
305
- #{element.type}* e = #{itGetRef}(&it);
306
- result ^= #{element.identify("*e")};
307
- result = AUTOC_RCYCLE(result);
308
- }
309
- return result;
310
- }
311
255
  #{define} void #{purge}(#{type_ref} self) {
312
256
  #{assert}(self);
313
257
  #{dtor}(self);
@@ -325,10 +269,6 @@ class HashSet < Collection
325
269
  result = #{@list.find}(&self->buckets[#{element.identify("element")} % self->bucket_count], element);
326
270
  return result;
327
271
  }
328
- #{define} size_t #{size}(#{type_ref} self) {
329
- #{assert}(self);
330
- return self->size;
331
- }
332
272
  #{define} int #{put}(#{type_ref} self, #{element.type} element) {
333
273
  #{@list.type_ref} bucket;
334
274
  #{assert}(self);
@@ -358,53 +298,6 @@ class HashSet < Collection
358
298
  }
359
299
  return 0;
360
300
  }
361
- #{define} void #{exclude}(#{type_ref} self, #{type_ref} other) {
362
- #{it} it;
363
- #{assert}(self);
364
- #{assert}(other);
365
- #{itCtor}(&it, other);
366
- while(#{itMove}(&it)) #{remove}(self, *#{itGetRef}(&it));
367
- }
368
- #{define} void #{include}(#{type_ref} self, #{type_ref} other) {
369
- #{it} it;
370
- #{assert}(self);
371
- #{assert}(other);
372
- #{itCtor}(&it, other);
373
- while(#{itMove}(&it)) #{put}(self, *#{itGetRef}(&it));
374
- }
375
- #{define} void #{retain}(#{type_ref} self, #{type_ref} other) {
376
- #{it} it;
377
- #{type} set;
378
- #{assert}(self);
379
- #{assert}(other);
380
- #{ctor}(&set);
381
- #{itCtor}(&it, self);
382
- while(#{itMove}(&it)) {
383
- #{element.type}* e = #{itGetRef}(&it);
384
- if(#{contains}(other, *e)) #{put}(&set, *e);
385
- }
386
- #{dtor}(self);
387
- *self = set;
388
- }
389
- #{define} void #{invert}(#{type_ref} self, #{type_ref} other) {
390
- #{it} it;
391
- #{type} set;
392
- #{assert}(self);
393
- #{assert}(other);
394
- #{ctor}(&set);
395
- #{itCtor}(&it, self);
396
- while(#{itMove}(&it)) {
397
- #{element.type}* e = #{itGetRef}(&it);
398
- if(!#{contains}(other, *e)) #{put}(&set, *e);
399
- }
400
- #{itCtor}(&it, other);
401
- while(#{itMove}(&it)) {
402
- #{element.type}* e = #{itGetRef}(&it);
403
- if(!#{contains}(self, *e)) #{put}(&set, *e);
404
- }
405
- #{dtor}(self);
406
- *self = set;
407
- }
408
301
  #{define} void #{itCtor}(#{it_ref} self, #{type_ref} set) {
409
302
  #{assert}(self);
410
303
  self->set = set;