You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
996 B
C++

TestQuadraticProbing.cpp - Test program for quadratic probing hash tables
#include <iostream.h>
#include "QuadraticProbing.h"
// Simple main
int main( )
{
int ITEM_NOT_FOUND = -9999;
HashTable<int> H( ITEM_NOT_FOUND );
const int NUMS = 4000;
const int GAP = 37;
int i;
cout << "Checking... (no more output means success)" << endl;
for( i = GAP; i != 0; i = ( i + GAP ) % NUMS )
H.insert( i );
for( i = 1; i < NUMS; i += 2 )
H.remove( i );
for( i = 2; i < NUMS; i +=2 )
if( H.find( i ) != i )
cout << "Find fails " << i << endl;
for( i = 1; i < NUMS; i += 2 )
{
if( H.find( i ) != ITEM_NOT_FOUND )
cout << "OOPS!!! " << i << endl;
}
return 0;
}