Hash Table using map and structrure

if anyone could tell me how to program an insert/ collision tracker using a map, bucket struct with openaddressing and seperate chaining using a singly linked list i would be in awe. i have been struggling and asking for a few days and no one is responding.
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
41
42
43
44
45
46
47
typedef unsigned int unint;

//this bucket is used by the open addressing table
struct openBucket{
  bool collision;//whether or not there was a collision at this field
  string entry_;
};

//this bucket is used by the seperate chaining table
struct chainBucket{
  bool collision;//whether or not there was a collision at this field
  List *bucketList;
};

class HashTables{
private:
  std::unordered_map<unint,openBucket> openAddressTable;
  std::unordered_map<unint,chainBucket> chainingTable;


void HashTables::addToOpenAddress(unint inputHash, std::string text){
//idk if this is how its done. 	
openCollisions = 0;
	int size = openAddressTable.size();
	for (int i = inputHash; i < size; i++) {
		if (openAddressTable[i].entry_==text) {
			openAddressTable[i].collision = true;
			i++;
			openCollisions++;
		}
		else {
			openAddressTable.insert =  new openBucket;
			openAddressTable[i].entry_ = text;
		}
	}
}

//TODO
// finish this function to add an element to the separate chaining table
// this tables tracks collisions with linked lists
// if a collision occurs,
// - edit collision boolean for current location
// - add to linked list
// else add new chainBucket to position
void HashTables::addToChaining(unint inputHash, std::string text){
	
}
Read this tutorial: http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_hashtable.aspx
It covers separate chaining and open addressing.
Topic archived. No new replies allowed.