/***************************************** * Instructions * - Replace 'uwuserid' with your uWaterloo User ID * - Select the current calendar term and enter the year * - List students with whom you had discussions and who helped you * * uWaterloo User ID: uwuserid @uwaterloo.ca * Submitted for ECE 250 * Department of Electrical and Computer Engineering * University of Waterloo * Calender Term of Submission: (Winter|Spring|Fall) 201N * * By submitting this file, I affirm that * I am the author of all modifications to * the provided code. * * The following is a list of uWaterloo User IDs of those students * I had discussions with in preparing this project: * - * * The following is a list of uWaterloo User IDs of those students * who helped me with this project (describe their help; e.g., debugging): * - *****************************************/ #ifndef DOUBLE_HASH_TABLE_H #define DOUBLE_HASH_TABLE_H #ifndef nullptr #define nullptr 0 #endif #include "Exception.h" #include "ece250.h" enum bin_state_t { UNOCCUPIED, OCCUPIED, ERASED }; template class Double_hash_table { private: int count; int power; int array_size; int mask; Type *array; bin_state_t *occupied; int h1( Type const & ) const; int h2( Type const & ) const; public: Double_hash_table( int = 5 ); ~Double_hash_table(); int size() const; int capacity() const; double load_factor() const; bool empty() const; bool member( Type const & ) const; Type bin( int ) const; void print() const; void insert( Type const & ); bool erase( Type const & ); void clear(); // Friends template friend std::ostream &operator<<( std::ostream &, Double_hash_table const & ); }; template Double_hash_table::Double_hash_table( int m ): count( 0 ), power( m ), array_size( 1 << power ), mask( array_size - 1 ), array( new Type[array_size] ), occupied( new bin_state_t[array_size] ) { for ( int i = 0; i < array_size; ++i ) { occupied[i] = UNOCCUPIED; } } // Your implementation here template std::ostream &operator<<( std::ostream &out, Double_hash_table const &hash ) { for ( int i = 0; i < hash.capacity(); ++i ) { if ( hash.occupied[i] == UNOCCUPIED ) { out << "- "; } else if ( hash.occupied[i] == ERASED ) { out << "x "; } else { out << hash.array[i] << ' '; } } return out; } #endif