Does the C ++ standard define a bucket structure for unordered_set?

When the hash value is calculated for the element in unordered_set, it is placed in the "bucket" along with other - different elements, but the same hash value.

My experience is that items in such a bucket are stored in a singly linked list. Meaning, it gets very slow when searching inside a bucket with a bad hash function.

Is a linked list requirement a standard, or just one possible implementation? Is it possible to implement unordered_setwith setlike buckets?

+4
source share
1 answer

, .

N4140 §23.2.5 [unord.req]/1

. , .

, , .

N4140 §23.2.5 [unord.req]/9

. - . , . , , , .

std::set , , set, .

: set /operator< ( ), . , .

, , , , . , , , , .

+3

Source: https://habr.com/ru/post/1660010/


All Articles