Method: Bitset#set

Defined in:
ext/bitset/bitset.c

#set(*args) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'ext/bitset/bitset.c', line 104

static VALUE rb_bitset_set(int argc, VALUE * argv, VALUE self) {
    int i;
    Bitset * bs = get_bitset(self);

    if (argc == 1 && rb_obj_is_kind_of(argv[0], rb_const_get(rb_cObject, rb_intern("Array")))) {
        for(i = 0; i < RARRAY_LEN(argv[0]); i++) {
            VALUE index = RARRAY_PTR(argv[0])[i];
            int idx = NUM2INT(index);
            validate_index(bs, idx);
            set_bit(bs, idx);
        }
    } else {
        for(i = 0; i < argc; i++) {
            VALUE index = argv[i];
            int idx = NUM2INT(index);
            validate_index(bs, idx);
            set_bit(bs, idx);
        }
    }
    return Qtrue;
}