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

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Yogita Misal
Yogita Misal

No responses yet

Write a response