Class ValueRangeCache<Value_>
java.lang.Object
ai.timefold.solver.core.impl.domain.valuerange.ValueRangeCache<Value_>
- Type Parameters:
Value_- the type of the cached values
- All Implemented Interfaces:
Iterable<Value_>
Instances are usually created using one of the static
of(...) factory methods,
which control how the underlying collection is initialized.
The collection preserves the original insertion order and enables efficient indexed and random access.
When values are added via add(Object), the set is consulted first and the value
is only appended to the list if it was not already present in the set.
As a result, the cache never contains duplicate elements according to their equals/hashCode contract.
-
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanget(int index) longgetSize()iterator()Iterates in original order of the values as provided, terminates when the last value is reached.Iterates in random order, does not terminate.static <Value_> ValueRangeCache<Value_>of(int size) static <Value_> ValueRangeCache<Value_>of(Collection<Value_> collection) static <Value_> ValueRangeCache<Value_>sort(ValueRangeSorter<Value_> sorter) Creates a copy of the cache and apply a sorting operation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
of
-
of
-
of
public static <Value_> ValueRangeCache<Value_> of(List<Value_> valuesWithFastRandomAccess, Set<Value_> valuesWithFastLookup) -
add
-
get
-
contains
-
getSize
public long getSize() -
iterator
Iterates in original order of the values as provided, terminates when the last value is reached. -
iterator
Iterates in random order, does not terminate. -
sort
Creates a copy of the cache and apply a sorting operation.- Parameters:
sorter- never null, the sorter
-