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.
typedefunsignedint 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){
}