Talk:cpp/container/unordered multiset
For an ordered multiset it is (obviously) the case that on linear traversal (begin to end) all elements with the same value come one after the other.
Therefore it is possible to retrieve the count for some element value and skip following elements with the same value (or process these in a special ways), i.e. it is easy to "group" elements with the same value on sequential traversal.
How is that for the unordered_set (and same question for the keys in an unordered_map)?
On sequential traversal, are all elements with the same value visited in sequence or is this only the case for all elements in the same bucket (i.e. hashing to the same index), but may these elements be visited in any mix?
Or is even nothing of the above guaranteed for sequential traversal of unordered containers?
If it is not guaranteed that elements with the SAME VALUE are visited one after the other on sequential traversal, I think it should be shortly mentioned (may be it is, but on a different page?), as otherwise it may be an evil pitfall when switching from ordered to unordered sets (or maps) for efficiency reasons, and elements with the same value are processed in "groups" (as described above). Especially as the problem might not show on tests, as long as there are no two values hashing to the same bucket.