Hey, guys. I'm working on making a simple Hash table, and I'm using vectors. The problem I'm having is whenever I try and search through a list, like below.
(this is the funtion that will insert an item into the table)
The seg fault happens at the if statement, and I'm getting this same error every time I use that if statement. the bucket is correct, and the capacity should be 30. Any ideas? Do you need to see more code?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void HashTable::insert(string name){
long bucket = hashFunction(name);
for(int i = 0; i < this->size; i++){
if(list[bucket].at(i).find(name)!= string::npos)
{
cout<<"name was found, cannot insert"<<endl;
cout<<"bucket: "<<bucket<<" name: "<<name<<endl;
}else{
cout<<"name was not found"<<endl;
list[bucket].at(i) = name;
this->numEntries++;
}
}
}