void HashTable<E>::insert( const E & x ) { int currentPos = findPos( x ); if( isActive( currentPos ) ) return; array[ currentPos ] = HashEntry( x, ACTIVE ); if( ++currentSize > array.size( ) / 2 ) rehash( ); }
void HashTable<Object>::insert( const Object & x ) { // Insert x as active int currentPos = findPos( x ); if( isActive( currentPos ) ) throw DuplicateItemException( ); array[ currentPos ] = HashEntry( x, ACTIVE ); if( ++occupied > array.size( ) / 2 ) rehash( ); }
bool HashTable<HashObj>::insert ( const HashObj & x){ std::cout<< "Entering insert function" << std::endl; int currentPos = findPos( x ); if( isActive( currentPos ) ) return false; array[currentPos] = HashEntry(x,ACTIVE); int half = array.size()/2; if( ++currentSize > half ) //Test if the array is over half full rehash(); //rehash the table with the new value return true; }
void QuadraticHashTable<HashedObj>::insert( const HashedObj & x ) { // Insert x as active int currentPos = findPos( x ); if( isActive( currentPos ) ) { array[currentPos].count++; return; }//if array[ currentPos ] = HashEntry( x, ACTIVE ); // Rehash; see Section 5.5 //if( ++currentSize > array.size( ) / 2 ) //rehash( ); }