> When is the last time you wish you could define an array where the indices are from a custom finite set, perhaps a range 100 to 200, perhaps an enum?
> ...
> The lack of this ability makes programmers use more general hash maps by default and therefore leave performance on the table.
You can simulate this in any language by hash-mapping the custom set elements to indices. (And in the general case, you won't be able to determine the indices faster than a hash table lookup.)
In fact, I imagine there are languages and implementations where hash table lookup is the fastest way to map 'a':'z' to 0:25.
In fact, let me try a (surely totally bogus) micro-benchmark right now:
$ python -m timeit --setup 'lookup = dict(zip("abcdefghijklmnopqrstuvwxyz", range(26)))' '[lookup[x] for x in "abcdefghijklmnopqrstuvwxyz"]'
500000 loops, best of 5: 884 nsec per loop
$ python -m timeit '[ord(x) - 97 for x in "abcdefghijklmnopqrstuvwxyz"]'
200000 loops, best of 5: 1.21 usec per loop
Huh....And surely if you use the hash map directly, instead of using it to grab an index into another container, overall performance only gets better (unless maybe you need to save per-instance memory, and you have multiple containers using the same custom index scheme).
Hash tables are a pretty neat idea.