< prev index next >

src/java.base/share/classes/java/util/AbstractList.java

Print this page
rev 47863 : imported patch listn


 324      *
 325      * <p>Note that the list iterator returned by this implementation will
 326      * throw an {@link UnsupportedOperationException} in response to its
 327      * {@code remove}, {@code set} and {@code add} methods unless the
 328      * list's {@code remove(int)}, {@code set(int, E)}, and
 329      * {@code add(int, E)} methods are overridden.
 330      *
 331      * <p>This implementation can be made to throw runtime exceptions in the
 332      * face of concurrent modification, as described in the specification for
 333      * the (protected) {@link #modCount} field.
 334      *
 335      * @throws IndexOutOfBoundsException {@inheritDoc}
 336      */
 337     public ListIterator<E> listIterator(final int index) {
 338         rangeCheckForAdd(index);
 339 
 340         return new ListItr(index);
 341     }
 342 
 343     private class Itr implements Iterator<E> {

 344         /**
 345          * Index of element to be returned by subsequent call to next.
 346          */
 347         int cursor = 0;
 348 
 349         /**
 350          * Index of element returned by most recent call to next or
 351          * previous.  Reset to -1 if this element is deleted by a call
 352          * to remove.
 353          */
 354         int lastRet = -1;
 355 
 356         /**
 357          * The modCount value that the iterator believes that the backing
 358          * List should have.  If this expectation is violated, the iterator
 359          * has detected concurrent modification.
 360          */
 361         int expectedModCount = modCount;
 362 
 363         public boolean hasNext() {




 324      *
 325      * <p>Note that the list iterator returned by this implementation will
 326      * throw an {@link UnsupportedOperationException} in response to its
 327      * {@code remove}, {@code set} and {@code add} methods unless the
 328      * list's {@code remove(int)}, {@code set(int, E)}, and
 329      * {@code add(int, E)} methods are overridden.
 330      *
 331      * <p>This implementation can be made to throw runtime exceptions in the
 332      * face of concurrent modification, as described in the specification for
 333      * the (protected) {@link #modCount} field.
 334      *
 335      * @throws IndexOutOfBoundsException {@inheritDoc}
 336      */
 337     public ListIterator<E> listIterator(final int index) {
 338         rangeCheckForAdd(index);
 339 
 340         return new ListItr(index);
 341     }
 342 
 343     private class Itr implements Iterator<E> {
 344 
 345         /**
 346          * Index of element to be returned by subsequent call to next.
 347          */
 348         int cursor = 0;
 349 
 350         /**
 351          * Index of element returned by most recent call to next or
 352          * previous.  Reset to -1 if this element is deleted by a call
 353          * to remove.
 354          */
 355         int lastRet = -1;
 356 
 357         /**
 358          * The modCount value that the iterator believes that the backing
 359          * List should have.  If this expectation is violated, the iterator
 360          * has detected concurrent modification.
 361          */
 362         int expectedModCount = modCount;
 363 
 364         public boolean hasNext() {


< prev index next >