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


C++ TwoDArray::insert方法代码示例

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


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

示例1:

TEST(insert, stringTest) {
    int r = 10;
    int c = 10;
    TwoDArray<string>* a = new TwoDArray<string>(r, c);
    a->insert(0, 0, "hey");
    a->insert(0, 9, "whats");
    a->insert(9, 9, "up");
    a->insert(4, 4, "yooooooooooo");
    delete a;
}
开发者ID:aviindub,项目名称:TwoDArray,代码行数:10,代码来源:TwoDArray.cpp

示例2:

TEST(TwoDArray, Print) {
	TwoDArray<int>* newArray = new TwoDArray<int>(10,10,0);
	newArray->insert(1,2,1);
	newArray->insert(9,8,2);
	newArray->insert(7,2,3);
	newArray->insert(6,4,4);
	newArray->insert(0,8,5);
	newArray->print();
	delete newArray;
}
开发者ID:billymills,项目名称:sparse-array-api,代码行数:10,代码来源:Sparse.cpp

示例3:

TEST(TwoDArrayTest, insert) {
  TwoDArray<int>* td = new TwoDArray<int>(10, 10, 0);
  td->insert(5, 4, 10);
  td->insert(5, 5, 9);
  td->insert(5, 6, 8);


  EXPECT_EQ(10, td->access(5, 4));
  EXPECT_EQ(8, td->access(5, 6));
  delete td;
}
开发者ID:nb-unca-projects,项目名称:TwoDArray,代码行数:11,代码来源:ArrayTest.cpp

示例4:

TEST(TwoDArrayTest, InsertInt) {
    TwoDArray<int>* tDInt = new TwoDArray<int>(3, 3, 0);
    for (int i=0; i < 3; i++) {
	  tDInt->insert(i, i, 3);
    }
    EXPECT_EQ(3, tDInt->access(1, 1));
    delete tDInt;
}
开发者ID:GregGay,项目名称:csci333_Project2,代码行数:8,代码来源:TwoDArray.cpp

示例5:

TEST(arrayTest, getNumRows) {
  TwoDArray<int>* i = new TwoDArray<int>(5, 5, 0);
  TwoDArray<double>* d = new TwoDArray<int>(6, 5, 0);
  TwoDArray<std::string>* s = new TwoDArray<std::string>(10, 5, "o");

  i->insert(2, 2, 7);
  d->insert(4, 4, 3.145);
  s->insert(0, 0, "Hello");

  EXPECT_EQ(5, i->getNumRows());
  EXPECT_EQ(6, d->getNumRows());
  EXPECT_EQ(10, s->getNumRows());

  delete i;
  delete d;
  delete s;
}
开发者ID:hcsnyder,项目名称:csci333-Project2,代码行数:17,代码来源:Array_test.cpp

示例6:

void AVLTree<T>::visualPrint(T def, T leftLeg, T rightLeg) {
	
	//make a Queue of globs, push in root at 0, 0
	list<Glob<T>*> q;
	int level=0; int spread=0;
	Glob<T>* root_glob = new Glob<T>(*root, level, spread);
	q.push_back (root_glob);
	
	//make 2d vector for glob coordinates, spread is width, level is depth
	int s; int l;
	TwoDArray<T>* tda = new TwoDArray<T>(8, 15, def);
	int spread_middle = 7;
	
	//begin level order traversal of AVLTree and insert into tda
	Node<T>* curr_node;
	while (!(q.empty())) {
		Glob<T>* curr_glob = q.front();
		curr_node = curr_glob->getNodePointer();
		if (curr_node->getLeftChild()!=0) {
			//get level, spread for left node and make a glob
			level = (curr_glob->getLevel())+2;
			spread = (curr_glob->getSpread())-2;
			Glob<T>* new_glob_left = new Glob<T>(*(curr_node->getLeftChild()), level, spread);
			q.push_back (new_glob_left);
			//insert left leg into tda
			tda->insert(level-1, spread_middle+spread+1, leftLeg);
		}
		if (curr_node->getRightChild()!=0) {
			level=(curr_glob->getLevel())+2;
			spread = (curr_glob->getSpread())+2;
			Glob<T>* new_glob_right = new Glob<T>(*(curr_node->getRightChild()), level, spread);
			q.push_back (new_glob_right);
			//insert right leg tda
			tda->insert(level-1, spread_middle+spread-1, rightLeg);			
		}		
		if (curr_node!=0) {
			l = curr_glob->getLevel();
			s = curr_glob->getSpread();
			tda->insert(l, spread_middle+s, curr_glob->getNodePointer()->getValue());
		}
		q.pop_front();	
	}
	tda->print();
	delete tda;
	delete root_glob;
}
开发者ID:ryanbarringtoncox,项目名称:AVLTree,代码行数:46,代码来源:AVLTree.cpp

示例7: 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;

}
开发者ID:billymills,项目名称:sparse-array-api,代码行数:17,代码来源:array_test.cpp


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