当前位置: 首页>>代码示例>>C++>>正文


C++ SparseArray::remove方法代码示例

本文整理汇总了C++中SparseArray::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ SparseArray::remove方法的具体用法?C++ SparseArray::remove怎么用?C++ SparseArray::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SparseArray的用法示例。


在下文中一共展示了SparseArray::remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

Test(sparseTest, remove) {
  SparseArray<int>* i = new SparseArray<int>(5, 5, 0);
  SparseArray<double>* d = new SparseArray<int>(5, 5, 0);
  SparseArray<std::string>* s = new SparseArray<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;
}
开发者ID:hcsnyder,项目名称:csci333-Project2,代码行数:25,代码来源:Array_test.cpp

示例2:

TEST(SparseArrayRemove, RemoveString) {
    SparseArray<string>* tDString = new SparseArray<string>(10, 10, "default");
    for (int i=0; i<10; i++) {
	  tDString->insert(i, i, "HELLO");
    }
    tDString->remove(7, 5);
    EXPECT_EQ("default", tDString->access(7, 5));
    delete tDString;
}
开发者ID:GregGay,项目名称:csci333_Project2,代码行数:9,代码来源:TwoDArray.cpp

示例3:

TEST(Sparse, Remove) {
	SparseArray<int>* newSparse = new SparseArray<int>(5,5,0);
	newSparse->insert(0,0,4);
	newSparse->remove(0,0);
	EXPECT_EQ(0, newSparse->access(2,3));
	delete newSparse;

	SparseArray<double>* newDouble = new SparseArray<double>(5,7,0.0);
	newDouble->insert(2,3,4.9);
	newDouble->remove(2,3);
	EXPECT_EQ(0.0, newDouble->access(2,3));
	delete newDouble;

	SparseArray<std::string>* newString = new SparseArray<std::string>(321,678,"yes");
	newString->insert(2,3,"no");
	newString->remove(2,3);
	EXPECT_EQ("yes", newString->access(2,3));
	delete newString;
}
开发者ID:billymills,项目名称:sparse-array-api,代码行数:19,代码来源:Sparse.cpp


注:本文中的SparseArray::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。