YkESet 0.99.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.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/CODE_OF_CONDUCT.md +74 -0
  3. data/Gemfile +7 -0
  4. data/LICENSE +21 -0
  5. data/README.md +68 -0
  6. data/Rakefile +13 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +8 -0
  9. data/docs/Yk/EMMap/Iterator.html +626 -0
  10. data/docs/Yk/EMMap.html +1504 -0
  11. data/docs/Yk/EMSet/Iterator.html +626 -0
  12. data/docs/Yk/EMSet.html +1472 -0
  13. data/docs/Yk/EMap/Iterator.html +626 -0
  14. data/docs/Yk/EMap.html +1730 -0
  15. data/docs/Yk/ESet/Iterator.html +626 -0
  16. data/docs/Yk/ESet.html +1472 -0
  17. data/docs/Yk.html +126 -0
  18. data/docs/_index.html +170 -0
  19. data/docs/class_list.html +51 -0
  20. data/docs/css/common.css +1 -0
  21. data/docs/css/full_list.css +58 -0
  22. data/docs/css/style.css +496 -0
  23. data/docs/file_list.html +51 -0
  24. data/docs/frames.html +17 -0
  25. data/docs/index.html +170 -0
  26. data/docs/js/app.js +314 -0
  27. data/docs/js/full_list.js +216 -0
  28. data/docs/js/jquery.js +4 -0
  29. data/docs/method_list.html +571 -0
  30. data/docs/top-level-namespace.html +110 -0
  31. data/eset.gemspec +29 -0
  32. data/ext/Yk/.ruby-version +1 -0
  33. data/ext/Yk/.yardoc/checksums +1 -0
  34. data/ext/Yk/.yardoc/complete +0 -0
  35. data/ext/Yk/.yardoc/object_types +0 -0
  36. data/ext/Yk/.yardoc/objects/root.dat +0 -0
  37. data/ext/Yk/.yardoc/proxy_types +0 -0
  38. data/ext/Yk/Makefile +267 -0
  39. data/ext/Yk/depend +2 -0
  40. data/ext/Yk/extconf.rb +7 -0
  41. data/ext/Yk/for_yard.rb +192 -0
  42. data/ext/Yk/for_yard_product.rb +397 -0
  43. data/ext/Yk/map_tz +78 -0
  44. data/ext/Yk/set_tz +77 -0
  45. data/ext/Yk/stl_map_tz.h +1026 -0
  46. data/ext/Yk/stl_multimap_tz.h +927 -0
  47. data/ext/Yk/stl_multiset_tz.h +805 -0
  48. data/ext/Yk/stl_set_tz.h +815 -0
  49. data/ext/Yk/stl_set_tz_ruby.cpp +575 -0
  50. data/ext/Yk/stl_tree_tz.h +1865 -0
  51. data/ext/Yk/test_set.rb +115 -0
  52. data/ext/Yk/tree_tz.cc +489 -0
  53. data/ext/Yk/tz_stl_auto.cpp +84 -0
  54. data/lib/eset/version.rb +3 -0
  55. data/lib/eset.rb +7 -0
  56. metadata +101 -0
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ GC::Profiler.enable
4
+ #require 'tz/eset'
5
+ if File.exists? './ESet.so'
6
+ require './ESet'
7
+ else
8
+ require 'Yk/ESet'
9
+ end
10
+ #require 'tz/debug2'
11
+
12
+ include Yk
13
+
14
+ class Item
15
+ attr :time, :f, :cnt
16
+ @@cnt = 0
17
+ def initialize f
18
+ @cnt = @@cnt
19
+ @@cnt += 1
20
+ @time = Time.now
21
+ @f = f
22
+ # p [self]
23
+ end
24
+ def < arg
25
+ # p arg
26
+ # p [arg]
27
+ # p [self, arg]
28
+ @f < arg.f
29
+ end
30
+ end
31
+
32
+
33
+ def main
34
+ s = ESet.new do |o|
35
+ # p o.f
36
+ o
37
+ end
38
+
39
+
40
+ p s.insert Item.new(rand)
41
+ p s.insert Item.new(rand)
42
+ p s.insert Item.new(rand)
43
+ p s.insert Item.new(rand)
44
+ p s.insert Item.new(rand)
45
+ p s.insert Item.new(rand)
46
+ ai = s.insert Item.new(r = rand)
47
+ bi = s.insert Item.new(r)
48
+ p ai
49
+ p bi
50
+ p ai[0] == bi[0]
51
+ p s.insert Item.new(rand)
52
+ p ai
53
+ p s.begin.item.f
54
+ p s.begin.inc.item.f
55
+ p 200
56
+ aj = s.upper_bound Item.new(0.5);
57
+ ak = s.lower_bound Item.new(0.5);
58
+ p ak
59
+ p ak.item
60
+ it = s.begin
61
+ while it != s.end
62
+ toOut = it.item.f.to_s
63
+ toOut += case it
64
+ when aj
65
+ "\t:upper_bound"
66
+ when ak
67
+ "\t:lower_bound"
68
+ else
69
+ ""
70
+ end
71
+ print toOut + "\n"
72
+ it.inc
73
+ end
74
+ ESet.for_each s.begin, s.end do |o|
75
+ p [o.f]
76
+ end
77
+
78
+
79
+
80
+
81
+
82
+ end
83
+
84
+ main
85
+
86
+ class Foo
87
+ attr :f
88
+ def initialize f
89
+ @f = f
90
+ end
91
+ end
92
+
93
+ s = ESet.new
94
+ s = ESet.new do |o|
95
+ o.f
96
+ end
97
+
98
+ s.insert Foo.new(rand)
99
+ s.insert Foo.new(rand)
100
+ s.insert Foo.new(rand)
101
+ s.insert Foo.new(rand)
102
+
103
+ ESet.for_each s.begin, s.end do |foo|
104
+ p foo.f
105
+ end
106
+
107
+ it = s.begin
108
+ while it != s.end
109
+ p it.item
110
+ it.inc
111
+ end
112
+
113
+
114
+
115
+
data/ext/Yk/tree_tz.cc ADDED
@@ -0,0 +1,489 @@
1
+ // RB tree utilities implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003-2013 Free Software Foundation, Inc.
4
+ //
5
+ // This file is part of the GNU ISO C++ Library. This library is free
6
+ // software; you can redistribute it and/or modify it under the
7
+ // terms of the GNU General Public License as published by the
8
+ // Free Software Foundation; either version 3, or (at your option)
9
+ // any later version.
10
+
11
+ // This library is distributed in the hope that it will be useful,
12
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ // GNU General Public License for more details.
15
+
16
+ // Under Section 7 of GPL version 3, you are granted additional
17
+ // permissions described in the GCC Runtime Library Exception, version
18
+ // 3.1, as published by the Free Software Foundation.
19
+
20
+ // You should have received a copy of the GNU General Public License and
21
+ // a copy of the GCC Runtime Library Exception along with this program;
22
+ // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23
+ // <http://www.gnu.org/licenses/>.
24
+
25
+ /*
26
+ *
27
+ * Copyright (c) 1996,1997
28
+ * Silicon Graphics Computer Systems, Inc.
29
+ *
30
+ * Permission to use, copy, modify, distribute and sell this software
31
+ * and its documentation for any purpose is hereby granted without fee,
32
+ * provided that the above copyright notice appear in all copies and
33
+ * that both that copyright notice and this permission notice appear
34
+ * in supporting documentation. Silicon Graphics makes no
35
+ * representations about the suitability of this software for any
36
+ * purpose. It is provided "as is" without express or implied warranty.
37
+ *
38
+ *
39
+ * Copyright (c) 1994
40
+ * Hewlett-Packard Company
41
+ *
42
+ * Permission to use, copy, modify, distribute and sell this software
43
+ * and its documentation for any purpose is hereby granted without fee,
44
+ * provided that the above copyright notice appear in all copies and
45
+ * that both that copyright notice and this permission notice appear
46
+ * in supporting documentation. Hewlett-Packard Company makes no
47
+ * representations about the suitability of this software for any
48
+ * purpose. It is provided "as is" without express or implied warranty.
49
+ *
50
+ *
51
+ * Copyright (c) 2020
52
+ *
53
+ * Yougaein@github (Kokeji Yougain)
54
+ *
55
+ */
56
+ #include <iostream>
57
+ #include "stl_tree_tz.h"
58
+
59
+ namespace tz _GLIBCXX_VISIBILITY(default)
60
+ {
61
+ _GLIBCXX_BEGIN_NAMESPACE_VERSION
62
+ using namespace std;
63
+
64
+ static _Rb_tree_node_base*
65
+ local_Rb_tree_increment(_Rb_tree_node_base* __x) throw ()
66
+ {
67
+ _Rb_tree_node_base* prev = __x;
68
+ if(__x->_M_left == __x && __x->_M_right == __x && (__x->_M_parent == __x || __x->_M_parent == 0))
69
+ return __x;
70
+ if (__x->_M_right != 0)
71
+ {
72
+ __x = __x->_M_right;
73
+ while (__x->_M_left != 0)
74
+ __x = __x->_M_left;
75
+ }
76
+ else
77
+ {
78
+ _Rb_tree_node_base* __y = __x->_M_parent;
79
+ if(__y){
80
+ while (__x == __y->_M_right)
81
+ {
82
+ __x = __y;
83
+ __y = __y->_M_parent;
84
+ }
85
+ if (__x->_M_right != __y)
86
+ __x = __y;
87
+ }
88
+ }
89
+ if(prev != __x){
90
+ prev->_TZ_refCount -= 1;
91
+ __x->_TZ_refCount += 1;
92
+ }
93
+ return __x;
94
+ }
95
+
96
+ _Rb_tree_node_base*
97
+ _Rb_tree_increment(_Rb_tree_node_base* __x) throw ()
98
+ {
99
+ return local_Rb_tree_increment(__x);
100
+ }
101
+
102
+ const _Rb_tree_node_base*
103
+ _Rb_tree_increment(const _Rb_tree_node_base* __x) throw ()
104
+ {
105
+ return local_Rb_tree_increment(const_cast<_Rb_tree_node_base*>(__x));
106
+ }
107
+
108
+ static _Rb_tree_node_base*
109
+ local_Rb_tree_decrement(_Rb_tree_node_base* __x) throw ()
110
+ {
111
+ _Rb_tree_node_base* prev = __x;
112
+ if(__x->_M_left == __x && __x->_M_right == __x && (__x->_M_parent == __x || __x->_M_parent == 0))
113
+ return __x;
114
+ if (__x->_M_color == _S_red
115
+ && __x->_M_parent->_M_parent == __x)
116
+ __x = __x->_M_right;
117
+ else if (__x->_M_left != 0)
118
+ {
119
+ _Rb_tree_node_base* __y = __x->_M_left;
120
+ while (__y->_M_right != 0)
121
+ __y = __y->_M_right;
122
+ __x = __y;
123
+ }
124
+ else
125
+ {
126
+ _Rb_tree_node_base* __y = __x->_M_parent;
127
+ if(__y){
128
+ while (__x == __y->_M_left)
129
+ {
130
+ __x = __y;
131
+ __y = __y->_M_parent;
132
+ }
133
+ __x = __y;
134
+ }
135
+ }
136
+ if(prev != __x){
137
+ prev->_TZ_refCount -= 1;
138
+ __x->_TZ_refCount += 1;
139
+ }
140
+ return __x;
141
+ }
142
+
143
+ _Rb_tree_node_base*
144
+ _Rb_tree_decrement(_Rb_tree_node_base* __x) throw ()
145
+ {
146
+ return local_Rb_tree_decrement(__x);
147
+ }
148
+
149
+ const _Rb_tree_node_base*
150
+ _Rb_tree_decrement(const _Rb_tree_node_base* __x) throw ()
151
+ {
152
+ return local_Rb_tree_decrement(const_cast<_Rb_tree_node_base*>(__x));
153
+ }
154
+
155
+ static void
156
+ local_Rb_tree_rotate_left(_Rb_tree_node_base* const __x,
157
+ _Rb_tree_node_base*& __root)
158
+ {
159
+ _Rb_tree_node_base* const __y = __x->_M_right;
160
+
161
+ __x->_M_right = __y->_M_left;
162
+ if (__y->_M_left !=0)
163
+ __y->_M_left->_M_parent = __x;
164
+ __y->_M_parent = __x->_M_parent;
165
+
166
+ if (__x == __root)
167
+ __root = __y;
168
+ else if (__x == __x->_M_parent->_M_left)
169
+ __x->_M_parent->_M_left = __y;
170
+ else
171
+ __x->_M_parent->_M_right = __y;
172
+ __y->_M_left = __x;
173
+ __x->_M_parent = __y;
174
+ }
175
+
176
+ /* Static keyword was missing on _Rb_tree_rotate_left.
177
+ Export the symbol for backward compatibility until
178
+ next ABI change. */
179
+ void
180
+ _Rb_tree_rotate_left(_Rb_tree_node_base* const __x,
181
+ _Rb_tree_node_base*& __root)
182
+ {
183
+ local_Rb_tree_rotate_left (__x, __root);
184
+ }
185
+
186
+ static void
187
+ local_Rb_tree_rotate_right(_Rb_tree_node_base* const __x,
188
+ _Rb_tree_node_base*& __root)
189
+ {
190
+ _Rb_tree_node_base* const __y = __x->_M_left;
191
+
192
+ __x->_M_left = __y->_M_right;
193
+ if (__y->_M_right != 0)
194
+ __y->_M_right->_M_parent = __x;
195
+ __y->_M_parent = __x->_M_parent;
196
+
197
+ if (__x == __root)
198
+ __root = __y;
199
+ else if (__x == __x->_M_parent->_M_right)
200
+ __x->_M_parent->_M_right = __y;
201
+ else
202
+ __x->_M_parent->_M_left = __y;
203
+ __y->_M_right = __x;
204
+ __x->_M_parent = __y;
205
+ }
206
+
207
+ /* Static keyword was missing on _Rb_tree_rotate_right
208
+ Export the symbol for backward compatibility until
209
+ next ABI change. */
210
+ void
211
+ _Rb_tree_rotate_right(_Rb_tree_node_base* const __x,
212
+ _Rb_tree_node_base*& __root)
213
+ {
214
+ local_Rb_tree_rotate_right (__x, __root);
215
+ }
216
+
217
+ void
218
+ _Rb_tree_insert_and_rebalance(const bool __insert_left,
219
+ _Rb_tree_node_base* __x,
220
+ _Rb_tree_node_base* __p,
221
+ _Rb_tree_node_base& __header) throw ()
222
+ {
223
+ _Rb_tree_node_base *& __root = __header._M_parent;
224
+
225
+ // Initialize fields in new node to insert.
226
+ __x->_M_parent = __p;
227
+ __x->_M_left = 0;
228
+ __x->_M_right = 0;
229
+ __x->_M_color = _S_red;
230
+
231
+ // Insert.
232
+ // Make new node child of parent and maintain root, leftmost and
233
+ // rightmost nodes.
234
+ // N.B. First node is always inserted left.
235
+ if (__insert_left)
236
+ {
237
+ __p->_M_left = __x; // also makes leftmost = __x when __p == &__header
238
+
239
+ if (__p == &__header)
240
+ {
241
+ __header._M_parent = __x;
242
+ __header._M_right = __x;
243
+ }
244
+ else if (__p == __header._M_left)
245
+ __header._M_left = __x; // maintain leftmost pointing to min node
246
+ }
247
+ else
248
+ {
249
+ __p->_M_right = __x;
250
+
251
+ if (__p == __header._M_right)
252
+ __header._M_right = __x; // maintain rightmost pointing to max node
253
+ }
254
+ // Rebalance.
255
+ while (__x != __root
256
+ && __x->_M_parent->_M_color == _S_red)
257
+ {
258
+ _Rb_tree_node_base* const __xpp = __x->_M_parent->_M_parent;
259
+
260
+ if (__x->_M_parent == __xpp->_M_left)
261
+ {
262
+ _Rb_tree_node_base* const __y = __xpp->_M_right;
263
+ if (__y && __y->_M_color == _S_red)
264
+ {
265
+ __x->_M_parent->_M_color = _S_black;
266
+ __y->_M_color = _S_black;
267
+ __xpp->_M_color = _S_red;
268
+ __x = __xpp;
269
+ }
270
+ else
271
+ {
272
+ if (__x == __x->_M_parent->_M_right)
273
+ {
274
+ __x = __x->_M_parent;
275
+ local_Rb_tree_rotate_left(__x, __root);
276
+ }
277
+ __x->_M_parent->_M_color = _S_black;
278
+ __xpp->_M_color = _S_red;
279
+ local_Rb_tree_rotate_right(__xpp, __root);
280
+ }
281
+ }
282
+ else
283
+ {
284
+ _Rb_tree_node_base* const __y = __xpp->_M_left;
285
+ if (__y && __y->_M_color == _S_red)
286
+ {
287
+ __x->_M_parent->_M_color = _S_black;
288
+ __y->_M_color = _S_black;
289
+ __xpp->_M_color = _S_red;
290
+ __x = __xpp;
291
+ }
292
+ else
293
+ {
294
+ if (__x == __x->_M_parent->_M_left)
295
+ {
296
+ __x = __x->_M_parent;
297
+ local_Rb_tree_rotate_right(__x, __root);
298
+ }
299
+ __x->_M_parent->_M_color = _S_black;
300
+ __xpp->_M_color = _S_red;
301
+ local_Rb_tree_rotate_left(__xpp, __root);
302
+ }
303
+ }
304
+ }
305
+ __root->_M_color = _S_black;
306
+ }
307
+
308
+ _Rb_tree_node_base*
309
+ _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z,
310
+ _Rb_tree_node_base& __header) throw ()
311
+ {
312
+ _Rb_tree_node_base *& __root = __header._M_parent;
313
+ _Rb_tree_node_base *& __leftmost = __header._M_left;
314
+ _Rb_tree_node_base *& __rightmost = __header._M_right;
315
+ _Rb_tree_node_base* __y = __z;
316
+ _Rb_tree_node_base* __x = 0;
317
+ _Rb_tree_node_base* __x_parent = 0;
318
+
319
+ if (__y->_M_left == 0) // __z has at most one non-null child. y == z.
320
+ __x = __y->_M_right; // __x might be null.
321
+ else
322
+ if (__y->_M_right == 0) // __z has exactly one non-null child. y == z.
323
+ __x = __y->_M_left; // __x is not null.
324
+ else
325
+ {
326
+ // __z has two non-null children. Set __y to
327
+ __y = __y->_M_right; // __z's successor. __x might be null.
328
+ while (__y->_M_left != 0)
329
+ __y = __y->_M_left;
330
+ __x = __y->_M_right;
331
+ }
332
+ if (__y != __z)
333
+ {
334
+ // relink y in place of z. y is z's successor
335
+ __z->_M_left->_M_parent = __y;
336
+ __y->_M_left = __z->_M_left;
337
+ if (__y != __z->_M_right)
338
+ {
339
+ __x_parent = __y->_M_parent;
340
+ if (__x) __x->_M_parent = __y->_M_parent;
341
+ __y->_M_parent->_M_left = __x; // __y must be a child of _M_left
342
+ __y->_M_right = __z->_M_right;
343
+ __z->_M_right->_M_parent = __y;
344
+ }
345
+ else
346
+ __x_parent = __y;
347
+ if (__root == __z)
348
+ __root = __y;
349
+ else if (__z->_M_parent->_M_left == __z)
350
+ __z->_M_parent->_M_left = __y;
351
+ else
352
+ __z->_M_parent->_M_right = __y;
353
+ __y->_M_parent = __z->_M_parent;
354
+ std::swap(__y->_M_color, __z->_M_color);
355
+ __y = __z;
356
+ // __y now points to node to be actually deleted
357
+ }
358
+ else
359
+ { // __y == __z
360
+ __x_parent = __y->_M_parent;
361
+ if (__x)
362
+ __x->_M_parent = __y->_M_parent;
363
+ if (__root == __z)
364
+ __root = __x;
365
+ else
366
+ if (__z->_M_parent->_M_left == __z)
367
+ __z->_M_parent->_M_left = __x;
368
+ else
369
+ __z->_M_parent->_M_right = __x;
370
+ if (__leftmost == __z)
371
+ {
372
+ if (__z->_M_right == 0) // __z->_M_left must be null also
373
+ __leftmost = __z->_M_parent;
374
+ // makes __leftmost == _M_header if __z == __root
375
+ else
376
+ __leftmost = _Rb_tree_node_base::_S_minimum(__x);
377
+ }
378
+ if (__rightmost == __z)
379
+ {
380
+ if (__z->_M_left == 0) // __z->_M_right must be null also
381
+ __rightmost = __z->_M_parent;
382
+ // makes __rightmost == _M_header if __z == __root
383
+ else // __x == __z->_M_left
384
+ __rightmost = _Rb_tree_node_base::_S_maximum(__x);
385
+ }
386
+ }
387
+ if (__y->_M_color != _S_red)
388
+ {
389
+ while (__x != __root && (__x == 0 || __x->_M_color == _S_black))
390
+ if (__x == __x_parent->_M_left)
391
+ {
392
+ _Rb_tree_node_base* __w = __x_parent->_M_right;
393
+ if (__w->_M_color == _S_red)
394
+ {
395
+ __w->_M_color = _S_black;
396
+ __x_parent->_M_color = _S_red;
397
+ local_Rb_tree_rotate_left(__x_parent, __root);
398
+ __w = __x_parent->_M_right;
399
+ }
400
+ if ((__w->_M_left == 0 ||
401
+ __w->_M_left->_M_color == _S_black) &&
402
+ (__w->_M_right == 0 ||
403
+ __w->_M_right->_M_color == _S_black))
404
+ {
405
+ __w->_M_color = _S_red;
406
+ __x = __x_parent;
407
+ __x_parent = __x_parent->_M_parent;
408
+ }
409
+ else
410
+ {
411
+ if (__w->_M_right == 0
412
+ || __w->_M_right->_M_color == _S_black)
413
+ {
414
+ __w->_M_left->_M_color = _S_black;
415
+ __w->_M_color = _S_red;
416
+ local_Rb_tree_rotate_right(__w, __root);
417
+ __w = __x_parent->_M_right;
418
+ }
419
+ __w->_M_color = __x_parent->_M_color;
420
+ __x_parent->_M_color = _S_black;
421
+ if (__w->_M_right)
422
+ __w->_M_right->_M_color = _S_black;
423
+ local_Rb_tree_rotate_left(__x_parent, __root);
424
+ break;
425
+ }
426
+ }
427
+ else
428
+ {
429
+ // same as above, with _M_right <-> _M_left.
430
+ _Rb_tree_node_base* __w = __x_parent->_M_left;
431
+ if (__w->_M_color == _S_red)
432
+ {
433
+ __w->_M_color = _S_black;
434
+ __x_parent->_M_color = _S_red;
435
+ local_Rb_tree_rotate_right(__x_parent, __root);
436
+ __w = __x_parent->_M_left;
437
+ }
438
+ if ((__w->_M_right == 0 ||
439
+ __w->_M_right->_M_color == _S_black) &&
440
+ (__w->_M_left == 0 ||
441
+ __w->_M_left->_M_color == _S_black))
442
+ {
443
+ __w->_M_color = _S_red;
444
+ __x = __x_parent;
445
+ __x_parent = __x_parent->_M_parent;
446
+ }
447
+ else
448
+ {
449
+ if (__w->_M_left == 0 || __w->_M_left->_M_color == _S_black)
450
+ {
451
+ __w->_M_right->_M_color = _S_black;
452
+ __w->_M_color = _S_red;
453
+ local_Rb_tree_rotate_left(__w, __root);
454
+ __w = __x_parent->_M_left;
455
+ }
456
+ __w->_M_color = __x_parent->_M_color;
457
+ __x_parent->_M_color = _S_black;
458
+ if (__w->_M_left)
459
+ __w->_M_left->_M_color = _S_black;
460
+ local_Rb_tree_rotate_right(__x_parent, __root);
461
+ break;
462
+ }
463
+ }
464
+ if (__x) __x->_M_color = _S_black;
465
+ }
466
+ return __y;
467
+ }
468
+
469
+ unsigned int
470
+ _Rb_tree_black_count(const _Rb_tree_node_base* __node,
471
+ const _Rb_tree_node_base* __root) throw ()
472
+ {
473
+ if (__node == 0)
474
+ return 0;
475
+ unsigned int __sum = 0;
476
+ do
477
+ {
478
+ if (__node->_M_color == _S_black)
479
+ ++__sum;
480
+ if (__node == __root)
481
+ break;
482
+ __node = __node->_M_parent;
483
+ }
484
+ while (1);
485
+ return __sum;
486
+ }
487
+
488
+ _GLIBCXX_END_NAMESPACE_VERSION
489
+ } // namespace
@@ -0,0 +1,84 @@
1
+ //============================================================================
2
+ // Name : tz_stl_auto.cpp
3
+ // *
4
+ // * Copyright (c) 2020
5
+ // *
6
+ // * Yougaein@github (Kokeji Yougain)
7
+ //============================================================================
8
+
9
+ #include <iostream>
10
+ #include "set_tz"
11
+ #include <stdlib.h>
12
+ #include <algorithm>
13
+ #include <typeinfo>
14
+ using namespace std;
15
+ using namespace tz;
16
+
17
+ #include <cxxabi.h>
18
+
19
+
20
+ char* demangle(const char *demangled)
21
+ {
22
+ int status;
23
+ return abi::__cxa_demangle(demangled, 0, 0, &status);
24
+ }
25
+
26
+ void main2();
27
+
28
+ int main() {
29
+ main2();
30
+ return 0;
31
+ }
32
+
33
+ void main2(){
34
+ cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
35
+ tz::multiset<int>& s(*new tz::multiset<int>);
36
+ std::cout << __LINE__ << std::endl;
37
+ std::cout << __LINE__ << std::endl;
38
+ for(int i = 0; i < 10 ; i++){
39
+ std::cout << __LINE__ << std::endl;
40
+ s.insert(rand());
41
+ std::cout << __LINE__ << std::endl;
42
+ }
43
+ std::cout << __LINE__ << std::endl;
44
+ /*std::for_each(s.begin(), s.end(), [](int x) {
45
+ std::cout << x << std::endl;
46
+ });*/
47
+ std::cout << "it_test" << std::endl;
48
+ multiset<int>::iterator it = s.begin(), it2, it3, it4, it5;
49
+ ++it;
50
+ it5 = it4 = it2 = it3 = it;
51
+ for(multiset<int>::iterator it = s.begin(); it != s.end() ; ++it){
52
+ std::cout << *it << std::endl;
53
+ std::cout << *(void**)&it << ";" << it._M_node->_TZ_refCount << std::endl;
54
+ }
55
+ std::cout << __LINE__ << std::endl;
56
+ std::cout << *s.end() << std::endl;
57
+ std::cout << __LINE__ << std::endl;
58
+ std::cout << demangle(typeid(s.end()).name()) << std::endl;
59
+ std::cout << "adr:" << &s << std::endl;
60
+ std::cout << "ptr_test" << std::endl;
61
+ std::cout << "1:" << *(void**)&it << ":" << &*it << std::endl;
62
+ ++it;
63
+ std::cout << "2:" << *(void**)&it << ":" << &*it << std::endl;
64
+ ++it;
65
+ std::cout << "3:" << *(void**)&it << ":" << &*it << std::endl;
66
+ ++it;
67
+ std::cout << "4:" << *(void**)&it << ":" << &*it << std::endl;
68
+ ++it;
69
+ std::cout << "5:" << *(void**)&it << ":" << &*it << std::endl;
70
+ std::cout << "ptr_test2" << std::endl;
71
+ it = s.begin();
72
+ it2 = it3 = it;
73
+ it5 = it4 = s.end();
74
+ delete &s;
75
+ std::cout << "1:" << *(void**)&it << ":" << &*it << std::endl;
76
+ --it;
77
+ std::cout << "2:" << *(void**)&it << ":" << &*it << std::endl;
78
+ --it;
79
+ std::cout << "3:" << *(void**)&it5 << ":" << &*it5 << std::endl;
80
+ --it5;
81
+ std::cout << "4:" << *(void**)&it5 << ":" << &*it5 << std::endl;
82
+ --it5;
83
+ std::cout << "5:" << *(void**)&it5 << ":" << &*it5 << std::endl;
84
+ }
@@ -0,0 +1,3 @@
1
+ class ESet
2
+ VERSION = "0.99.0"
3
+ end
data/lib/eset.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "tz/version"
2
+ require "tz/eset"
3
+
4
+ class ESet
5
+ class Error < StandardError; end
6
+ # Your code goes here...
7
+ end