Hello,
I know how to create a hash_map and use my hash function with it, but I don't know how to handle collisions. Specifically, how would I implement a chain/buckets with a linked list... it seems like it's built in but I can't find how to do it.
#include <iostream>
#include <string>
#include <ext/hash_map>
#include "d_hashf.h"
using namespace __gnu_cxx;
int main()
{
typedef hash_map<string, string, hFstring> hash_class;
hash_class extensions;
hash_class::iterator itr;
extensions["Test1"] = "HAHAHA";
extensions["Test1"] = "HoHoHo";
extensions["Test1"] = "HeHEHe";
for(itr = extensions.begin(); itr != extensions.end(); itr++)
cout << (*itr).first << (*itr).second << endl;
cout << extensions["Test1"] << endl;
extensions.erase("Test1");
if (extensions.find("Test1") == extensions.end())
cout << "NULL" << endl;
}
Here's some example code, if anyone would like to see... What I'll end up doing is creating 1373 buckets to store 25,000+ dictionary words. I'd like to know how to limit the number of buckets to 1373 and implement chaining.