Exemplo n.º 1
0
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;

}
Exemplo n.º 2
0
TEST(TwoDArray, PrintString) {
    TwoDArray<string>* tdS = new TwoDArray<string>(5, 5, "default");
    for (int i = 0; i < 5; i++) {
	  tdS->insert(i, i, "hello");
    }
    std::cout << "TDArray String print" << std::endl;
    tdS->print();
    delete tdS;
}
Exemplo n.º 3
0
TEST(TwoDArray, PrintInt) {
    TwoDArray<int>* tdInt = new TwoDArray<int>(5, 5, 0);
    for (int i = 0; i < 5; i++) {
	  tdInt->insert(i, i, 7);
    }
    std::cout << "TDArray Integer print" << std::endl;
    tdInt->print();
    delete tdInt;
}
Exemplo n.º 4
0
TEST(TwoDArray, PrintDouble) {
    TwoDArray<double>* tdD = new TwoDArray<double>(5, 5, 0.00);
    for (int i = 0; i < 5; i++) {
	  tdD->insert(i, i, 7.77);
    }
    std::cout << "TDArray Double print" << std::endl;
    tdD->print();
    delete tdD;
}
Exemplo n.º 5
0
TEST(arrayTest, print) {
  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->print();
  std::cout << std::endl;
  d->print();
  std::cout << std::endl;
  s->print();

  delete i;
  delete d;
  delete s;
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
TEST(print, 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");
    a->print();
    delete a;
}
Exemplo n.º 8
0
TEST(print, doubleTest) {
    int r = 10;
    int c = 10;
    TwoDArray<double>* a = new TwoDArray<double>(r, c);
    a->insert(0, 0, 4089.7678);
    a->insert(0, 9, 900.435468);
    a->insert(9, 9, 92939.765);
    a->insert(4, 4, 567658.12);
    a->print();
    delete a;
}
Exemplo n.º 9
0
TEST(print, integerTest) {
    int r = 10;
    int c = 10;
    TwoDArray<int>* a = new TwoDArray<int>(r, c);
    a->insert(0, 0, 400);
    a->insert(0, 9, 900);
    a->insert(9, 9, 92939);
    a->insert(4, 4, 567658);
    a->print();
    delete a;
}
Exemplo n.º 10
0
int main() {
  TwoDArray<int>* l = new TwoDArray<int>(10, 10);

  TwoDArray<std::string>* s = new TwoDArray<std::string>(20, 20);

  l->insert(5, 9, 5);
  l->insert(1, 1, 100);
  l->insert(7, 2, 99999);

  l->print();


  s->insert(1, 1, "hello world!");
  s->insert(19, 19, "hi");
  s->insert(5, 10, "apple");
  s->insert(4, 16, "banana");

  s->print();


  return 0;
}
Exemplo n.º 11
0
int main() {
  TwoDArray<int>* victim = new TwoDArray<int>(5,10,0);
  for(int i = 0; i<victim->getNumRows(); i++) {
    for(int j = 0; j<victim->getNumCols(); j++) {
      victim->insert(i,j,i+j);
    }
  }
  victim->print();
  delete victim;
  TwoDArray<std::string>* victim2 = new TwoDArray<std::string>(3,2,"moo");
  victim2->print();
  delete victim2;
  return 0;
}
Exemplo n.º 12
0
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;
}