本文整理汇总了C++中Tuple::delete_inplace方法的典型用法代码示例。如果您正苦于以下问题:C++ Tuple::delete_inplace方法的具体用法?C++ Tuple::delete_inplace怎么用?C++ Tuple::delete_inplace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple::delete_inplace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_delete_inplace
void test_delete_inplace() {
Tuple *tuple = new_tuple();
tuple->put(state, 1, Qnil);
Integer *count = tuple->delete_inplace(state, Fixnum::from(0), Fixnum::from(3), Qnil);
TS_ASSERT_EQUALS(1, count->to_native());
TS_ASSERT_EQUALS(Fixnum::from(1), as<Fixnum>(tuple->at(state, 0)));
TS_ASSERT_EQUALS(Fixnum::from(9), as<Fixnum>(tuple->at(state, 1)));
TS_ASSERT_EQUALS(Qnil, tuple->at(state, 2));
}
示例2: test_delete_inplace_bounds
void test_delete_inplace_bounds() {
Tuple *tuple = new_tuple();
Integer *count;
TS_ASSERT_THROWS_ASSERT(count = tuple->delete_inplace(state, Fixnum::from(0), Fixnum::from(4), Qnil),
const RubyException &e,
TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
TS_ASSERT_THROWS_ASSERT(count = tuple->delete_inplace(state, Fixnum::from(1), Fixnum::from(3), Qnil),
const RubyException &e,
TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
TS_ASSERT_THROWS_ASSERT(count = tuple->delete_inplace(state, Fixnum::from(-1), Fixnum::from(3), Qnil),
const RubyException &e,
TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
TS_ASSERT_THROWS_ASSERT(count = tuple->delete_inplace(state, Fixnum::from(0), Fixnum::from(-1), Qnil),
const RubyException &e,
TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
TS_ASSERT_THROWS_ASSERT(count = tuple->delete_inplace(state, Fixnum::from(3), Fixnum::from(1), Qnil),
const RubyException &e,
TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
}
示例3:
void Module::Info::mark(Object* obj, ObjectMark& mark) {
auto_mark(obj, mark);
Array* subclasses = as<Module>(obj)->hierarchy_subclasses_;
if(subclasses->nil_p()) return;
native_int offset = subclasses->offset();
native_int size = subclasses->size();
Tuple* tup = subclasses->tuple();
for(native_int i = offset; i < size + offset; ++i) {
if(WeakRef* ref = try_as<WeakRef>(tup->field[i])) {
if(!ref->alive_p()) {
tup->field[i] = cNil;
}
}
}
subclasses->set_size(size - tup->delete_inplace(offset, size, cNil));
}