/***************************************** * 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 DYNAMIC_DOUBLE_HASH_TABLE_H #define DYNAMIC_DOUBLE_HASH_TABLE_H #ifndef nullptr #define nullptr 0 #endif #include "Exception.h" #include "ece250.h" enum state { EMPTY, OCCUPIED, DELETED }; template class Dynamic_double_hash_table { private: int power; int count; int deleted_count; int array_size; int initial_size; Type *array; state *occupied; int h1( Type const & ) const; int h2( Type const & ) const; public: Dynamic_double_hash_table( int = 5 ); ~Dynamic_double_hash_table(); int size() const; int capacity() const; double load_factor() const; double deleted_factor() const; bool empty() const; bool member( Type const & ) const; Type bin( int ) const; void print() const; void insert( Type const & ); bool remove( Type const & ); void clear(); // Friends template friend std::ostream &operator<<( std::ostream &, Dynamic_double_hash_table const & ); }; template Dynamic_double_hash_table::Dynamic_double_hash_table( int m ): power( m ), count( 0 ), deleted_count( 0 ), array_size( 1 << power ), initial_size( 1 << power ), array( new Type[array_size] ), occupied( new state[array_size] ) { for ( int i = 0; i < array_size; ++i ) { occupied[i] = EMPTY; } } template Dynamic_double_hash_table::~Dynamic_double_hash_table() { // enter your implementation here } template int Dynamic_double_hash_table::size() const { // enter your implementation here return 0; } template int Dynamic_double_hash_table::capacity() const { // enter your implementation here return 0; } template double Dynamic_double_hash_table::load_factor() const { // enter your implementation here return 0.0; } template double Dynamic_double_hash_table::deleted_factor() const { // enter your implementation here return 0.0; } template bool Dynamic_double_hash_table::empty() const { // enter your implementation here return true; } template int Dynamic_double_hash_table::h1( Type const &obj ) const { int result = static_cast( obj ) & (array_size - 1); return result < 0 ? (result + array_size) : result; } template int Dynamic_double_hash_table::h2( Type const &obj ) const { int result = (static_cast( obj ) / array_size) & (array_size - 1); return (result < 0) ? ((result + array_size) | 1) : (result | 1); } template bool Dynamic_double_hash_table::member( Type const &obj ) const { // enter your implementation here return false; } template Type Dynamic_double_hash_table::bin( int n ) const { // DO NOT CHANGE return array[n]; } template void Dynamic_double_hash_table::insert( Type const &obj ) { // enter your implementation here } template bool Dynamic_double_hash_table::remove( Type const &obj ) { // enter your implementation here return false; } template void Dynamic_double_hash_table::clear() { // enter your implementation here } // You can modify this function however you want: it will not be tested template std::ostream &operator<<( std::ostream &out, Dynamic_double_hash_table const &list ) { return out; } // Is an error showing up in ece250.h or elsewhere? // Did you forget a closing '}' ? #endif