Method: Containers::Bitset#clear

Defined in:
ext/containers/bitset/bitset.c

#clear(*args) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'ext/containers/bitset/bitset.c', line 174

static VALUE rb_bitset_clear(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);
            _clear_bit(bs, idx);
        }
    } else {
        for(i = 0; i < argc; i++) {
            VALUE index = argv[i];
            int idx = NUM2INT(index);
            validate_index(bs, idx);
            _clear_bit(bs, idx);
        }
    }
    return Qtrue;
}