哈希表是否允许重复值?

2 c++ algorithm hashtable

假设我有一个哈希表arr [1..n],一组键k1,k2,k3(密钥的数量)等等.哈希函数h(k)

h(k)取输入k并给出输出i作为arr [i]的索引.

现在在哈希的线性探测概念中,让我们考虑一下场景.

1> let k1=101 and h(k)=i=5, then k1(101) is stored in arr[5]

2> let k2=102 and h(k)=i=6 then k1(102) is stored in arr[6]

3>Now again k3=101 and h(k)=i=5 then by linear probing it will go one
step ahead(i=i+1) and check a[i](a[6]) is free or not, since a[6] is not free 
so we repeat again (i=i+1) and check a[i](a[7]) is free or not, since a[7] is free
so k3(101) is again inserted at arr[7].
Run Code Online (Sandbox Code Playgroud)

现在arr [5]和arr [7]可能是重复的,它们属于同一个键.

哈希表是否允许重复?我的理解是否正确.

如果我错了,请核实我

Vla*_*cow 6

在C++中,有两个哈希容器允许重复.他们是std::unordered_multisetstd::unordered_multimap.