I am trying to use a list and iterate through it to find a word and delete the word from the list

I am trying to use a list with a hash table to find an occurrence of a word and delete it from the table. The hashtable list is initilized as list<string>::hashTable[HASH_TABLE_SIZE] in a header file where the HASH_TABLE_SIZE is inputted by the user. In the code below I am attempting to iterate through the list and then delete the first occurence of a word... any ideas I currently get an infinite loop?

for(list<string>::iterator i = Hash::hashTable[0].begin(); i!=Hash::hashTable[HASH_TABLE_SIZE].end(); i++)
int count=0;
Last edited on
¿do you have a connection between the end of each list and the beginning of the next one? (for example, from hashTable[0].end() to hashTable[1].begin())

nevermind that Hash::hashTable[HASH_TABLE_SIZE].end() is invalid as you are trying to access past the end of the array.

> list<string>::hashTable[HASH_TABLE_SIZE]
weird syntax, ¿is `hashTable' a static member of your own list class?

> in a header file where the HASH_TABLE_SIZE is inputted by the user.
std::cin >> HASH_TABLE_SIZE;
#include "some_header.h" 
still HASH_TABLE_SIZE should be constant, ¿how could the user modify it?

> Hash::hashTable[0].begin();
wait, now `hashTable' is a static member of Hash...
or Hash is a super class of list...

¿could you post some actual example instead of random bits that you thought were relevant?
Registered users can post here. Sign in or register to post.