Hash map
Also called: Dictionary, Hash table
A key-value collection that finds a value by its key in constant time on average.
Definition
A hash map turns each key into a number (its hash) and uses it to jump straight to the bucket where the value is stored. Lookups, inserts and deletes are O(1) on average. Swift calls it Dictionary, Kotlin and Java HashMap (Kotlin's mutableMapOf() keeps insertion order with a LinkedHashMap).
In practice
Counting word frequencies: counts[word, default: 0] += 1 in Swift touches each word once, O(n) in total.
Learn it in context
Lessons that use this term.