我试着用矢量实现哈希表。我的表规模将在构造函数中定义,例如让说表的大小为31,创建哈希表我做如下:使用矢量C++实现哈希表
vector<string> entires; // it is filled with entries that I'll put into hash table;
vector<string> hashtable;
hashtable.resize(31);
for(int i=0;i<entries.size();i++){
int index=hashFunction(entries[i]);
// now I need to know whether I've already put an entry into hashtable[index] or not
}
有没有人帮我,我怎么能做到这一点?
这是你的真实密码?我可以发现至少2个错误(一个丢失的右括号和你拼错的条目) – Borgleader
@Borgleader nope我只是写了一些简单的一部分。对于错别字 – TheGost
@TheGost检查是否散列表[索引] .empty()'?我不明白你是如何计划用矢量实现一个哈希表的。你会做什么2个不同的条目散列到相同的索引? – Praetorian