如何检查链表数组中的某个链表是否为空
how to check if a certain linked list in an array of linked lists is empty
使用此数据结构:(双向链表数组)
list<string> hashTable [HASH_TABLE_SIZE];
我想使用以下方法检查某个链表是否为空:
Hash HashTable;
if(Hash[hf(word)].empty() == true)
{do this}
这些是我得到的编译错误:
$ make -f makefile.txt
g++ -g -D HASH_TABLE_SIZE=10 -c hash.cpp
hash.cpp: In member function `void Hash::processFile(std::string)':
hash.cpp:19: error: expected primary-expression before '[' token
makefile.txt:6: recipe for target `hash.o' failed
make: *** [hash.o] Error 1
首先你有编译错误。请显示您的哈希.cpp文件的第 19 行。第二:
Hash[hf(word)].empty() == true
是一个不好的比较,你可以只使用
if ( Hash[hf(word)].empty() )
第三:list是一个动态结构,所以,我认为,最好使用指向list的指针数组:
list<string> * hashTable[HASH_TABLE_SIZE]
相关文章:
- 我当前实现的双向链表类是否需要重构迭代器 end() 功能?
- 测试双向链表是否形成算术级数
- 是否可以创建带有索引但没有指针的单个链表?
- 给定一个创建的带有货物的链表,我需要使用函数检查实际序列或"train"是否有效
- 如何在用于删除节点的函数中检查我的链表是否C++为空
- 链表的这个别名运算符是否会产生深度复制
- 是否可以将新的列表节点分配给链表的现有节点
- 是否可以从 const 方法迭代链表
- 如何检查链表中的数据是否存在C++
- 不太确定如何从这里继续前进.是否使用链表进行搜索
- 查找链表是否为循环列表
- 如何检查元素是否存在于 c++ 中的链表中
- 对象数组作为链表中的字符数组 - 我对对齐的假设是否有效
- 测试链表是否彼此相等
- 如何检查链表数组中的某个链表是否为空
- 如何使用 c++ 检查链表是否排序
- 正在搜索“链表”是否为空
- 在C++中检查链表是否为空
- 如何检查链表是否内存不足/已满
- 检查链表是否为回文