Mapping Single Characters to Multiple Values

Compact arrays are still basically just that—arrays to which compression and indexing have been applied. Like regular arrays, they are best suited to storing values that are all the same size. They also work best when the values being mapped to are relatively small; a big array of 32-byte values, for example, can become quite unwieldy.

But what if you're looking up a value that is large, or could be of variable length? A couple of techniques can be used.

If the total universe of values that can be mapped to is relatively small, you can save space without imposing too huge a performance penalty by offloading the target values into a separate array (or other data structure). The target values in the ...

Get Unicode Demystified now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.