本文整理汇总了C++中TArray::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::remove方法的具体用法?C++ TArray::remove怎么用?C++ TArray::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TArray
的用法示例。
在下文中一共展示了TArray::remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_insert_remove
void test_insert_remove(void)
{
TArray<int> arr;
arr.initialize(2);
CPPUNIT_ASSERT_EQUAL((hyu32)0, arr.size());
HMD_ASSERT_HALT(arr.insert(1));
arr.insert(0) = 10;
CPPUNIT_ASSERT_EQUAL((hyu32)1, arr.size());
CPPUNIT_ASSERT_EQUAL(10, arr[0]);
arr.insert(0) = 20;
CPPUNIT_ASSERT_EQUAL((hyu32)2, arr.size());
CPPUNIT_ASSERT_EQUAL(20, arr[0]);
CPPUNIT_ASSERT_EQUAL(10, arr[1]);
arr.insert(1) = 30;
CPPUNIT_ASSERT_EQUAL((hyu32)3, arr.size());
CPPUNIT_ASSERT_EQUAL(20, arr[0]);
CPPUNIT_ASSERT_EQUAL(30, arr[1]);
CPPUNIT_ASSERT_EQUAL(10, arr[2]);
arr.insert(3) = 40;
CPPUNIT_ASSERT_EQUAL((hyu32)4, arr.size());
CPPUNIT_ASSERT_EQUAL(20, arr[0]);
CPPUNIT_ASSERT_EQUAL(30, arr[1]);
CPPUNIT_ASSERT_EQUAL(10, arr[2]);
CPPUNIT_ASSERT_EQUAL(40, arr[3]);
arr.insert(-1) = 50;
CPPUNIT_ASSERT_EQUAL((hyu32)5, arr.size());
CPPUNIT_ASSERT_EQUAL(20, arr[0]);
CPPUNIT_ASSERT_EQUAL(30, arr[1]);
CPPUNIT_ASSERT_EQUAL(10, arr[2]);
CPPUNIT_ASSERT_EQUAL(50, arr[3]);
CPPUNIT_ASSERT_EQUAL(40, arr[4]);
arr.remove(2);
CPPUNIT_ASSERT_EQUAL((hyu32)4, arr.size());
CPPUNIT_ASSERT_EQUAL(20, arr[0]);
CPPUNIT_ASSERT_EQUAL(30, arr[1]);
CPPUNIT_ASSERT_EQUAL(50, arr[2]);
CPPUNIT_ASSERT_EQUAL(40, arr[3]);
arr.remove(-3);
CPPUNIT_ASSERT_EQUAL((hyu32)3, arr.size());
CPPUNIT_ASSERT_EQUAL(20, arr[0]);
CPPUNIT_ASSERT_EQUAL(50, arr[1]);
CPPUNIT_ASSERT_EQUAL(40, arr[2]);
HMD_ASSERT_HALT(arr.remove(3));
HMD_ASSERT_HALT(arr.remove(-4));
int* p = arr.nthAddr(3);
int* q = arr.addSpaces(2);
CPPUNIT_ASSERT_EQUAL((hyu32)5, arr.size());
CPPUNIT_ASSERT_EQUAL(p, q);
}
示例2:
TEST_F( TArrayTest, removeItTest) {
TArray<float> arrayInstance;
arrayInstance.add( 1.0f );
EXPECT_EQ( 1, arrayInstance.size() );
TArray<float>::Iterator it = arrayInstance.find( 1.0f );
EXPECT_NE( arrayInstance.end(), it );
arrayInstance.remove( it );
EXPECT_EQ( 0, arrayInstance.size() );
}