Interface ValueRange<T>
-
- All Known Subinterfaces:
CountableValueRange<T>
- All Known Implementing Classes:
AbstractCountableValueRange
,AbstractUncountableValueRange
,BigDecimalValueRange
,BigIntegerValueRange
,BooleanValueRange
,CompositeCountableValueRange
,DoubleValueRange
,EmptyValueRange
,IntValueRange
,ListValueRange
,LongValueRange
,NullableCountableValueRange
,TemporalValueRange
public interface ValueRange<T>
A ValueRange is a set of a values for aPlanningVariable
. These values might be stored in memory as aCollection
(usually aList
orSet
), but if the values are numbers, they can also be stored in memory by their bounds to use less memory and provide more opportunities.Prefer using
CountableValueRange
(which extends this interface) whenever possible.A ValueRange is stateful (unlike a
ValueSelector
which is stateless).Implementations must be immutable.
An implementation must extend
AbstractCountableValueRange
orAbstractUncountableValueRange
to ensure backwards compatibility in future versions.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
contains(T value)
Iterator<T>
createRandomIterator(Random workingRandom)
Select in random order, but without shuffling the elements.boolean
isEmpty()
In aCountableValueRange
, this must be consistent withCountableValueRange.getSize()
.
-
-
-
Method Detail
-
isEmpty
boolean isEmpty()
In aCountableValueRange
, this must be consistent withCountableValueRange.getSize()
.- Returns:
- true if the range is empty
-
contains
boolean contains(T value)
- Parameters:
value
- sometimes null- Returns:
- true if the ValueRange contains that value
-
createRandomIterator
Iterator<T> createRandomIterator(Random workingRandom)
Select in random order, but without shuffling the elements. Each element might be selected multiple times. Scales well because it does not require caching.- Parameters:
workingRandom
- never null, theRandom
to use when any random number is needed, soEnvironmentMode.REPRODUCIBLE
works correctly.RandomUtils
can be useful too.- Returns:
- never null
-
-