Interface SplitableIterator<T>

All Superinterfaces:
Iterator<T>
All Known Implementing Classes:
AbstractSplitableIterator, EmptyIterator, GenericIterator, LazyMultiIterator, SingleValueIterator, TransformIterator

public interface SplitableIterator<T> extends Iterator<T>
Merges the concepts of Spliterator and Iterator. Objects implementing this interface are Iterators that are capable of splitting into two parts under certain conditions and are also capable of creating Spliterators on demand.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Tests to determine if this Iterator is capable of splitting into two new Iterators.
    spliterator(int characteristics)
    Utility method that creates a Spliterator with the specified characteristics that encounters all of the same elements as this Iterator.
    default SplitIterator<T>
    Whenever isSplitAllowed returns true this method can be used to create two new SplitableIterators that collectively visit all the same elements as this Iterator.

    Methods inherited from interface java.util.Iterator

    forEachRemaining, hasNext, next, remove
  • Method Details

    • isSplitAllowed

      default boolean isSplitAllowed()
      Tests to determine if this Iterator is capable of splitting into two new Iterators.
    • splitIterator

      @Nonnull default SplitIterator<T> splitIterator()
      Whenever isSplitAllowed returns true this method can be used to create two new SplitableIterators that collectively visit all the same elements as this Iterator. Whenever isSplitAllowed returns false this method throws UnsupportedOperationException.
      Returns:
      two new SplitableIterators spanning the same elements as this
      Throws:
      UnsupportedOperationException - if splitting is not allowed
    • spliterator

      @Nonnull Spliterator<T> spliterator(int characteristics)
      Utility method that creates a Spliterator with the specified characteristics that encounters all of the same elements as this Iterator. Implementations are allowed to link the Spliterator to use this Iterator directly.