I'm trying to make a templated HashTable Class that uses Seperate Chaining for collision resolution. My problem is that I don't know how to iterate through the list at specific array index's because I am unsure of the syntax.
I keep getting error C2228: left of '.end' must have class/struct/union and error C2228: left of '.push_front' must have class/struct/union
I've declared my list as a private member of the class like so:
list<T1> **List;
And have used the default constructor to pre-fill each index with a for loop.
Here is the trouble points :
template <typename T1>
void HashTable<T1>::Insert(T1 var)
{
int index = HashFunction(var);
List[index].push_front(var);
++LF;
cout << "Load Factor: " << LF << endl << endl;
}
template <typename T1>
void HashTable<T1>::Delete(string key)
{
int visited = 0;
list<T1>::iterator iter;
for(int i = 0; i < prime; ++i)
{
iter = List[i].begin();
while((iter != List[i].end) && ((*iter)->getKey() != key)) //While iter is not at the end of the list and while ID of iter is not equal to ID being obliterated
What am I doing wrong?
It looks to me like you want just a single array of lists. Right now List[i] returns a pointer to a list<T1>, whereas you may intend List[i] to be a list<T1> itself.
Try using