< prev index next >

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

Print this page




  29  * An iterator for lists that allows the programmer
  30  * to traverse the list in either direction, modify
  31  * the list during iteration, and obtain the iterator's
  32  * current position in the list. A {@code ListIterator}
  33  * has no current element; its <I>cursor position</I> always
  34  * lies between the element that would be returned by a call
  35  * to {@code previous()} and the element that would be
  36  * returned by a call to {@code next()}.
  37  * An iterator for a list of length {@code n} has {@code n+1} possible
  38  * cursor positions, as illustrated by the carets ({@code ^}) below:
  39  * <PRE>
  40  *                      Element(0)   Element(1)   Element(2)   ... Element(n-1)
  41  * cursor positions:  ^            ^            ^            ^                  ^
  42  * </PRE>
  43  * Note that the {@link #remove} and {@link #set(Object)} methods are
  44  * <i>not</i> defined in terms of the cursor position;  they are defined to
  45  * operate on the last element returned by a call to {@link #next} or
  46  * {@link #previous()}.
  47  *
  48  * <p>This interface is a member of the
  49  * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  50  * Java Collections Framework</a>.
  51  *
  52  * @author  Josh Bloch
  53  * @see Collection
  54  * @see List
  55  * @see Iterator
  56  * @see Enumeration
  57  * @see List#listIterator()
  58  * @since   1.2
  59  */
  60 public interface ListIterator<E> extends Iterator<E> {
  61     // Query Operations
  62 
  63     /**
  64      * Returns {@code true} if this list iterator has more elements when
  65      * traversing the list in the forward direction. (In other words,
  66      * returns {@code true} if {@link #next} would return an element rather
  67      * than throwing an exception.)
  68      *
  69      * @return {@code true} if the list iterator has more elements when




  29  * An iterator for lists that allows the programmer
  30  * to traverse the list in either direction, modify
  31  * the list during iteration, and obtain the iterator's
  32  * current position in the list. A {@code ListIterator}
  33  * has no current element; its <I>cursor position</I> always
  34  * lies between the element that would be returned by a call
  35  * to {@code previous()} and the element that would be
  36  * returned by a call to {@code next()}.
  37  * An iterator for a list of length {@code n} has {@code n+1} possible
  38  * cursor positions, as illustrated by the carets ({@code ^}) below:
  39  * <PRE>
  40  *                      Element(0)   Element(1)   Element(2)   ... Element(n-1)
  41  * cursor positions:  ^            ^            ^            ^                  ^
  42  * </PRE>
  43  * Note that the {@link #remove} and {@link #set(Object)} methods are
  44  * <i>not</i> defined in terms of the cursor position;  they are defined to
  45  * operate on the last element returned by a call to {@link #next} or
  46  * {@link #previous()}.
  47  *
  48  * <p>This interface is a member of the
  49  * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
  50  * Java Collections Framework</a>.
  51  *
  52  * @author  Josh Bloch
  53  * @see Collection
  54  * @see List
  55  * @see Iterator
  56  * @see Enumeration
  57  * @see List#listIterator()
  58  * @since   1.2
  59  */
  60 public interface ListIterator<E> extends Iterator<E> {
  61     // Query Operations
  62 
  63     /**
  64      * Returns {@code true} if this list iterator has more elements when
  65      * traversing the list in the forward direction. (In other words,
  66      * returns {@code true} if {@link #next} would return an element rather
  67      * than throwing an exception.)
  68      *
  69      * @return {@code true} if the list iterator has more elements when


< prev index next >