Beispiel #1
0
void DestructorTest()
{
	cout << "--------------------------DestructorTest---------------------------" << endl;

	RedBlackTree<int> tree;
	cout << "Create Tree..." << endl;
	tree.Insert(6);
	tree.Insert(7);
	tree.Insert(8);
	tree.Insert(9);
	cout << "Remove All of Tree..." << endl << endl;
	tree.RemoveAll();

	RedBlackTree<int> tree2;
	cout << "Create Tree2..." << endl << endl;
	tree2.Insert(0);
	tree2.Insert(1);
	tree2.Insert(2);
	tree2.Insert(3);

	RedBlackTree<int> tree3(tree2);
	cout << "Create Tree3 (Copy of Tree2)..." << endl;
	cout << "Insert into Tree3..." << endl << endl;
	tree3.Insert(10);
	tree3.Insert(55);
	tree3.Insert(96);
	tree3.Insert(777);

	cout << "Destory Empty Tree1..." << endl;
	cout << "Destory Tree2..." << endl;
	cout << "Destory Copy Tree3..." << endl << endl;
}
Beispiel #2
0
void HeightTest()
{
	cout << "--------------------------Height Test---------------------------" << endl;

	RedBlackTree<int> tree;
	cout<< "Creat Tree..." << endl;
	cout << "Height: " << tree.Height() << endl;
	cout << "Insert 1" << endl;
	tree.Insert(1);
	cout << "Height: " << tree.Height() << endl <<endl ;
	cout << "Insert 5 Item" << endl;
	tree.Insert(20);
	tree.Insert(3);
	tree.Insert(7);
	tree.Insert(5);
	tree.Insert(6);
	tree.Insert(10);
	tree.Insert(21);
	tree.Insert(23);
	cout << "Height: " << tree.Height() << endl;

	cout << "Verify Red Black Tree..." << endl;
	tree.verify(tree);

	cout << "Remove 1" << endl;
	tree.Remove(1);
	cout << "Height: " << tree.Height() << endl <<endl ;

	cout << "Remove All..." << endl;
	tree.RemoveAll();
	cout << "Height: " << tree.Height() << endl;

	cout << "Verify Red Black Tree..." << endl;
	tree.verify(tree);

	cout << endl;
}