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

Print this page

        

*** 85,95 **** * lists will refuse to add null elements, and others will impose * restrictions on the type of elements that may be added. List * classes should clearly specify in their documentation any restrictions * on what elements may be added. * ! * <p>This implementation calls {@code add(size(), e)}. * * <p>Note that this implementation throws an * {@code UnsupportedOperationException} unless * {@link #add(int, Object) add(int, E)} is overridden. * --- 85,96 ---- * lists will refuse to add null elements, and others will impose * restrictions on the type of elements that may be added. List * classes should clearly specify in their documentation any restrictions * on what elements may be added. * ! * @implSpec ! * This implementation calls {@code add(size(), e)}. * * <p>Note that this implementation throws an * {@code UnsupportedOperationException} unless * {@link #add(int, Object) add(int, E)} is overridden. *
*** 117,127 **** abstract public E get(int index); /** * {@inheritDoc} * ! * <p>This implementation always throws an * {@code UnsupportedOperationException}. * * @throws UnsupportedOperationException {@inheritDoc} * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} --- 118,129 ---- abstract public E get(int index); /** * {@inheritDoc} * ! * @implSpec ! * This implementation always throws an * {@code UnsupportedOperationException}. * * @throws UnsupportedOperationException {@inheritDoc} * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc}
*** 133,143 **** } /** * {@inheritDoc} * ! * <p>This implementation always throws an * {@code UnsupportedOperationException}. * * @throws UnsupportedOperationException {@inheritDoc} * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} --- 135,146 ---- } /** * {@inheritDoc} * ! * @implSpec ! * This implementation always throws an * {@code UnsupportedOperationException}. * * @throws UnsupportedOperationException {@inheritDoc} * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc}
*** 149,159 **** } /** * {@inheritDoc} * ! * <p>This implementation always throws an * {@code UnsupportedOperationException}. * * @throws UnsupportedOperationException {@inheritDoc} * @throws IndexOutOfBoundsException {@inheritDoc} */ --- 152,163 ---- } /** * {@inheritDoc} * ! * @implSpec ! * This implementation always throws an * {@code UnsupportedOperationException}. * * @throws UnsupportedOperationException {@inheritDoc} * @throws IndexOutOfBoundsException {@inheritDoc} */
*** 165,175 **** // Search Operations /** * {@inheritDoc} * ! * <p>This implementation first gets a list iterator (with * {@code listIterator()}). Then, it iterates over the list until the * specified element is found or the end of the list is reached. * * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} --- 169,180 ---- // Search Operations /** * {@inheritDoc} * ! * @implSpec ! * This implementation first gets a list iterator (with * {@code listIterator()}). Then, it iterates over the list until the * specified element is found or the end of the list is reached. * * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc}
*** 189,199 **** } /** * {@inheritDoc} * ! * <p>This implementation first gets a list iterator that points to the end * of the list (with {@code listIterator(size())}). Then, it iterates * backwards over the list until the specified element is found, or the * beginning of the list is reached. * * @throws ClassCastException {@inheritDoc} --- 194,205 ---- } /** * {@inheritDoc} * ! * @implSpec ! * This implementation first gets a list iterator that points to the end * of the list (with {@code listIterator(size())}). Then, it iterates * backwards over the list until the specified element is found, or the * beginning of the list is reached. * * @throws ClassCastException {@inheritDoc}
*** 218,228 **** /** * Removes all of the elements from this list (optional operation). * The list will be empty after this call returns. * ! * <p>This implementation calls {@code removeRange(0, size())}. * * <p>Note that this implementation throws an * {@code UnsupportedOperationException} unless {@code remove(int * index)} or {@code removeRange(int fromIndex, int toIndex)} is * overridden. --- 224,235 ---- /** * Removes all of the elements from this list (optional operation). * The list will be empty after this call returns. * ! * @implSpec ! * This implementation calls {@code removeRange(0, size())}. * * <p>Note that this implementation throws an * {@code UnsupportedOperationException} unless {@code remove(int * index)} or {@code removeRange(int fromIndex, int toIndex)} is * overridden.
*** 235,245 **** } /** * {@inheritDoc} * ! * <p>This implementation gets an iterator over the specified collection * and iterates over it, inserting the elements obtained from the * iterator into this list at the appropriate position, one at a time, * using {@code add(int, E)}. * Many implementations will override this method for efficiency. * --- 242,253 ---- } /** * {@inheritDoc} * ! * @implSpec ! * This implementation gets an iterator over the specified collection * and iterates over it, inserting the elements obtained from the * iterator into this list at the appropriate position, one at a time, * using {@code add(int, E)}. * Many implementations will override this method for efficiency. *
*** 267,277 **** // Iterators /** * Returns an iterator over the elements in this list in proper sequence. * ! * <p>This implementation returns a straightforward implementation of the * iterator interface, relying on the backing list's {@code size()}, * {@code get(int)}, and {@code remove(int)} methods. * * <p>Note that the iterator returned by this method will throw an * {@link UnsupportedOperationException} in response to its --- 275,286 ---- // Iterators /** * Returns an iterator over the elements in this list in proper sequence. * ! * @implSpec ! * This implementation returns a straightforward implementation of the * iterator interface, relying on the backing list's {@code size()}, * {@code get(int)}, and {@code remove(int)} methods. * * <p>Note that the iterator returned by this method will throw an * {@link UnsupportedOperationException} in response to its
*** 289,310 **** } /** * {@inheritDoc} * ! * <p>This implementation returns {@code listIterator(0)}. * * @see #listIterator(int) */ public ListIterator<E> listIterator() { return listIterator(0); } /** * {@inheritDoc} * ! * <p>This implementation returns a straightforward implementation of the * {@code ListIterator} interface that extends the implementation of the * {@code Iterator} interface returned by the {@code iterator()} method. * The {@code ListIterator} implementation relies on the backing list's * {@code get(int)}, {@code set(int, E)}, {@code add(int, E)} * and {@code remove(int)} methods. --- 298,321 ---- } /** * {@inheritDoc} * ! * @implSpec ! * This implementation returns {@code listIterator(0)}. * * @see #listIterator(int) */ public ListIterator<E> listIterator() { return listIterator(0); } /** * {@inheritDoc} * ! * @implSpec ! * This implementation returns a straightforward implementation of the * {@code ListIterator} interface that extends the implementation of the * {@code Iterator} interface returned by the {@code iterator()} method. * The {@code ListIterator} implementation relies on the backing list's * {@code get(int)}, {@code set(int, E)}, {@code add(int, E)} * and {@code remove(int)} methods.
*** 446,456 **** } /** * {@inheritDoc} * ! * <p>This implementation returns a list that subclasses * {@code AbstractList}. The subclass stores, in private fields, the * offset of the subList within the backing list, the size of the subList * (which can change over its lifetime), and the expected * {@code modCount} value of the backing list. There are two variants * of the subclass, one of which implements {@code RandomAccess}. --- 457,468 ---- } /** * {@inheritDoc} * ! * @implSpec ! * This implementation returns a list that subclasses * {@code AbstractList}. The subclass stores, in private fields, the * offset of the subList within the backing list, the size of the subList * (which can change over its lifetime), and the expected * {@code modCount} value of the backing list. There are two variants * of the subclass, one of which implements {@code RandomAccess}.
*** 495,504 **** --- 507,517 ---- * the two lists are <i>equal</i>. (Two elements {@code e1} and * {@code e2} are <i>equal</i> if {@code (e1==null ? e2==null : * e1.equals(e2))}.) In other words, two lists are defined to be * equal if they contain the same elements in the same order.<p> * + * @implSpec * This implementation first checks if the specified object is this * list. If so, it returns {@code true}; if not, it checks if the * specified object is a list. If not, it returns {@code false}; if so, * it iterates over both lists, comparing corresponding pairs of elements. * If any comparison returns {@code false}, this method returns
*** 527,537 **** } /** * Returns the hash code value for this list. * ! * <p>This implementation uses exactly the code that is used to define the * list hash function in the documentation for the {@link List#hashCode} * method. * * @return the hash code value for this list */ --- 540,551 ---- } /** * Returns the hash code value for this list. * ! * @implSpec ! * This implementation uses exactly the code that is used to define the * list hash function in the documentation for the {@link List#hashCode} * method. * * @return the hash code value for this list */
*** 553,563 **** * and its subLists. Overriding this method to take advantage of * the internals of the list implementation can <i>substantially</i> * improve the performance of the {@code clear} operation on this list * and its subLists. * ! * <p>This implementation gets a list iterator positioned before * {@code fromIndex}, and repeatedly calls {@code ListIterator.next} * followed by {@code ListIterator.remove} until the entire range has * been removed. <b>Note: if {@code ListIterator.remove} requires linear * time, this implementation requires quadratic time.</b> * --- 567,578 ---- * and its subLists. Overriding this method to take advantage of * the internals of the list implementation can <i>substantially</i> * improve the performance of the {@code clear} operation on this list * and its subLists. * ! * @implSpec ! * This implementation gets a list iterator positioned before * {@code fromIndex}, and repeatedly calls {@code ListIterator.next} * followed by {@code ListIterator.remove} until the entire range has * been removed. <b>Note: if {@code ListIterator.remove} requires linear * time, this implementation requires quadratic time.</b> *