Class EmptyValueRange<T>

java.lang.Object
ai.timefold.solver.core.impl.domain.valuerange.AbstractCountableValueRange<T>
ai.timefold.solver.core.impl.domain.valuerange.buildin.EmptyValueRange<T>
All Implemented Interfaces:
CountableValueRange<T>, ValueRange<T>, SortableValueRange<T>

@NullMarked public final class EmptyValueRange<T> extends AbstractCountableValueRange<T>
Special range for empty value ranges.
  • Method Details

    • instance

      public static <T> EmptyValueRange<T> instance()
    • getSize

      public long getSize()
      Description copied from interface: CountableValueRange
      Used by uniform random selection in a composite CountableValueRange, or one which includes nulls.
      Returns:
      the exact number of elements generated by this CountableValueRange, always >= 0
    • get

      public @Nullable T get(long index)
      Description copied from interface: CountableValueRange
      Used by uniform random selection in a composite CountableValueRange, or one which includes nulls.
      Parameters:
      index - always < CountableValueRange.getSize()
      Returns:
      sometimes null (if PlanningVariable.allowsUnassigned() is true)
    • createOriginalIterator

      public Iterator<T> createOriginalIterator()
      Description copied from interface: CountableValueRange
      Select the elements in original (natural) order.
    • sort

      public ValueRange<T> sort(ValueRangeSorter<T> sorter)
      Description copied from interface: SortableValueRange
      The sorting operation copies the current value range and sorts it using the provided sorter.
      Specified by:
      sort in interface SortableValueRange<T>
      Overrides:
      sort in class AbstractCountableValueRange<T>
      Parameters:
      sorter - never null, the value range sorter
      Returns:
      A new instance of the value range, with the data sorted.
    • contains

      public boolean contains(@Nullable T value)
      Parameters:
      value - sometimes null
      Returns:
      true if the ValueRange contains that value
    • createRandomIterator

      public Iterator<T> createRandomIterator(Random workingRandom)
      Description copied from interface: ValueRange
      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.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object