#ifndef SEPARATE_CHAINING_H #define SEPARATE_CHAINING_H #include #include #include #include #include using namespace std; int nextPrime( int n ); // SeparateChaining Hash table class // // CONSTRUCTION: an approximate initial size or default of 101 // // ******************PUBLIC OPERATIONS********************* // bool insert( x ) --> Insert x // bool remove( x ) --> Remove x // bool contains( x ) --> Return true if x is present // void makeEmpty( ) --> Remove all items template class HashTable { public: explicit HashTable( int size = 101 ); bool contains( const HashedObj & x ) const; void makeEmpty( ); bool insert( const HashedObj & x ); bool insert( HashedObj && x ); bool remove( const HashedObj & x ); private: vector> theLists; // The array of Lists int currentSize; void rehash( ); size_t myhash( const HashedObj & x ) const; }; #endif