encyclopegia.org

Index mapping

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.[src] The technique is most effective when the universe of keys is reasonably small, such that allocating an array with one position for every possible key is affordable.[src] Its effectiveness comes from the fact that an arbitrary position in an array can be examined in constant time.[src]

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.[src] The technique is most effective when the universe of keys is reasonably small, such that allocating an array with one position for every possible key is affordable.[src] Its effectiveness comes from the fact that an arbitrary position in an array can be examined in constant time.[src] ==Applicable arrays== There are many practical examples of data whose valid values are restricted within a small range.[src] A trivial hash function is a suitable choice when such data needs to act as a lookup key.[src] Some examples include: month in the year (1–12) day in the month (1–31) day of the week (1–7) human age (0–130) – e.g.[src] lifecover actuary tables, fixed-term mortgage ASCII characters (0–127), encompassing common mathematical operator symbols, digits, punctuation marks, and English language alphabet ==Examples== 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.[src] ===Avoid branching=== Roger Sayle gives an example of eliminating a multiway branch caused by a switch statement: inline bool HasOnly30Days(int m) { switch (m) { case 4: // April case 6: // June case 9: // September case 11: // November return true; default: return false; } } Which can be replaced with a table lookup: inline bool HasOnly30Days(int m) { static const bool T[] = { 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 }; return T[m-1]; } ==References==[src]

11 sentences · 11 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Index mapping." encyclopegia.org, 2024, https://encyclopegia.org/wiki/index-mapping. Accessed 29 November 2026.

Chicago

"Index mapping." encyclopegia.org. Accessed November 29, 2026. https://encyclopegia.org/wiki/index-mapping.

APA

encyclopegia.org. (2024). Index mapping. Retrieved November 29, 2026, from https://encyclopegia.org/wiki/index-mapping

Accessed November 29, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Index Librorum Prohibitorum

stub · references available

Roud Folk Song Index

stub · references available

stock market index

stub · references available

color index

stub · references available

Hoover index

stub · references available

AMX index

stub · references available

ramp travel index

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1235533517 · 0.5 · snapshot enwiki-001235533517

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners
  • Index — every corpus, paper and record
  • Estate guide — what a public data estate is
  • Founder — Lois-Kleinner Alpasan
  • Records — DOIs and external deposits
  • Documents — one-pagers, PDFs and QR codes
  • Brand kit — logos and share images
  • Papers — plain-language briefs with citations
  • Browser — search engine, PWA and bookmarklet
  • Anticloud — the operator and its projects

As seen in Business Insider · 336 outlets · evidence DOIs · plain-language papers

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.