【发布时间】:2015-01-20 10:03:18
【问题描述】:
我正在尝试制作一个模板化的 HashTable 类,该类使用单独的链接来解决冲突。我的问题是我不知道如何遍历特定数组索引处的列表,因为我不确定语法。
我不断收到错误 C2228:“.end”左侧必须有类/结构/联合 和错误 C2228:'.push_front' 的左侧必须有类/结构/联合
我已将我的列表声明为类的私有成员,如下所示:
list<T1> **List;
并且已经使用了默认的构造函数来用for循环预填充每个索引。
这里是麻烦点:
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
我做错了什么?
【问题讨论】:
标签: c++ arrays stl listiterator