A hash table or hash map is a data structure that uses a hash function to map keys (e.g. a person's name), to their associated values (e.g. their address). Thus, a hash map implements an associative array. A hash function is used to transform the key into the index of an array element where the corresponding value is stored.

In many situations, the lookup of elements within hash tables turns out to be more efficient than within arrays - even if the hash map building time is taken into account. In a well-dimensioned hash table, the average lookup time is independent of the number of elements stored in the table.

The following operations are used to manipulate and access maps:

OperationDescription
buildMap()Build a map from an array.
setMapValue()Update the value of a specific key.
getMapValue()Get the value of a specific key.
getMapEntries()Get all map entries to an array.
removeMapValue()Remove the entry corresponding to a specific key.

The following sections describe the above operations in more detail.

  • No labels