*
* Queue Method |
* Equivalent Deque Method |
*
*
- *
* {@link java.util.Queue#offer offer(e)} |
* {@link #offerLast offerLast(e)} |
- *
- *
+ *
+ *
* {@link java.util.Queue#add add(e)} |
* {@link #addLast addLast(e)} |
- *
- *
+ *
+ *
* {@link java.util.Queue#poll poll()} |
* {@link #pollFirst pollFirst()} |
- *
- *
+ *
+ *
* {@link java.util.Queue#remove remove()} |
* {@link #removeFirst removeFirst()} |
- *
- *
+ *
+ *
* {@link java.util.Queue#peek peek()} |
* {@link #peek peekFirst()} |
- *
- *
+ *
+ *
* {@link java.util.Queue#element element()} |
* {@link #getFirst getFirst()} |
- *
+ *
*
*
* 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 dequeue is used as a stack, elements are pushed and popped from the
+ * 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
- * Deque methods as indicated in the table below:
+ *
*
* Stack Method |
* Equivalent Deque Method |
*
*
- *
* {@link #push push(e)} |
* {@link #addFirst addFirst(e)} |
- *
- *
+ *
+ *
* {@link #pop pop()} |
* {@link #removeFirst removeFirst()} |
- *
- *
+ *
+ *
* {@link #peek peek()} |
* {@link #peekFirst peekFirst()} |
- *
+ *
*
*
* Note that the {@link #peek peek} method works equally well when
@@ -144,7 +142,7 @@ package java.util;
* take advantage of the ability to insert nulls. This is so because
* null is used as a special return value by various methods
* to indicated that the deque is empty.
- *
+ *
*
Deque implementations generally do not define
* element-based versions of the equals and hashCode
* methods, but instead inherit the identity-based versions from class
@@ -162,7 +160,7 @@ package java.util;
public interface Deque extends Queue {
/**
- * Inserts the specified element to the front this deque unless it would
+ * Inserts the specified element at the front of this deque unless it would
* violate capacity restrictions. When using a capacity-restricted deque,
* this method is generally preferable to method addFirst, which
* can fail to insert an element only by throwing an exception.
@@ -170,13 +168,13 @@ public interface Deque extends Queue<
* @param e the element to insert
* @return true if it was possible to insert the element,
* else false
- * @throws NullPointerException if e is null and this
+ * @throws NullPointerException if the specified element is null and this
* deque does not permit null elements
*/
boolean offerFirst(E e);
/**
- * Inserts the specified element to the end of this deque unless it would
+ * Inserts the specified element at the end of this deque unless it would
* violate capacity restrictions. When using a capacity-restricted deque,
* this method is generally preferable to method addLast which
* can fail to insert an element only by throwing an exception.
@@ -184,31 +182,31 @@ public interface Deque extends Queue<
* @param e the element to insert
* @return true if it was possible to insert the element,
* else false
- * @throws NullPointerException if e is null and this
+ * @throws NullPointerException if the specified element is null and this
* deque does not permit null elements
*/
boolean offerLast(E e);
/**
- * Inserts the specified element to the front of this deque unless it
+ * Inserts the specified element at the front of this deque unless it
* would violate capacity restrictions.
*
* @param e the element to insert
* @throws IllegalStateException if it was not possible to insert
* the element due to capacity restrictions
- * @throws NullPointerException if e is null and this
+ * @throws NullPointerException if the specified element is null and this
* deque does not permit null elements
*/
void addFirst(E e);
/**
- * Inserts the specified element to the end of this deque unless it would
+ * Inserts the specified element at the end of this deque unless it would
* violate capacity restrictions.
*
* @param e the element to insert
* @throws IllegalStateException if it was not possible to insert
* the element due to capacity restrictions
- * @throws NullPointerException if e is null and this
+ * @throws NullPointerException if the specified element is null and this
* deque does not permit null elements
*/
void addLast(E e);
@@ -232,7 +230,7 @@ public interface Deque extends Queue<
E pollLast();
/**
- * Removes and returns the first element of this deque. This method
+ * Retrieves and removes the first element of this deque. This method
* differs from the pollFirst method only in that it throws an
* exception if this deque is empty.
*
@@ -271,7 +269,7 @@ public interface Deque extends Queue<
/**
* Retrieves, but does not remove, the first element of this
- * deque. This method differs from the peek method only
+ * deque. This method differs from the peekFirst method only
* in that it throws an exception if this deque is empty.
*
* @return the first element of this deque
@@ -281,7 +279,7 @@ public interface Deque extends Queue<
/**
* Retrieves, but does not remove, the last element of this
- * deque. This method differs from the peek method only
+ * deque. This method differs from the peekLast method only
* in that it throws an exception if this deque is empty.
*
* @return the last element of this deque
@@ -296,11 +294,12 @@ public interface Deque extends Queue<
* such that (o==null ? e==null : o.equals(e)) (if
* such an element exists).
*
- * @param e element to be removed from this deque, if present
+ * @param o element to be removed from this deque, if present
* @return true if the deque contained the specified element
- * @throws NullPointerException if the specified element is null
+ * @throws NullPointerException if the specified element is null and this
+ * deque does not permit null elements
*/
- boolean removeFirstOccurrence(Object e);
+ boolean removeFirstOccurrence(Object o);
/**
* Removes the last occurrence of the specified element in this
@@ -309,11 +308,12 @@ public interface Deque extends Queue<
* such that (o==null ? e==null : o.equals(e)) (if
* such an element exists).
*
- * @param e element to be removed from this deque, if present
+ * @param o element to be removed from this deque, if present
* @return true if the deque contained the specified element
- * @throws NullPointerException if the specified element is null
+ * @throws NullPointerException if the specified element is null and this
+ * deque does not permit null elements
*/
- boolean removeLastOccurrence(Object e);
+ boolean removeLastOccurrence(Object o);
// *** Queue methods ***
@@ -321,7 +321,7 @@ public interface Deque extends Queue<
/**
* Inserts the specified element into the queue represented by this deque
* unless it would violate capacity restrictions. In other words, inserts
- * the specified element to the end of this deque. When using a
+ * the specified element at the end of this deque. When using a
* capacity-restricted deque, this method is generally preferable to the
* {@link #add} method, which can fail to insert an element only by
* throwing an exception.
@@ -331,7 +331,7 @@ public interface Deque extends Queue<
* @param e the element to insert
* @return true if it was possible to insert the element,
* else false
- * @throws NullPointerException if e is null and this
+ * @throws NullPointerException if the specified element is null and this
* deque does not permit null elements
*/
boolean offer(E e);
@@ -339,7 +339,7 @@ public interface Deque extends Queue<
/**
* Inserts the specified element into the queue represented by this
* deque unless it would violate capacity restrictions. In other words,
- * inserts the specified element as the last element of this deque.
+ * inserts the specified element as the last element of this deque.
*
* This method is equivalent to {@link #addLast}.
*
@@ -347,7 +347,7 @@ public interface Deque extends Queue<
* @return true (as per the spec for {@link Collection#add})
* @throws IllegalStateException if it was not possible to insert
* the element due to capacity restrictions
- * @throws NullPointerException if e is null and this
+ * @throws NullPointerException if the specified element is null and this
* deque does not permit null elements
*/
boolean add(E e);
@@ -381,7 +381,7 @@ public interface Deque extends Queue<
* Retrieves, but does not remove, the head of the queue represented by
* this deque, returning null if this deque is empty.
*
- * This method is equivalent to {@link #peekFirst()}
+ *
This method is equivalent to {@link #peekFirst()}.
*
* @return the head of the queue represented by this deque, or
* null if this deque is empty
@@ -393,7 +393,7 @@ public interface Deque extends Queue<
* this deque. This method differs from the peek method only in
* that it throws an exception if this deque is empty.
*
- * This method is equivalent to {@link #getFirst()}
+ *
This method is equivalent to {@link #getFirst()}.
*
* @return the head of the queue represented by this deque
* @throws NoSuchElementException if this deque is empty
@@ -405,14 +405,15 @@ public interface Deque extends Queue<
/**
* Pushes an element onto the stack represented by this deque. In other
- * words, inserts the element to the front this deque unless it would
+ * words, inserts the element at the front of this deque unless it would
* violate capacity restrictions.
*
* This method is equivalent to {@link #addFirst}.
*
+ * @param e the element to push
* @throws IllegalStateException if it was not possible to insert
* the element due to capacity restrictions
- * @throws NullPointerException if e is null and this
+ * @throws NullPointerException if the specified element is null and this
* deque does not permit null elements
*/
void push(E e);
@@ -435,7 +436,7 @@ public interface Deque extends Queue<
/**
* Returns an iterator over the elements in this deque. The elements
* will be ordered from first (head) to last (tail).
- *
+ *
* @return an Iterator over the elements in this deque
*/
Iterator iterator();