Techniques for searching a list of ranges to find the one a given values falls in:
Often your ranges are all the same length. Then you can find the slot by dividing your value by the range length. This is very fast.
If the length of each range is a multiple of some unit, you can construct a lookup table. You take your value, divide by the length of the unit and use it to index the table to give you the band number. This is very fast. This technique can be used to deal with weighted values that behave like extending the length of the associated band.
If your ranges are short and sparse, you can index the start point, rounded, in a HashMap or TreeMap. There is no built-in Collection that will look up ranges for you. You must roll your own.
This page is posted |
http://mindprod.com/jgloss/range.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\range.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[18.188.161.0] |
| |
Feedback |
You are visitor number | |