/* * Code modified from Weiss Textbook: http://users.cis.fiu.edu/~weiss/dsaa_c++/Code * Version author: A. Kalyanaraman * Date: 11/22/2011 * For use in Cpt S 223, School of EECS, WSU */ #ifndef QUADRATIC_PROBING_H_ #define QUADRATIC_PROBING_H_ //#include "vector.h" //#include "mystring.h" #include #include #include "globalfunctions.h" using namespace std; // QuadraticProbing Hash table class // // CONSTRUCTION: an initialization for ITEM_NOT_FOUND // and an approximate initial size or default of 101 // // ******************PUBLIC OPERATIONS********************* // void insert( x ) --> Insert x // void remove( x ) --> Remove x // Hashable find( x ) --> Return item that matches x // void makeEmpty( ) --> Remove all items class HashTable_qp { public: explicit HashTable_qp( const string& notFound, int size = 101 ); HashTable_qp( const HashTable_qp & rhs ) : ITEM_NOT_FOUND( rhs.ITEM_NOT_FOUND ), array( rhs.array ), currentSize( rhs.currentSize ) { } const string & find( const string & x ) const; void makeEmpty( ); void insert( const string & x ); void remove( const string & x ); const HashTable_qp & operator=( const HashTable_qp & rhs ); enum EntryType { ACTIVE, EMPTY, DELETED }; private: struct HashEntry { string element; EntryType info; HashEntry( const string & e = string( ), EntryType i = EMPTY ) : element( e ), info( i ) { } }; vector array; int currentSize; const string ITEM_NOT_FOUND; bool isActive( int currentPos ) const; int findPos( const string & x ) const; void rehash( ); }; //#include "QuadraticProbing.cpp" #endif