--- jsr166/src/main/java/util/Deque.java 2016/03/22 15:27:58 1.34 +++ jsr166/src/main/java/util/Deque.java 2018/04/05 00:03:34 1.41 @@ -27,41 +27,44 @@ package java.util; *
The twelve methods described above are summarized in the * following table: * - *
- * | First Element (Head) | - *Last Element (Tail) | + *+ * | First Element (Head) | + *Last Element (Tail) | *||||
---|---|---|---|---|---|---|---|---|---|
- * | Throws exception | - *Special value | - *Throws exception | - *Special value | + *Throws exception | + *Special value | + *Throws exception | + *Special value | *|
Insert | - *{@link Deque#addFirst addFirst(e)} | - *{@link Deque#offerFirst offerFirst(e)} | - *{@link Deque#addLast addLast(e)} | - *{@link Deque#offerLast offerLast(e)} | + *Insert | + *{@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()} | + *Remove | + *{@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()} | + *Examine | + *{@link #getFirst() getFirst()} | + *{@link #peekFirst() peekFirst()} | + *{@link #getLast() getLast()} | + *{@link #peekLast() peekLast()} | *
This interface extends the {@link Queue} interface. When a deque is @@ -70,62 +73,70 @@ package java.util; * inherited from the {@code Queue} interface are precisely equivalent to * {@code Deque} methods as indicated in the following table: * - *
{@code Queue} Method | - *Equivalent {@code Deque} Method | + *{@code Queue} Method | + *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()} | *
Deques can also be used as LIFO (Last-In-First-Out) stacks. This * interface should be used in preference to the legacy {@link Stack} class. * When a deque is used as a stack, elements are pushed and popped from the - * beginning of the deque. Stack methods are precisely equivalent to - * {@code Deque} methods as indicated in the table below: + * beginning of the deque. Stack methods are equivalent to {@code Deque} + * methods as indicated in the table below: * - *
Stack Method | - *Equivalent {@code Deque} Method | + *Stack Method | + *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 #getFirst() getFirst()} | *
Note that the {@link #peek peek} method works equally well when @@ -152,9 +163,9 @@ package java.util; * methods, but instead inherit the identity-based versions from class * {@code Object}. * - *
This interface is a member of the Java Collections - * Framework. + *
This interface is a member of the
+ *
+ * Java Collections Framework.
*
* @author Doug Lea
* @author Josh Bloch
@@ -401,8 +412,8 @@ public interface Deque This method is equivalent to {@link #removeFirst()}.
*
@@ -448,6 +459,31 @@ public interface Deque 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 extends E> c);
// *** Stack methods ***