HashMaps
HashMaps?
- A
HashMaps
are a type ofmap
. Maps
are collections ofkey-value pairs
that aresearchable
.Maps
are unordered.Maps
store and retrieve data using the keys to identify entries.Keys
must be unique. They cannot be changed(=immutable) e.g> <k:A, v:3> <k:A, v:4> CANNOT exist in the same mapValues
are not unique, and therefore, they can be changed(=mutable) e.g> <k:A, v:3> <k:B, v:3> CAN exist in the same mapMaps
also sometimes calleddictionaries
.- A real life example of
KVpairs
is phone numbers and names.
Phone Number = KEY
Name = VALUE
Map ADT
Methods:
- V put(<K, V>)
- V get(K)
- V remove(K)
- int size()
SIZE
refers to the number of entries, nCAPACITY
refers to the length of the backing array, N
Leave a comment