YkESet 0.99.9 → 0.99.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e07f6b289a0481ea87f3ebbadda79385902561588a5b175b3bc021c473ddb5f
4
- data.tar.gz: 2e09d66e8ea52db188d07f94c226851ab3a68519f0b13d7eb432241ccc9335be
3
+ metadata.gz: 5a7a1250f76831d6f850cba04f4cd7d9c4a50d96cd4017ebf4126b01845677ca
4
+ data.tar.gz: ed66cd6e0b260c1c92df2bc2797ae58087445f150927210a654c3b6407d1e511
5
5
  SHA512:
6
- metadata.gz: 7e900c7edb69dde2bc6b6babc7f6050b4c9d9710b0fab6aa9c7581d29ad1e88678bccf6f87c7f24e9231374b11124c29544170c741800393a0d9304a55ab95bf
7
- data.tar.gz: f31d39a654955db6a04add4a615a633e5a44814b584f901b43b47796210a470276b9b73ffb0ca75386238f186dc866d562a641f543cd7f6e6b8266ce2fcb09c6
6
+ metadata.gz: 7469e05c4bd5cfcdc88a9fcc0c886bd7ae44738868fe0d6b33de45d0aef21e4d17af29ec8711b9081f3d5b9ef59327d4a674710972e0a01c75412c540a88bbbf
7
+ data.tar.gz: 6397d68f50f38d948d3c43c672757bb825e3de9582814b0e215c3775ff3b80dbce452eedf0df7ab96bb8cef763b090c0c20c7592bd27234e15a6716630c226fe
@@ -271,6 +271,15 @@ struct ESetWrap{
271
271
  }
272
272
 
273
273
 
274
+ static VALUE eMSet_each(VALUE self) {
275
+ EMSet* p = eMSet(self);
276
+ VALUE ret = Qnil;
277
+ for(typename EMSet::iterator it = p->begin() ; it != p->end() ; ++it)
278
+ ret = rb_yield(toValue(*it));
279
+ return ret;
280
+ }
281
+
282
+
274
283
  static VALUE eMSetIt_clone(VALUE self) {
275
284
  iterator* it = eMSetIt(self);
276
285
  VALUE itv = eMSetIt_alloc(cESetIt);
@@ -332,6 +341,68 @@ struct ESetWrap{
332
341
  }
333
342
  }
334
343
 
344
+ static VALUE eMSetIt_succ(VALUE self){
345
+ VALUE ret = eMSetIt_clone(self);
346
+ eMSetIt_inc(ret);
347
+ return ret;
348
+ }
349
+
350
+ static VALUE eMSetIt_spaceshipOp(VALUE self, VALUE other){
351
+ iterator* a = eMSetIt(self);
352
+ iterator* b = eMSetIt(other);
353
+ if(a->_M_node->_TZ_destroyer){
354
+ rb_raise(rb_eArgError, "the left operand is already erased");
355
+ return Qnil;
356
+ }
357
+ if(b->_M_node->_TZ_destroyer){
358
+ rb_raise(rb_eArgError, "the right operand is already erased");
359
+ return Qnil;
360
+ }
361
+ if((EMSet*)a->_M_node->_TZ_tree != (EMSet*)b->_M_node->_TZ_tree){
362
+ rb_raise(rb_eArgError, "the left operand and the right operand are not from the same container");
363
+ return Qnil;
364
+ }
365
+ if(*a == *b)
366
+ return INT2FIX(0);
367
+ if(*a == ((EMSet*)a->_M_node->_TZ_tree)->end()){
368
+ return INT2FIX(1);
369
+ }else{
370
+ if(*b == ((EMSet*)b->_M_node->_TZ_tree)->end()){
371
+ return INT2FIX(-1);
372
+ }else{
373
+ VALUE res = rb_funcall(**a, ID_LESS, 1, **b);
374
+ if(res == Qtrue)
375
+ return INT2FIX(-1);
376
+ else{
377
+ res = rb_funcall(**b, ID_LESS, 1, **a);
378
+ if(res == Qtrue)
379
+ return INT2FIX(1);
380
+ else{
381
+ iterator tmp = *a;
382
+ while(1){
383
+ ++tmp;
384
+ if(tmp == ((EMSet*)a->_M_node->_TZ_tree)->end() || rb_funcall(*tmp, ID_LESS, 1, **b) != Qfalse || rb_funcall(*tmp, ID_LESS, 1, **a) != Qfalse)
385
+ break;
386
+ if(tmp == *b)
387
+ return INT2FIX(1);
388
+ }
389
+ tmp = *a;
390
+ while(1){
391
+ --tmp;
392
+ if(rb_funcall(**a, ID_LESS, 1, **b) != Qfalse || rb_funcall(**b, ID_LESS, 1, **a) != Qfalse)
393
+ break;
394
+ if(tmp == *b)
395
+ return INT2FIX(-1);
396
+ if(tmp == ((EMSet*)a->_M_node->_TZ_tree)->begin()){
397
+ rb_raise(rb_eArgError, "Unknown range");
398
+ return Qnil;
399
+ }
400
+ }
401
+ }
402
+ }
403
+ }
404
+ }
405
+ }
335
406
 
