Interface ValueRange<T>

All Known Subinterfaces:
CountableValueRange<T>
All Known Implementing Classes:
AbstractCountableValueRange, AbstractUncountableValueRange, BigDecimalValueRange, BigIntegerValueRange, BooleanValueRange, CompositeCountableValueRange, DoubleValueRange, EmptyValueRange, IntValueRange, ListValueRange, LongValueRange, NullAllowingCountableValueRange, SetValueRange, TemporalValueRange

@NullMarked public interface ValueRange<T>
A ValueRange is a set of a values for a PlanningVariable or PlanningListVariable. These values might be stored in memory as a Collection (usually a List or Set), but if the values are numbers, they can also be stored in memory by their bounds to use less memory and provide more opportunities.

ValueRange is stateless, and its contents must not depend on any planning variables. Implementations must be immutable.

It is recommended to implement Object.equals(Object) and Object.hashCode() and for those implementations to be efficient, because instances are often cached.

Don't implement this interface directly. If you can't use a collection to store the values, use ValueRangeFactory to get an instance of a CountableValueRange.

See Also:
  • Method Details

    • isEmpty

      boolean isEmpty()
      In a CountableValueRange, this must be consistent with CountableValueRange.getSize().
      Returns:
      true if the range is empty
    • contains

      boolean contains(@Nullable 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 - the Random to use when any random number is needed, so runs are reproducible.