Package org.infinispan.commons.util
Class FilterSpliterator<T>
- java.lang.Object
-
- org.infinispan.commons.util.FilterSpliterator<T>
-
- All Implemented Interfaces:
AutoCloseable
,Spliterator<T>
,CloseableSpliterator<T>
public class FilterSpliterator<T> extends Object implements CloseableSpliterator<T>
Spliterator that only returns entries that pass the given predicate. This spliterator will inherit all of the characteristics of the underlying spliterator, except that it won't returnSpliterator.SIZED
orSpliterator.SUBSIZED
.The
forEachRemaining(Consumer)
method should provide better performance than callingtryAdvance(Consumer)
until it returns false. This is due to having to capture the argument before testing it and finally invoking the providedConsumer
.- Since:
- 9.3
- Author:
- wburns
-
-
Constructor Summary
Constructors Constructor Description FilterSpliterator(Spliterator<T> spliterator, Predicate<? super T> predicate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
characteristics()
void
close()
long
estimateSize()
void
forEachRemaining(Consumer<? super T> action)
boolean
tryAdvance(Consumer<? super T> action)
Spliterator<T>
trySplit()
-
-
-
Constructor Detail
-
FilterSpliterator
public FilterSpliterator(Spliterator<T> spliterator, Predicate<? super T> predicate)
-
-
Method Detail
-
close
public void close()
- Specified by:
close
in interfaceCloseableSpliterator<T>
-
trySplit
public Spliterator<T> trySplit()
-
estimateSize
public long estimateSize()
-
characteristics
public int characteristics()
-
-