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

@NullMarked public final class SetValueRange<T> extends AbstractCountableValueRange<T>
  • Constructor Details

    • SetValueRange

      public SetValueRange(Set<T> set)
  • Method Details

    • 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 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)
    • contains

      public boolean contains(@Nullable T value)
      Parameters:
      value - sometimes null
      Returns:
      true if the ValueRange contains that value
    • 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.
    • createOriginalIterator

      public Iterator<T> createOriginalIterator()
      Description copied from interface: CountableValueRange
      Select the elements in original (natural) order.
    • 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.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object