Unordered sets have to pay for their O(1) average access time in a few ways:
setuses less memory thanunordered_setto store the same number of elements.- For a small number of elements, lookups in a
setmight 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
setsorts the elements is useful if you want to access them in order. - You can lexicographically compare different
sets with<,<=,>and>=.unordered_sets are not required to support these operations.