Class FilteredUniqueRandomIterator<T>
java.lang.Object
ai.timefold.solver.core.impl.bavet.common.index.FilteredUniqueRandomIterator<T>
- Type Parameters:
T-
- All Implemented Interfaces:
UniqueRandomIterator<T>,Iterator<T>
@NullMarked
public final class FilteredUniqueRandomIterator<T>
extends Object
implements UniqueRandomIterator<T>
Unlike
DefaultUniqueRandomIterator, this class only returns elements that match the given filter.
Because we can't predict how many elements will be filtered out,
and because we don't want to pre-filter the entire list,
this class may need to try multiple times to find a matching element.-
Method Details
-
hasNext
public boolean hasNext()Description copied from interface:UniqueRandomIteratorReturns whether there are no more elements to pick from. In case ofFilteredUniqueRandomIterator, this method may return false positives, as it cannot predict how many elements will be filtered out. -
next
Description copied from interface:UniqueRandomIteratorPicks a random element from the list which has not already been removed. Once an element of the list is removed either viaUniqueRandomIterator.remove(), it will never be returned again by this method. -
remove
public void remove()Description copied from interface:UniqueRandomIteratorRemoves a random element in the underlying list which has not already been removed. Once this method returns, no subsequentUniqueRandomIterator.next()will return this element ever again.
-