I have a program that needs to do a *compile time checkable** map from one known set of values to another known set of values:
in out ------------ 8 37 10 61 12 92 13 1/4 109 15 1/4 151 etc
This would be easy if the inputs were either integers or evenly spaced. I'm going to be iterating over the rows but also want to be able to do lookups in a readable manor.
My current thought (that I'm not liking) is to define an enum like
enum Size
{
_8,
_10,
_12,
_13_25,
_15_25,
// etc
}
and then set it up for 2 lookups.
Any better ideas?
Edit: My primary concern is limiting what I can try to look up. I'd like stuff to not even compile if the code might try and look up something that is invalid.
The set is small and iteration times are almost totally irrelevant.
I haven't seen anything that gains me anything over the enum so for now I'm going with that. OTOH I'll keep watching this question.
*
Note: I'm not worried about catching issues with pointers and what not, just straight forward code like for loops and variable assignments.
The nitty grity: I over simplified the above for clarity and generality. I actually have a table that has 3 non-integer, non-uniform axes and one non-numeric axis. And at this point I'm not sure what directions I'm going to need to enumerate it in.
a few links to give a flavor of what I'm looking for: