Ejemplo n.º 1
0
void Test1()
{
	HashTaable<int> ht1(10);
	ht1.Insert(1);
	ht1.Insert(2);
	ht1.Insert(3);
	ht1.Insert(4);
	ht1.Insert(5);
	ht1.Insert(6);
	ht1.Insert(7);
	ht1.Insert(8);

	ht1.Insert(89);
	ht1.Insert(18);
	ht1.Insert(49);
	ht1.Insert(58);
	ht1.Insert(9);
	ht1.PrintTable();
	//ht1.Remove(8);
	ht1.Remove(9);
	ht1.PrintTable();
	if (ht1.Find(8))
		cout << "pass" << endl;
	else
		cout << "false" << endl;


}
Ejemplo n.º 2
0
void Test2()
{
	HashTaable<string> ht1(10);//使用仿函数解决这个问题
	ht1.Insert("小明");
	ht1.Insert("小军");
	ht1.Insert("杰克");
	ht1.Insert("明小");

	ht1.PrintTable();
}
Ejemplo n.º 3
0
void HashTableTest()
{
	HashTableBucket<int,int> ht;
	ht.Insert(1,1);
	ht.Insert(11,11);
	ht.Insert(21,21);
	ht.Insert(12,12);
	ht.Insert(23,23);
	ht.Insert(54,57);
	ht.Insert(42,12);
	//ht.Print();
	HashTableBucket<int,int> ht1(ht);
	//ht1.Print();

	HashTableBucket<int,int> ht2;
	ht2 = ht1;
	ht2.Print();

}
Ejemplo n.º 4
0
	void TestHashTable()
	{
		HashTable<int> ht1(10);
		ht1.Insert(89);
		ht1.Insert(18);
		ht1.Insert(49);
		ht1.Insert(58);
		ht1.Insert(9);

		ht1.Print();

		//ht1.Remove(89);
		//ht1.Remove(9);
		//ht1.Print();

		//int pos = ht1.Find(18);
		//pos = ht1.Find(9);
		//pos = ht1.Find(14);
	}