What is Hashmaps?

<aside> 💡 Hashmap is data structure that is indexed. Hashmap use hash function to calculate index with the key into ember or slot.

The value that is mapped to bucket with the proper index. The key is unique and consistent. In Python, Dictionary is one of the examples of Hashmaps

</aside>

Implementation

def printdict(d):
		for key in d:
				print(key, "->", d[key])

# 0 is key
# 'first' is value from 0 or 'first' is value from key
hashmaps = {0: 'first', 1: 'second', 2: 'third'}
printdict(hashmaps)
print()

hashmaps[3] = 'fourth'
printdict(hashmaps)
print()

hashmaps.popitem()
printdict(hashmaps)
0 -> first
1 -> second
2 -> third

0 -> first
1 -> second
2 -> third
3 -> fourth

0 -> first
1 -> second
2 -> third