Skip to content

Instantly share code, notes, and snippets.

@henders
Created January 25, 2012 22:41
Show Gist options
  • Save henders/1679340 to your computer and use it in GitHub Desktop.
Save henders/1679340 to your computer and use it in GitHub Desktop.
homework
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