Class FilterSpliterator<T>

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.util.Spliterator<T>, CloseableSpliterator<T>

    public class FilterSpliterator<T>
    extends java.lang.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 return Spliterator.SIZED or Spliterator.SUBSIZED.

    The forEachRemaining(Consumer) method should provide better performance than calling tryAdvance(Consumer) until it returns false. This is due to having to capture the argument before testing it and finally invoking the provided Consumer.

    Since:
    9.3
    Author:
    wburns
    • Constructor Detail

      • FilterSpliterator

        public FilterSpliterator​(java.util.Spliterator<T> spliterator,
                                 java.util.function.Predicate<? super T> predicate)
    • Method Detail

      • tryAdvance

        public boolean tryAdvance​(java.util.function.Consumer<? super T> action)
      • forEachRemaining

        public void forEachRemaining​(java.util.function.Consumer<? super T> action)
      • trySplit

        public java.util.Spliterator<T> trySplit()
      • estimateSize

        public long estimateSize()
      • characteristics

        public int characteristics()