# Understanding HashMap

**URL:** <https://forum.dfinity.org/t/understanding-hashmap/17872>\
**Category:** Language Support\
**Tags:** Motoko, Education\
**Created:** [January 9, 2023, 10:52am UTC](https://forum.dfinity.org/t/understanding-hashmap/17872 "2023-01-09T10:52:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vampyr](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@vampyr](https://forum.dfinity.org/u/vampyr)\
**Post date:** [January 9, 2023, 10:52am UTC](https://forum.dfinity.org/t/understanding-hashmap/17872/1 "2023-01-09T10:52:37Z")

</div>

```auto
type Id = Nat32;

  type Post = {
    creater : Text;
    title : Text;
    content : Text;
  };

let posts = Map.HashMap<Id, Post>(
    0,
    Nat32.equal,
    func(a : Nat32) : Nat32 { a },
  );

```

```auto
Map.HashMap<Id, Post>(
    0,
    Nat32.equal,
    func(a : Nat32) : Nat32 { a },

```

what does this Map actually do, there’s not many examples, also what is the best way to store objects? In array or a list? Also trying to figure about how to update a post content provided by an id in function. Thanks !

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [January 9, 2023, 2:18pm UTC](https://forum.dfinity.org/t/understanding-hashmap/17872/2 "2023-01-09T14:18:48Z")

</div>

I’d recommend [GitHub - ZhenyaUsenko/motoko-hash-map: Stable hash maps for Motoko](https://github.com/ZhenyaUsenko/motoko-hash-map) as you will get much better performance.

It has both sets and key value maps. It makes getting a value out of a big list much faster by using indexing by key. Your code won’t have to search through the whole list to find the item.
