Purifying flames Purifying flames - 3 months ago 33
C++ Question

Comparing unordered_map vs unordered_set

First of all, what is the main difference between them?

The only thing i've found is that

has no operator
How should i access an element in
, since there is no

Which container is using random access to memory(or both)?

And which one of them faster in any sense or using less memory?


They are nearly identical. unordered_set only contains keys, and no values. There is no mapping from a key to a value, so no need for an operator[]. unordered_map maps a key to a value.

You can use the various find methods within unordered_set to locate things.