Class CharIterators.AbstractIndexBasedIterator

All Implemented Interfaces:
CharIterator, Iterator<Character>, PrimitiveIterator<Character,CharConsumer>
Direct Known Subclasses:
Enclosing class:

public abstract static class CharIterators.AbstractIndexBasedIterator extends AbstractCharIterator
A skeletal implementation for an iterator backed by an index-based data store. High performance concrete implementations (like the main Iterator 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 BigListIterators 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).

  • Method Details

    • hasNext

      public boolean hasNext()
    • nextChar

      public char nextChar()
      Description copied from interface: CharIterator
      Returns the next element as a primitive type.
      the next element in the iteration.
      See Also:
    • remove

      public void remove()
    • forEachRemaining

      public void forEachRemaining(CharConsumer action)
      Description copied from interface: CharIterator
      Performs the given action for each remaining element until all elements have been processed or the action throws an exception.
      action - the action to be performed for each element.
      See Also:
    • skip

      public int skip(int n)
      Description copied from interface: CharIterator
      Skips the given number of elements.

      The effect of this call is exactly the same as that of calling for n times (possibly stopping if Iterator.hasNext() becomes false).

      n - the number of elements to skip.
      the number of elements actually skipped.
      See Also: