001/*
002 * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.  Oracle designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Oracle in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
022 * or visit www.oracle.com if you need additional information or have any
023 * questions.
024 */
025
026package Torello.Java.ReadOnly;
027
028import java.util.ListIterator;
029
030/**
031 * Immutable variant of Java Collections Framework interface
032 * <CODE>java&#46;util&#46;ListIterator&lt;E&gt;</CODE>.
033 * 
034 * <EMBED CLASS='external-html' DATA-JDK=ReadOnlyListIterator DATA-FILE-ID=INTERFACES>
035 *
036 * @param <E> the type of elements returned by this list iterator
037 */
038@Torello.JavaDoc.JDHeaderBackgroundImg(EmbedTagFileID="JDHBI_INTERFACE")
039public interface ReadOnlyListIterator<E>
040{
041    // ********************************************************************************************
042    // ********************************************************************************************
043    // Original Methods
044    // ********************************************************************************************
045    // ********************************************************************************************
046
047
048    /**
049     * Returns {@code TRUE} if this list iterator has more elements when traversing the list in the
050     * forward direction. (In other words, returns {@code TRUE} if {@link #next} would return an
051     * element rather than throwing an exception.)
052     *
053     * @return {@code TRUE} if the list iterator has more elements when traversing the list in the
054     * forward direction
055     */
056    boolean hasNext();
057
058    /**
059     * Returns the next element in the list and advances the cursor position.  This method may be
060     * called repeatedly to iterate through the list, or intermixed with calls to {@link #previous}
061     * to go back and forth.  (Note that alternating calls to {@code next} and {@code previous}
062     * will return the same element repeatedly.)
063     *
064     * @return the next element in the list
065     * @throws NoSuchElementException if the iteration has no next element
066     */
067    E next();
068
069    /**
070     * Returns {@code TRUE} if this list iterator has more elements when traversing the list in the
071     * reverse direction.  (In other words, returns {@code TRUE} if {@link #previous} would return
072     * an element rather than throwing an exception.)
073     *
074     * @return {@code TRUE} if the list iterator has more elements when traversing the list in the
075     * reverse direction
076     */
077    boolean hasPrevious();
078
079    /**
080     * Returns the previous element in the list and moves the cursor position backwards.  This
081     * method may be called repeatedly to iterate through the list backwards, or intermixed with
082     * calls to {@link #next} to go back and forth.  (Note that alternating calls to {@code next}
083     * and {@code previous} will return the same element repeatedly.)
084     *
085     * @return the previous element in the list
086     * @throws NoSuchElementException if the iteration has no previous element
087     */
088    E previous();
089
090    /**
091     * Returns the index of the element that would be returned by a subsequent call to
092     * {@link #next}. (Returns list size if the list iterator is at the end of the list.)
093     *
094     * @return the index of the element that would be returned by a subsequent call to
095     * {@code next}, or list size if the list iterator is at the end of the list
096     */
097    int nextIndex();
098
099    /**
100     * Returns the index of the element that would be returned by a subsequent call to
101     * {@link #previous}. (Returns -1 if the list iterator is at the beginning of the list.)
102     *
103     * @return the index of the element that would be returned by a subsequent call to
104     * {@code previous}, or -1 if the list iterator is at the beginning of the list
105     */
106    int previousIndex();
107}