Created
January 25, 2012 22:41
-
-
Save henders/1679340 to your computer and use it in GitHub Desktop.
homework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class intListElement { | |
public: | |
int num; | |
intListElement * next; | |
}; | |
class intHashTable { | |
private: | |
int size; | |
intListElement ** table; | |
public: | |
intHashTable(int size); | |
~intHashTable(); | |
void insert(int num); | |
void remove(int num); | |
int lookup(int num); | |
void print(void); | |
}; | |
// construct a new hash table with nelements elements | |
intHashTable::intHashTable(int nelements) | |
{ | |
size = nelements; | |
table = new intListElement*[size]; | |
for( int i = 0; i < size; i++) { | |
table[i] = 0; | |
} | |
} | |
void intHashTable::print() | |
{ | |
for(int i = 0; i < size; i++) { | |
cout << table[i] << endl; | |
} | |
} | |
void intHashTable::insert(int num) | |
{ | |
int location = ((unsigned)num) % size; | |
cout << "here\n"; | |
table[location]->num = 4; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment