Purifying flames Purifying flames - 1 year ago 167
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download