#ifndef DYNAMIC_DOUBLE_HASH_TABLE_H #define DYNAMIC_DOUBLE_HASH_TABLE_H /***************************************** * UW User ID: uwuserid * Submitted for ECE 250 * Semester of Submission: (Winter|Spring|Fall) 20NN * * By submitting this file, I affirm that * I am the author of all modifications to * the provided code. *****************************************/ #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() { // i did this delete [] array; } template int Dynamic_double_hash_table::size() const { // i did this return array_size; } template int Dynamic_double_hash_table::capacity() const { // i did this int occnum = 0; for ( int i = 0; i < array_size; ++i ) { if (occupied[i] == EMPTY) { occnum++; } } return occnum; } 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