# HashMap in java vs unordererd map in c++

**URL:** <https://discuss.codechef.com/t/hashmap-in-java-vs-unordererd-map-in-c/14540>\
**Category:** general\
**Tags:** hashing\
**Created:** [May 1, 2017, 1:16pm UTC](https://discuss.codechef.com/t/hashmap-in-java-vs-unordererd-map-in-c/14540 "2017-05-01T13:16:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![va1ts7\_100](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@va1ts7\_100](https://discuss.codechef.com/u/va1ts7_100)\
**Post date:** [May 1, 2017, 1:16pm UTC](https://discuss.codechef.com/t/hashmap-in-java-vs-unordererd-map-in-c/14540/1 "2017-05-01T13:16:07Z")

</div>

Hi Everyone,

I see plenty of interview questions where HashMap is used frequently. Can I use unordered map in c++ which i guess is pretty same as hashmap in java. Or is there any other way to implement way hashmap in c++.Because I need to store some pointers in map , that is why I prefer to incline towards c++ map rather than java hashmap…!

---

<div class="post-metadata">

**Author:** ![anon85470456](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@anon85470456](https://discuss.codechef.com/u/anon85470456)\
**Post date:** [May 1, 2017, 1:34pm UTC](https://discuss.codechef.com/t/hashmap-in-java-vs-unordererd-map-in-c/14540/2 "2017-05-01T13:34:01Z")

</div>

In C++ unordered\_map should work fine for this.

You may also use simply C++ STL map, but I guess map performs slower in some cases compared to unordered\_map

---

<div class="post-metadata">

**Author:** ![raja379](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@raja379](https://discuss.codechef.com/u/raja379)\
**Post date:** [May 1, 2017, 4:19pm UTC](https://discuss.codechef.com/t/hashmap-in-java-vs-unordererd-map-in-c/14540/3 "2017-05-01T16:19:50Z")

</div>

Yes, HashMap in java and unordered\_map in c++ stl are more or less the same… you can store pointers in java too(Don’t forget, in java, everything you deal with is a reference)… hence, HashMap also serves your purpose.

---

<div class="post-metadata">

**Author:** ![marshal\_roxx](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@marshal\_roxx](https://discuss.codechef.com/u/marshal_roxx)\
**Post date:** [May 2, 2017, 11:53am UTC](https://discuss.codechef.com/t/hashmap-in-java-vs-unordererd-map-in-c/14540/4 "2017-05-02T11:53:13Z")

</div>

unordered\_map will do your purpose as well as hashmap in java will do . unordered map will be faster on operations like insertion and deletion than map in c++ but map possesses some extra useful characteristics such as for the elements are in sorted order , we can traverse from start to finish .

---

<div class="post-metadata">

**Author:** ![va1ts7\_100](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@va1ts7\_100](https://discuss.codechef.com/u/va1ts7_100)\
**Post date:** [May 1, 2017, 6:03pm UTC](https://discuss.codechef.com/t/hashmap-in-java-vs-unordererd-map-in-c/14540/5 "2017-05-01T18:03:06Z")

</div>

plz be sure before you post your answers 😉

---

<div class="post-metadata">

**Author:** ![va1ts7\_100](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@va1ts7\_100](https://discuss.codechef.com/u/va1ts7_100)\
**Post date:** [May 1, 2017, 6:03pm UTC](https://discuss.codechef.com/t/hashmap-in-java-vs-unordererd-map-in-c/14540/6 "2017-05-01T18:03:38Z")

</div>

thanks… 🙂

---

<div class="post-metadata">

**Author:** ![anon85470456](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@anon85470456](https://discuss.codechef.com/u/anon85470456)\
**Post date:** [May 1, 2017, 6:08pm UTC](https://discuss.codechef.com/t/hashmap-in-java-vs-unordererd-map-in-c/14540/7 "2017-05-01T18:08:53Z")

</div>

sure as in?
