Can you recognise this pattern?

Hasmap and Hashtable

Hashmap is non-syncronized and is not thread safe while HashTable is thread safe and is synchronised.

Yogita Misal
Aug 4, 2023

--

Hashmap is faster than Hashtable .

Hashmap allows one null keys and values can be null .

Hashtable doesn’t allow null key or value .

Hashmap iterator is fail-safe where Hash Table iterator is not fail-safe.

What are their implementation??

It is type of containers which store data with key-value combination.

It means particular data will have an special key and the value associated with this key .

The implementation of Hashtable on c++ is unordered_map<> and the implementation of map on CPP is map<>.

This means if you need keys to be sorted then it is better to use map<> , otherwise use unordered_map<> .

unordered map constructs

We can construct many ways like above .

For example Two Sum Leetcode solution:

Solution
Rewrite in this passion

--

--

Yogita Misal
Yogita Misal

No responses yet