336
407
  static VALUE eMSet_find(int argc, VALUE *argv, VALUE self){
337
408
  VALUE b, e, v;
@@ -514,6 +585,7 @@ struct ESetWrap{
514
585
  rb_define_method(cESet, "size", RUBY_METHOD_FUNC(ESetWrap<EMSet>::eMSet_size), 0);
515
586
  rb_define_method(cESet, "clear", RUBY_METHOD_FUNC(ESetWrap<EMSet>::eMSet_clear), 0);
516
587
 
588
+ rb_define_method(cESet, "each", RUBY_METHOD_FUNC(ESetWrap<EMSet>::eMSet_each), 0);
517
589
  rb_define_method(cESet, "begin", RUBY_METHOD_FUNC(ESetWrap<EMSet>::eMSet_begin), 0);
518
590
  rb_define_method(cESet, "end", RUBY_METHOD_FUNC(ESetWrap<EMSet>::eMSet_end), 0);
519
591
  rb_define_method(cESet, "upper_bound", RUBY_METHOD_FUNC(ESetWrap<EMSet>::eMSet_upper_bound), 1);
@@ -603,7 +675,7 @@ struct ESetWrapMap_ : ESetWrap<E>{
603
675
  static void Init_eset(const char* n){
604
676
  ESetWrap<E>::Init_eset(n);
605
677
  rb_define_method(ESetWrap<E>::cESet, "insert", RUBY_METHOD_FUNC(eMSet_insert), -1);
606
- rb_define_method(ESetWrap<E>::cESet, "add", RUBY_METHOD_FUNC(eMSet_insert), -1);
678
+ rb_define_method(ESetWrap<E>::cESet, "add", RUBY_METHOD_FUNC(eMSet_add), -1);
607
679
  rb_define_method(ESetWrap<E>::cESetIt, "item", RUBY_METHOD_FUNC(eMSetIt_item), 0);
608
680
  };
609
681
  };
@@ -671,7 +743,7 @@ struct ESetWrapMap<EMap> : ESetWrapMap_<EMap>{
671
743
  static void Init_eset(const char* n){
672
744
  ESetWrapMap_<EMap>::Init_eset(n);
673
745
  rb_define_method(ESetWrap<EMap>::cESet, "insert_or_assign", RUBY_METHOD_FUNC(eMSet_insert_or_assign), -1);
674
- rb_define_method(ESetWrap<EMap>::cESet, "add_or_assign", RUBY_METHOD_FUNC(eMSet_insert_or_assign), -1);
746
+ rb_define_method(ESetWrap<EMap>::cESet, "add_or_assign", RUBY_METHOD_FUNC(eMSet_add_or_assign), -1);
675
747
  }
676
748
  };
677
749
 
@@ -736,7 +808,7 @@ struct ESetWrapSet : ESetWrap<EMSet>{
736
808
  static void Init_eset(const char* n){
737
809
  ESetWrap<EMSet>::Init_eset(n);
738
810
  rb_define_method(ESetWrap<EMSet>::cESet, "insert", RUBY_METHOD_FUNC(eMSet_insert), -1);
739
- rb_define_method(ESetWrap<EMSet>::cESet, "add", RUBY_METHOD_FUNC(eMSet_insert), -1);
811
+ rb_define_method(ESetWrap<EMSet>::cESet, "add", RUBY_METHOD_FUNC(eMSet_add), -1);
740
812
  rb_define_method(ESetWrap<EMSet>::cESetIt, "item", RUBY_METHOD_FUNC(eMSetIt_item), 0);
741
813
  };
742
814
  };
@@ -1,3 +1,3 @@
1
1
  class ESet
2
- VERSION = "0.99.9"
2
+ VERSION = "0.99.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: YkESet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.99.9
4
+ version: 0.99.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - yougaein