Index mapping (or direct addressing, or a trivial hash function) in computer science describes using an array, in which each position corresponds to a key in the universe of possible values.
Its effectiveness comes from the fact that an arbitrary position in an array can be examined in constant time.
A trivial hash function is a suitable choice when such data needs to act as a lookup key.
Some examples include: Using a trivial hash function, in a non-iterative table lookup, can eliminate conditional testing and branching completely, reducing the instruction path length of a computer program.
Roger Sayle gives an example[2] of eliminating a multiway branch caused by a switch statement: Which can be replaced with a table lookup: