Class AbstractIndexedListIterator<E>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int position  
      private int size  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractIndexedListIterator​(int size)
      Constructs an iterator across a sequence of the given size whose initial position is 0.
      protected AbstractIndexedListIterator​(int size, int position)
      Constructs an iterator across a sequence of the given size with the given initial position.
    • Field Detail

      • size

        private final int size
      • position

        private int position
    • Constructor Detail

      • AbstractIndexedListIterator

        protected AbstractIndexedListIterator​(int size)
        Constructs an iterator across a sequence of the given size whose initial position is 0. That is, the first call to next() will return the first element (or throw NoSuchElementException if size is zero).
        Throws:
        java.lang.IllegalArgumentException - if size is negative
      • AbstractIndexedListIterator

        protected AbstractIndexedListIterator​(int size,
                                              int position)
        Constructs an iterator across a sequence of the given size with the given initial position. That is, the first call to nextIndex() will return position, and the first call to next() will return the element at that index, if available. Calls to previous() can retrieve the preceding position elements.
        Throws:
        java.lang.IndexOutOfBoundsException - if position is negative or is greater than size
        java.lang.IllegalArgumentException - if size is negative
    • Method Detail

      • get

        protected abstract E get​(int index)
        Returns the element with the specified index. This method is called by next().
      • hasNext

        public final boolean hasNext()
      • next

        public final E next()
      • nextIndex

        public final int nextIndex()
      • hasPrevious

        public final boolean hasPrevious()
      • previous

        public final E previous()
      • previousIndex

        public final int previousIndex()