...

/

unordered_map vs unordered_set

unordered_map vs unordered_set

This lesson will discuss the difference between unordered_map and unordered_set and look at some of their key features.

Introduction

Before solving any challenges regarding Hash Tables, it is necessary to look at the implementations of unordered_map, and unordered_set and see how they are different. Both are implemented in C++ STL. It is also a common misconception that these two structures are the same, but they are very different from each other.

🔍 unordered_map

unordered_map is a container which is implemented using the Map interface. It stores an element in the form of key-value pairs; it maps the values to keys.

It provides the basic functionality of hashing along with some helper functions that help in the process of insertion, deletion, and search.

Some of the key features of unordered_map are given below:

  • An unordered_map stores key-value pairs (examples given below) to map a key to the value:

abc>123abc->123 ...