Index mapping
Appearance
Index mapping is a computer science term used to describe the mapping of raw data, used directly as in array index, on an array.
Examples
The technique can be most effective for mapping data with a small range. If the array encompasses all combinations of input, a range check is not required.
C example
This example[1] of a C function - returning TRUE if a month (x) contains 30 days (otherwise FALSE), illustrates the concept succinctly
if ((unsigned)x > 11) return 0; /*x>12?*/ static const int T[12] ={0,0,0,0,1,0,1,0,0,1,0,1}; /* 0-based table 'if 30 days =1,else 0' */ return T[x]; /* return with boolean 1 = true, 0=false */
See also
References
- ^ "A Superoptimizer Analysis of Multiway Branch Code Generation" by Roger Anthony Sayle
External links
- A Superoptimizer Analysis of Multiway Branch Code Generation by Roger Anthony Sayle