# HG changeset patch # User dl # Date 1497667816 25200 # Node ID bd582963beb7183ddb1ce13c01571ae17fd426c1 # Parent 757b830688e33862bb1796a7615b17e2be8408d6 8181334: add spec for Deque.addAll Reviewed-by: martin, psandoz, smarks, darcy diff -r 757b830688e3 -r bd582963beb7 src/java.base/share/classes/java/util/Deque.java --- a/src/java.base/share/classes/java/util/Deque.java Fri Jun 16 17:41:05 2017 -0700 +++ b/src/java.base/share/classes/java/util/Deque.java Fri Jun 16 19:50:16 2017 -0700 @@ -72,24 +72,24 @@ * * * Insert - * {@link Deque#addFirst addFirst(e)} - * {@link Deque#offerFirst offerFirst(e)} - * {@link Deque#addLast addLast(e)} - * {@link Deque#offerLast offerLast(e)} + * {@link #addFirst(Object) addFirst(e)} + * {@link #offerFirst(Object) offerFirst(e)} + * {@link #addLast(Object) addLast(e)} + * {@link #offerLast(Object) offerLast(e)} * * * Remove - * {@link Deque#removeFirst removeFirst()} - * {@link Deque#pollFirst pollFirst()} - * {@link Deque#removeLast removeLast()} - * {@link Deque#pollLast pollLast()} + * {@link #removeFirst() removeFirst()} + * {@link #pollFirst() pollFirst()} + * {@link #removeLast() removeLast()} + * {@link #pollLast() pollLast()} * * * Examine - * {@link Deque#getFirst getFirst()} - * {@link Deque#peekFirst peekFirst()} - * {@link Deque#getLast getLast()} - * {@link Deque#peekLast peekLast()} + * {@link #getFirst() getFirst()} + * {@link #peekFirst() peekFirst()} + * {@link #getLast() getLast()} + * {@link #peekLast() peekLast()} * * * @@ -106,28 +106,28 @@ * Equivalent {@code Deque} Method * * - * {@link java.util.Queue#add add(e)} - * {@link #addLast addLast(e)} + * {@link #add(Object) add(e)} + * {@link #addLast(Object) addLast(e)} * * - * {@link java.util.Queue#offer offer(e)} - * {@link #offerLast offerLast(e)} + * {@link #offer(Object) offer(e)} + * {@link #offerLast(Object) offerLast(e)} * * - * {@link java.util.Queue#remove remove()} - * {@link #removeFirst removeFirst()} + * {@link #remove() remove()} + * {@link #removeFirst() removeFirst()} * * - * {@link java.util.Queue#poll poll()} - * {@link #pollFirst pollFirst()} + * {@link #poll() poll()} + * {@link #pollFirst() pollFirst()} * * - * {@link java.util.Queue#element element()} - * {@link #getFirst getFirst()} + * {@link #element() element()} + * {@link #getFirst() getFirst()} * * - * {@link java.util.Queue#peek peek()} - * {@link #peek peekFirst()} + * {@link #peek() peek()} + * {@link #peekFirst() peekFirst()} * * * @@ -144,16 +144,16 @@ * Equivalent {@code Deque} Method * * - * {@link #push push(e)} - * {@link #addFirst addFirst(e)} + * {@link #push(Object) push(e)} + * {@link #addFirst(Object) addFirst(e)} * * - * {@link #pop pop()} - * {@link #removeFirst removeFirst()} + * {@link #pop() pop()} + * {@link #removeFirst() removeFirst()} * * - * {@link #peek peek()} - * {@link #peekFirst peekFirst()} + * {@link #peek() peek()} + * {@link #peekFirst() peekFirst()} * * * @@ -430,8 +430,8 @@ /** * Retrieves and removes the head of the queue represented by this deque * (in other words, the first element of this deque). - * This method differs from {@link #poll poll} only in that it throws an - * exception if this deque is empty. + * This method differs from {@link #poll() poll()} only in that it + * throws an exception if this deque is empty. * *

This method is equivalent to {@link #removeFirst()}. * @@ -477,6 +477,31 @@ */ E peek(); + /** + * Adds all of the elements in the specified collection at the end + * of this deque, as if by calling {@link #addLast} on each one, + * in the order that they are returned by the collection's iterator. + * + *

When using a capacity-restricted deque, it is generally preferable + * to call {@link #offer(Object) offer} separately on each element. + * + *

An exception encountered while trying to add an element may result + * in only some of the elements having been successfully added when + * the associated exception is thrown. + * + * @param c the elements to be inserted into this deque + * @return {@code true} if this deque changed as a result of the call + * @throws IllegalStateException if not all the elements can be added at + * this time due to insertion restrictions + * @throws ClassCastException if the class of an element of the specified + * collection prevents it from being added to this deque + * @throws NullPointerException if the specified collection contains a + * null element and this deque does not permit null elements, + * or if the specified collection is null + * @throws IllegalArgumentException if some property of an element of the + * specified collection prevents it from being added to this deque + */ + boolean addAll(Collection c); // *** Stack methods ***