本文整理汇总了C++中TwoDArray::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ TwoDArray::remove方法的具体用法?C++ TwoDArray::remove怎么用?C++ TwoDArray::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwoDArray
的用法示例。
在下文中一共展示了TwoDArray::remove方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Test(arrayTest, remove) {
TwoDArray<int>* i = new TwoDArray<int>(5, 5, 0);
TwoDArray<double>* d = new TwoDArray<int>(5, 5, 0);
TwoDArray<std::string>* s = new TwoDArray<std::string>(5, 5, "o");
i->insert(2, 2, 7);
d->insert(4, 4, 3.145);
s->insert(0, 0, "Hello");
i->insert(3, 3, 9);
i->remove(2, 2);
d->remove(4, 4);
s->remove(0, 0);
s->insert(0, 0, "y");
EXPECT_EQ(0, i->access(2, 2));
EXPECT_EQ(0, d->access(4, 4));
EXPECT_EQ("y", s->access(0, 0));
EXPECT_EQ(9, i->insert(3, 3));
delete i;
delete d;
delete s;
}
示例2:
TEST(TwoDArrayTest, remove) {
TwoDArray<int>* td = new TwoDArray<int>(10, 10, 42);
td->insert(5, 5, 12);
td->remove(5, 5);
EXPECT_EQ(42, td->access(5,5));
delete td;
}
示例3:
TEST(remove, integerTest) {
int r = 10;
int c = 10;
TwoDArray<int>* a = new TwoDArray<int>(r, c);
a->insert(0, 0, 400);
a->remove(0, 0);
ASSERT_TRUE(a->access(0, 0) != 400);
delete a;
}
示例4:
TEST(TwoDArray, Remove) {
TwoDArray<int>* newInt = new TwoDArray<int>(5,5,0);
newInt->insert(2,3,4);
newInt->remove(2,3);
EXPECT_EQ(0, newInt->access(2,3));
delete newInt;
TwoDArray<double>* newDouble = new TwoDArray<double>(3,4,1.0);
newDouble->insert(2,1,4.4);
newDouble->remove(2,1);
EXPECT_EQ(1.0, newDouble->access(2,3));
delete newDouble;
TwoDArray<std::string>* newString = new TwoDArray<std::string>(100,200,"empty");
newString->insert(48, 68, "hello");
newString->remove(2,3);
EXPECT_EQ("hello", newString->access(48,68));
delete newString;
}
示例5:
TEST(TwoDArrayRemove, RemoveDouble) {
TwoDArray<double>* tDDouble = new TwoDArray<double>(10, 10, 0.0);
for (int i=0; i<10; i++) {
tDDouble->insert(i, i, 7);
}
tDDouble->remove(7, 5);
EXPECT_EQ(0.0, tDDouble->access(7, 5));
delete tDDouble;
}
示例6: main
int main(){
TwoDArray<int>* newArray = new TwoDArray<int>(10, 10, 0);
newArray->insert(1,1,5);
cout << newArray->access(1,1) << endl;
newArray->remove(1,1);
cout << newArray->access(1,1) << endl;
newArray->print();
delete newArray;
TwoDArray<std::string>* nextArray = new TwoDArray<std::string>(5,5, "hi");
nextArray->insert(2,2, "bye");
nextArray->print();
delete nextArray;
}