Introduction

Hel|

Hash map

Introduction

This is part of my attempt to revisit all the basic data structure that i should have known.

About

Hash map is a typical implementation for various map functionality in different languages, in go, this is the default implementation of map.

Hash map is build upon multiple bucket where each bucket contains linkedlist. Each bucket is chosen based using this formula

bucket_id = hash(key) mod cap

hash = hash function
key = key of the map data
cap = capacity of the hashmap

For example
cap = 4
key = apple
hash(apple) = 15
bucket_id = 15 mod 4
          = 3
So the data should be inserted into bucket 3

This data structure of chained linked list hash map allows collision handling and O(1) read and write as long as the hash function space and hash capacity is big enough.