ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/Deque.java
(Generate patch)

Comparing jsr166/src/main/java/util/Deque.java (file contents):
Revision 1.2 by dl, Tue Mar 8 12:27:06 2005 UTC vs.
Revision 1.4 by dl, Tue Mar 22 16:48:32 2005 UTC

# Line 24 | Line 24 | package java.util;
24   * <tt>Deque</tt> implementations; in most implementations, insert
25   * operations cannot fail.
26   *
27 < * <p>The twelve methods described above are summarized in the
27 > * <p>The twelve methods described above are summarized in the
28   * following table:<p>
29 < *
29 > *
30   * <table BORDER CELLPADDING=3 CELLSPACING=1>
31   *  <tr>
32   *    <td></td>
# Line 65 | Line 65 | package java.util;
65   *
66   * <p>This interface extends the {@link Queue} interface.  When a deque is
67   * used as a queue, FIFO (First-In-First-Out) behavior results.  Elements are
68 < * added to the end of the deque and removed from the beginning.  The methods
68 > * added at the end of the deque and removed from the beginning.  The methods
69   * inherited from the <tt>Queue</tt> interface are precisely equivalent to
70   * <tt>Deque</tt> methods as indicated in the following table:<p>
71   *
# Line 103 | Line 103 | package java.util;
103   *
104   * <p>Deques can also be used as LIFO (Last-In-First-Out) stacks.  This
105   * interface should be used in preference to the legacy {@link Stack} class.
106 < * When a dequeue is used as a stack, elements are pushed and popped from the
106 > * When a deque is used as a stack, elements are pushed and popped from the
107   * beginning of the deque.  Stack methods are precisely equivalent to
108   * <tt>Deque</tt> methods as indicated in the table below:<p>
109   *
# Line 144 | Line 144 | package java.util;
144   * take advantage of the ability to insert nulls.  This is so because
145   * <tt>null</tt> is used as a special return value by various methods
146   * to indicated that the deque is empty.
147 < *
147 > *
148   * <p><tt>Deque</tt> implementations generally do not define
149   * element-based versions of the <tt>equals</tt> and <tt>hashCode</tt>
150   * methods, but instead inherit the identity-based versions from class
# Line 162 | Line 162 | package java.util;
162  
163   public interface Deque<E> extends Queue<E> {
164      /**
165 <     * Inserts the specified element to the front this deque unless it would
165 >     * Inserts the specified element at the front of this deque unless it would
166       * violate capacity restrictions.  When using a capacity-restricted deque,
167       * this method is generally preferable to method <tt>addFirst</tt>, which
168       * can fail to insert an element only by throwing an exception.
# Line 170 | Line 170 | public interface Deque<E> extends Queue<
170       * @param e the element to insert
171       * @return <tt>true</tt> if it was possible to insert the element,
172       *     else <tt>false</tt>
173 <     * @throws NullPointerException if <tt>e</tt> is null and this
173 >     * @throws NullPointerException if the specified element is null and this
174       *     deque does not permit null elements
175       */
176      boolean offerFirst(E e);
177  
178      /**
179 <     * Inserts the specified element to the end of this deque unless it would
179 >     * Inserts the specified element at the end of this deque unless it would
180       * violate capacity restrictions.  When using a capacity-restricted deque,
181       * this method is generally preferable to method <tt>addLast</tt> which
182       * can fail to insert an element only by throwing an exception.
# Line 184 | Line 184 | public interface Deque<E> extends Queue<
184       * @param e the element to insert
185       * @return <tt>true</tt> if it was possible to insert the element,
186       *     else <tt>false</tt>
187 <     * @throws NullPointerException if <tt>e</tt> is null and this
187 >     * @throws NullPointerException if the specified element is null and this
188       *     deque does not permit null elements
189       */
190      boolean offerLast(E e);
191  
192      /**
193 <     * Inserts the specified element to the front of this deque unless it
193 >     * Inserts the specified element at the front of this deque unless it
194       * would violate capacity restrictions.
195       *
196       * @param e the element to insert
197       * @throws IllegalStateException if it was not possible to insert
198       *    the element due to capacity restrictions
199 <     * @throws NullPointerException if <tt>e</tt> is null and this
199 >     * @throws NullPointerException if the specified element is null and this
200       *     deque does not permit null elements
201       */
202      void addFirst(E e);
203  
204      /**
205 <     * Inserts the specified element to the end of this deque unless it would
205 >     * Inserts the specified element at the end of this deque unless it would
206       * violate capacity restrictions.
207       *
208       * @param e the element to insert
209       * @throws IllegalStateException if it was not possible to insert
210       *    the element due to capacity restrictions
211 <     * @throws NullPointerException if <tt>e</tt> is null and this
211 >     * @throws NullPointerException if the specified element is null and this
212       *     deque does not permit null elements
213       */
214      void addLast(E e);
# Line 271 | Line 271 | public interface Deque<E> extends Queue<
271  
272      /**
273       * Retrieves, but does not remove, the first element of this
274 <     * deque.  This method differs from the <tt>peek</tt> method only
274 >     * deque.  This method differs from the <tt>peekFirst</tt> method only
275       * in that it throws an exception if this deque is empty.
276       *
277       * @return the first element of this deque
# Line 281 | Line 281 | public interface Deque<E> extends Queue<
281  
282      /**
283       * Retrieves, but does not remove, the last element of this
284 <     * deque.  This method differs from the <tt>peek</tt> method only
284 >     * deque.  This method differs from the <tt>peekLast</tt> method only
285       * in that it throws an exception if this deque is empty.
286       *
287       * @return the last element of this deque
# Line 296 | Line 296 | public interface Deque<E> extends Queue<
296       * such that <tt>(o==null ? e==null : o.equals(e))</tt> (if
297       * such an element exists).
298       *
299 <     * @param e element to be removed from this deque, if present
299 >     * @param o element to be removed from this deque, if present
300       * @return <tt>true</tt> if the deque contained the specified element
301 <     * @throws NullPointerException if the specified element is <tt>null</tt>
301 >     * @throws NullPointerException if the specified element is null and this
302 >     *     deque does not permit null elements
303       */
304 <    boolean removeFirstOccurrence(Object e);
304 >    boolean removeFirstOccurrence(Object o);
305  
306      /**
307       * Removes the last occurrence of the specified element in this
# Line 309 | Line 310 | public interface Deque<E> extends Queue<
310       * such that <tt>(o==null ? e==null : o.equals(e))</tt> (if
311       * such an element exists).
312       *
313 <     * @param e element to be removed from this deque, if present
313 >     * @param o element to be removed from this deque, if present
314       * @return <tt>true</tt> if the deque contained the specified element
315 <     * @throws NullPointerException if the specified element is <tt>null</tt>
315 >     * @throws NullPointerException if the specified element is null and this
316 >     *     deque does not permit null elements
317       */
318 <    boolean removeLastOccurrence(Object e);
318 >    boolean removeLastOccurrence(Object o);
319  
320  
321      // *** Queue methods ***
# Line 321 | Line 323 | public interface Deque<E> extends Queue<
323      /**
324       * Inserts the specified element into the queue represented by this deque
325       * unless it would violate capacity restrictions.  In other words, inserts
326 <     * the specified element to the end of this deque.  When using a
326 >     * the specified element at the end of this deque.  When using a
327       * capacity-restricted deque, this method is generally preferable to the
328       * {@link #add} method, which can fail to insert an element only by
329       * throwing an exception.
# Line 331 | Line 333 | public interface Deque<E> extends Queue<
333       * @param e the element to insert
334       * @return <tt>true</tt> if it was possible to insert the element,
335       *     else <tt>false</tt>
336 <     * @throws NullPointerException if <tt>e</tt> is null and this
336 >     * @throws NullPointerException if the specified element is null and this
337       *     deque does not permit null elements
338       */
339      boolean offer(E e);
# Line 339 | Line 341 | public interface Deque<E> extends Queue<
341      /**
342       * Inserts the specified element into the queue represented by this
343       * deque unless it would violate capacity restrictions.  In other words,
344 <     * inserts the specified element as the last element of this deque.
344 >     * inserts the specified element as the last element of this deque.
345       *
346       * <p>This method is equivalent to {@link #addLast}.
347       *
# Line 347 | Line 349 | public interface Deque<E> extends Queue<
349       * @return <tt>true</tt> (as per the spec for {@link Collection#add})
350       * @throws IllegalStateException if it was not possible to insert
351       *    the element due to capacity restrictions
352 <     * @throws NullPointerException if <tt>e</tt> is null and this
352 >     * @throws NullPointerException if the specified element is null and this
353       *     deque does not permit null elements
354       */
355      boolean add(E e);
# Line 381 | Line 383 | public interface Deque<E> extends Queue<
383       * Retrieves, but does not remove, the head of the queue represented by
384       * this deque, returning <tt>null</tt> if this deque is empty.
385       *
386 <     * <p>This method is equivalent to {@link #peekFirst()}
386 >     * <p>This method is equivalent to {@link #peekFirst()}.
387       *
388       * @return the head of the queue represented by this deque, or
389       *     <tt>null</tt> if this deque is empty
# Line 393 | Line 395 | public interface Deque<E> extends Queue<
395       * this deque.  This method differs from the <tt>peek</tt> method only in
396       * that it throws an exception if this deque is empty.
397       *
398 <     * <p>This method is equivalent to {@link #getFirst()}
398 >     * <p>This method is equivalent to {@link #getFirst()}.
399       *
400       * @return the head of the queue represented by this deque
401       * @throws NoSuchElementException if this deque is empty
# Line 405 | Line 407 | public interface Deque<E> extends Queue<
407  
408      /**
409       * Pushes an element onto the stack represented by this deque.  In other
410 <     * words, inserts the element to the front this deque unless it would
410 >     * words, inserts the element at the front of this deque unless it would
411       * violate capacity restrictions.
412       *
413       * <p>This method is equivalent to {@link #addFirst}.
414       *
415 +     * @param e the element to push
416       * @throws IllegalStateException if it was not possible to insert
417       *    the element due to capacity restrictions
418 <     * @throws NullPointerException if <tt>e</tt> is null and this
418 >     * @throws NullPointerException if the specified element is null and this
419       *     deque does not permit null elements
420       */
421      void push(E e);
# Line 435 | Line 438 | public interface Deque<E> extends Queue<
438      /**
439       * Returns an iterator over the elements in this deque.  The elements
440       * will be ordered from first (head) to last (tail).
441 <     *
441 >     *
442       * @return an <tt>Iterator</tt> over the elements in this deque
443       */
444      Iterator<E> iterator();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines