6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.util; 27 28 /** 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}/../technotes/guides/collections/index.html"> 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 70 * traversing the list in the forward direction 71 */ 72 boolean hasNext(); 73 74 /** 75 * Returns the next element in the list and advances the cursor position. 76 * This method may be called repeatedly to iterate through the list, 77 * or intermixed with calls to {@link #previous} to go back and forth. 78 * (Note that alternating calls to {@code next} and {@code previous} 79 * will return the same element repeatedly.) 80 * | 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javany.util; 27 28 /** 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}/../technotes/guides/collections/index.html"> 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<any 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 70 * traversing the list in the forward direction 71 */ 72 boolean hasNext(); 73 74 /** 75 * Returns the next element in the list and advances the cursor position. 76 * This method may be called repeatedly to iterate through the list, 77 * or intermixed with calls to {@link #previous} to go back and forth. 78 * (Note that alternating calls to {@code next} and {@code previous} 79 * will return the same element repeatedly.) 80 * |