Unordered sets have to pay for their O(1) average access time in a few ways:
set
uses less memory thanunordered_set
to store the same number of elements.- For a small number of elements, lookups in a
set
might be faster than lookups in anunordered_set
. - Even though many operations are faster in the average case for
unordered_set
, they are often guaranteed to have better worst case complexities forset
(for exampleinsert
). - That
set
sorts the elements is useful if you want to access them in order. - You can lexicographically compare different
set
s with<
,<=
,>
and>=
.unordered_set
s are not required to support these operations.