本文整理汇总了C++中TwoDArray::access方法的典型用法代码示例。如果您正苦于以下问题:C++ TwoDArray::access方法的具体用法?C++ TwoDArray::access怎么用?C++ TwoDArray::access使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwoDArray
的用法示例。
在下文中一共展示了TwoDArray::access方法的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, access) {
TwoDArray<int>* td = new TwoDArray<int>(100, 100, 42);
td->insert(25, 25, 1);
td->insert(25, 26, 2);
td->insert(26, 25, 3);
td->insert(26, 26, 4);
EXPECT_EQ(42, td->access(0, 0));
EXPECT_EQ(4, td->access(26, 26));
delete td;
}
示例3:
TEST(TwoDArrayAccess, AccessString) {
TwoDArray<string>* tDString = new TwoDArray<string>(12, 12, "9");
for (int i = 0; i < 10; i++) {
for(int j = 0; j < 10; j++) {
tDString->access(i, j);
}
}
EXPECT_EQ("9", tDString->access(7, 7));
delete tDString;
}
示例4:
TEST(TwoDArray, Insert) {
TwoDArray<int>* newInt = new TwoDArray<int>(10,10,0);
newInt->insert(5,5,5);
EXPECT_EQ(5, newInt->access(5,5));
delete newInt;
TwoDArray<std::string>* newString = new TwoDArray<std::string>(10,10,"null");
newString->insert(5,5,"yo");
EXPECT_EQ("yo", newString->access(5,5));
delete newString;
TwoDArray<double>* newDouble = new TwoDArray<double>(10,10,0.0);
newDouble->insert(5,5,5.5);
EXPECT_EQ(5.5, newDouble->access(5,5));
delete newDouble;
}
示例5:
TEST(access, stringTest) {
int r = 10;
int c = 10;
TwoDArray<string>* a = new TwoDArray<string>(r, c);
a->insert(9, 9, "yarrr");
EXPECT_EQ("yarrr", a->access(9, 9));
delete a;
}
示例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;
}