T - lookup (source) value typeU - result (destination) valuetypepublic static class RangeLookupTable.Builder<T extends Number & Comparable<? super T>,U extends Number & Comparable<? super U>> extends Object
| Constructor and Description |
|---|
Builder()
Creates a new builder.
|
| Modifier and Type | Method and Description |
|---|---|
RangeLookupTable.Builder |
add(Range<T> srcRange,
U resultValue)
Adds a new lookup defined by a range of source values mapping to a
result value.
|
RangeLookupTable<T,U> |
build()
Creates a new table that will hold the lookup items added to
this builder.
|
public RangeLookupTable<T,U> build()
public RangeLookupTable.Builder add(Range<T> srcRange, U resultValue)
[5, 10] => 1
has previously been set, and a new lookup [0, 20] => 2 is added,
then the following lookups will result:
[0, 5) => 2
[5, 10] => 1
(10, 20] => 2
Where a new range is completely overlapped by existing ranges it
will be ignored.
Note that it is possible to end up with unintended gaps in lookup coverage. If the first range in the above example had been the half-open interval (5, 10] rather than the closed interval [5, 10] then the following would have resulted:
[0, 5) => 2
(5, 10] => 1
(10, 20] => 2
In this case the value 5 would not be matched.srcRange - the source value rangeresultValue - the destination valueCopyright © 2009–2020. All rights reserved.