It depends where your priority are:
- speed ?
- memory ?
- flexibility ?
A trivial approach is a binary search in a sorted array where you store the upper bound for each interval (including the undefined ones).
Cheers Rolf
( addicted to the Perl Programming Language)