-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHashTable.hh
40 lines (32 loc) · 1.02 KB
/
HashTable.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// -----------------------------------------------------------------
// Basic hash table as a chained list of nodes
#ifndef _HASHTABLE_HH
#define _HASHTABLE_HH
#include <vector>
#include <cstddef> // Now needed for NULL in C++11...
// -----------------------------------------------------------------
// -----------------------------------------------------------------
// Struct of a node in a slot in the hashtable
// Seems to reduce object-oriented overhead compared to a class
struct node {
unsigned int value;
node* next;
};
// Class declaration for HashTable
class HashTable {
public:
// Constructor, destructor
HashTable(unsigned int tableNumber);
HashTable();
~HashTable();
// Member functions
void insert(unsigned int site);
bool find(unsigned int site);
// Member data
unsigned int size;
unsigned int tableNumber;
unsigned int mod;
std::vector<node*> table; // Vector of lists of nodes
};
#endif
// -----------------------------------------------------------------