Class ObjectSpliterators.AbstractIndexBasedSpliterator<K>

java.lang.Object
it.unimi.dsi.fastutil.objects.AbstractObjectSpliterator<K>
it.unimi.dsi.fastutil.objects.ObjectSpliterators.AbstractIndexBasedSpliterator<K>
All Implemented Interfaces:
ObjectSpliterator<K>, java.util.Spliterator<K>
Direct Known Subclasses:
ObjectSpliterators.EarlyBindingSizeIndexBasedSpliterator, ObjectSpliterators.LateBindingSizeIndexBasedSpliterator
Enclosing class:
ObjectSpliterators

public abstract static class ObjectSpliterators.AbstractIndexBasedSpliterator<K>
extends AbstractObjectSpliterator<K>
A skeletal implementation for a spliterator backed by an index based data store. High performance concrete implementations (like the main Spliterator of ArrayList) generally should avoid using this and just implement the interface directly, but should be decent for less performance critical implementations.

This class is only appropriate for sequences that are at most Integer.MAX_VALUE long. If your backing data store can be bigger then this, consider the equivalently named class in the type specific BigSpliterators class.

As the abstract methods in this class are used in inner loops, it is generally a good idea to override the class as final as to encourage the JVM to inline them (or alternatively, override the abstract methods as final).

  • Nested Class Summary

    Nested classes/interfaces inherited from interface java.util.Spliterator

    java.util.Spliterator.OfDouble, java.util.Spliterator.OfInt, java.util.Spliterator.OfLong, java.util.Spliterator.OfPrimitive<T extends java.lang.Object,​T_CONS extends java.lang.Object,​T_SPLITR extends java.util.Spliterator.OfPrimitive<T,​T_CONS,​T_SPLITR>>
  • Field Summary

    Fields inherited from interface java.util.Spliterator

    CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED
  • Method Summary

    Modifier and Type Method Description
    int characteristics()  
    long estimateSize()  
    void forEachRemaining​(java.util.function.Consumer<? super K> action)  
    long skip​(long n)
    Skips the given number of elements.
    boolean tryAdvance​(java.util.function.Consumer<? super K> action)  
    ObjectSpliterator<K> trySplit()

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Spliterator

    getComparator, getExactSizeIfKnown, hasCharacteristics
  • Method Details

    • characteristics

      public int characteristics()
    • estimateSize

      public long estimateSize()
    • tryAdvance

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

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

      public long skip​(long n)
      Description copied from interface: ObjectSpliterator
      Skips the given number of elements.

      The effect of this call is exactly the same as that of calling Spliterator.tryAdvance(java.util.function.Consumer<? super T>) for n times (possibly stopping if Spliterator.tryAdvance(java.util.function.Consumer<? super T>) returns false). The action called will do nothing; elements will be discarded.

      Parameters:
      n - the number of elements to skip.
      Returns:
      the number of elements actually skipped.
      See Also:
      Spliterator.tryAdvance(java.util.function.Consumer<? super T>)
    • trySplit

      public ObjectSpliterator<K> trySplit()
      Throws:
      java.lang.IndexOutOfBoundsException - if the return of computeSplitPoint() was < pos or > {@link #getMaxPos()}.
      Implementation Specification:
      This implementation always returns a prefix of the elements, in order to comply with the Spliterator.ORDERED property. This means this current iterator does not need to to update what getMaxPos() returns in response to this method (but it may do "book-keeping" on it based on binding strategy).

      The split point is computed by computeSplitPoint(); see that method for details.