Im making a separate chaining hash table for dictionary words. In my insert method i use find to make sure there isnt a duplicate. Every thing compiles but my program stops at the find statement and quits working. If i omit the find method, which ok for the first word because there is no duplicate as of yet, it stops on the push back method for some weird reason. If someone could point out to me why it does this it would be greatly appreciated. I can post more of the code if needed.
Note:I also am not sure if my constructor is wrong or not.
//insert
bool DictHash::insert(const string &x)
{
list<string> &newList = wordList[myHash(x)];
if(find(newList.begin(), newList.end(), x)!= newList.end())
{
return false;
}
newList.push_back(x);
if(++currentSize > wordList.size())
rehash();
return true;
}
//constructor
DictHash::DictHash(int size)
{
vector<list<string> > wordList[size];
}
//main
using namespace std;
int main()
{
ifstream infile("file name");
DictHash *dictionary;
dictionary = new DictHash(102001);
if(infile.is_open())
{
while(infile.good())
{
string word;
getline(infile, word);
cout<<word<<endl;
dictionary->insert(word);
}
infile.close();
}
return 0;
}