Пример #1
0
static VALUE
rb_set_delete(VALUE set, SEL sel, VALUE obj)
{
    rb_set_modify_check(set);

    CFSetRemoveValue((CFMutableSetRef)set, (const void *)RB2OC(obj));
    return set;
}
Пример #2
0
static VALUE
rb_set_clear(VALUE set, SEL sel)
{
    rb_set_modify_check(set);

    CFSetRemoveAllValues((CFMutableSetRef)set);
    return set;
}
Пример #3
0
static VALUE
rb_set_add(VALUE set, VALUE obj)
{
    rb_set_modify_check(set);

    CFSetAddValue((CFMutableSetRef)set, (const void *)RB2OC(obj));

    return set;
}
Пример #4
0
static VALUE
rb_set_merge(VALUE set, VALUE other)
{
    rb_set_modify_check(set);

    CFSetApplyFunction((CFMutableSetRef)other, rb_set_union_callback, (void *)set);

    return set;
}
Пример #5
0
static VALUE
rb_set_delete2(VALUE set, SEL sel, VALUE obj)
{
    rb_set_modify_check(set);

    if (CFSetContainsValue((CFMutableSetRef)set, (const void *)RB2OC(obj))) {
	CFSetRemoveValue((CFMutableSetRef)set, (const void *)RB2OC(obj));
	return set;
    } else
	return Qnil;
}
Пример #6
0
static VALUE
rb_set_add2(VALUE set, SEL sel, VALUE obj)
{
    rb_set_modify_check(set);

    if (CFSetContainsValue((CFMutableSetRef)set, (const void *)RB2OC(obj))) {
	return Qnil;
    }
    CFSetAddValue((CFMutableSetRef)set, (const void *)RB2OC(obj));
    return set;
}
Пример #7
0
static VALUE
rb_set_intersect(VALUE set, SEL sel, VALUE other)
{
    rb_set_modify_check(set);

    VALUE new_set = rb_set_new();
    CFMutableSetRef sets[2] = { (CFMutableSetRef)other, (CFMutableSetRef)new_set };
    CFSetApplyFunction((CFMutableSetRef)set, rb_set_intersect_callback, sets);

    return new_set;
}
Пример #8
0
static VALUE
rb_set_reject_bang(VALUE set, SEL sel)
{
    rb_set_modify_check(set);

    VALUE new_set = rb_set_dup(set, 0);
    VALUE acted = Qfalse;
    VALUE context[2] = { set, (VALUE)&acted };
    CFSetApplyFunction((CFMutableSetRef)new_set, rb_set_delete_if_callback, (void *)context);

    return acted == Qtrue ? set : Qnil ;
}
Пример #9
0
static VALUE
rb_set_delete_if(VALUE set)
{
    rb_set_modify_check(set);

    VALUE new_set = rb_set_dup(set);
    VALUE acted = Qfalse;
    VALUE context[2] = { set, (VALUE)&acted };
    CFSetApplyFunction((CFMutableSetRef)new_set, rb_set_delete_if_callback, (void *)context);

    return set;
}
Пример #10
0
static VALUE
rb_set_merge(VALUE set, SEL sel, VALUE other)
{
    rb_set_modify_check(set);

    VALUE klass = *(VALUE *)other;
    if (klass == rb_cCFSet || klass == rb_cNSSet || klass == rb_cNSMutableSet)
	CFSetApplyFunction((CFMutableSetRef)other, rb_set_union_callback, (void *)set);	
    else
	rb_block_call(other, rb_intern("each"), 0, 0, merge_i, (VALUE)set);

    return set;
}