I'm looking to store some kind of map between
usize. I'd like it to be as fast as possible, as I'll be going through a lot of these. The obvious option is
[usize; 256], using
usuze::MAX to represent unset values, but that does waste a lot of memory, which could lead to low memory locality, which wouldn't be ideal. I've also considered
Vec<(u8, usize)> which may save space, but is slow to access and by using heap allocation gives up memory locality entirely. A hash map without actually hashing seems like it might be ideal, especially since most commonly I'll have
b'a' to b
'z' is my values, so a map size of 32 would give no collisions.
Does a better data structure exist for me than just an array?