java.lang.Object
net.i2p.router.util.CachedIteratorArrayList.CachedIterator<E>
Type Parameters:
E - the element type of the list
All Implemented Interfaces:
Serializable, Iterator<E>
Enclosing class:
CachedIteratorArrayList<E>

private static class CachedIteratorArrayList.CachedIterator<E>extends Object implements Iterator<E>, Serializable
An iterator reused across traversals of the list.
  • Field Details

    • cursor

      int cursor
      Index of element to be returned by subsequent call to next.
    • lastRet

      int lastRet
      Index of element returned by most recent call to next or previous. Reset to -1 if this element is deleted by a call to remove.
    • expectedModCount

      int expectedModCount
      The modCount value that the iterator believes that the backing List should have. If this expectation is violated, the iterator has detected concurrent modification.
    • listRef

      private transient WeakReference<CachedIteratorArrayList<E>> listRef
      Reference to the owning list, set on each call to CachedIteratorArrayList.iterator().
  • Constructor Details

    • CachedIterator

      private CachedIterator()
      An iterator that keeps its own position.
  • Method Details

    • reset

      void reset(CachedIteratorArrayList<E> list)
      Reset iterator state for the given list.
      Parameters:
      list - the list to iterate
    • list

      private CachedIteratorArrayList<E> list()
      Gives the list this iterator belongs to.
      Returns:
      the owning list, null if it was collected
    • hasNext

      public boolean hasNext()
      Whether there is a next element available.
      Specified by:
      hasNext in interface Iterator<E>
      Returns:
      whether next is present
    • next

      public E next()
      The next element in the iteration.
      Specified by:
      next in interface Iterator<E>
      Returns:
      the next element
      Throws:
      NoSuchElementException - if the iteration is finished
    • remove

      public void remove()
      Removes from the underlying list the last element returned by next().
      Specified by:
      remove in interface Iterator<E>
    • checkForComodification

      final void checkForComodification(CachedIteratorArrayList<E> l)
      Fails if the list changed since the iterator was created.
      Parameters:
      l - the list to check