[cvs] / jsr166 / src / main / java / util / Deque.java Repository:
ViewVC logotype

Diff of /jsr166/src/main/java/util/Deque.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Tue Mar 8 12:27:06 2005 UTC revision 1.3, Tue Mar 22 01:29:00 2005 UTC
# Line 103  Line 103 
103   *   *
104   * <p>Deques can also be used as LIFO (Last-In-First-Out) stacks.  This   * <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.   * 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   * 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   * beginning of the deque.  Stack methods are precisely equivalent to
108   * <tt>Deque</tt> methods as indicated in the table below:<p>   * <tt>Deque</tt> methods as indicated in the table below:<p>
109   *   *
# Line 162  Line 162 
162    
163  public interface Deque<E> extends Queue<E> {  public interface Deque<E> extends Queue<E> {
164      /**      /**
165       * 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
166       * violate capacity restrictions.  When using a capacity-restricted deque,       * violate capacity restrictions.  When using a capacity-restricted deque,
167       * this method is generally preferable to method <tt>addFirst</tt>, which       * this method is generally preferable to method <tt>addFirst</tt>, which
168       * can fail to insert an element only by throwing an exception.       * can fail to insert an element only by throwing an exception.
# Line 170  Line 170 
170       * @param e the element to insert       * @param e the element to insert
171       * @return <tt>true</tt> if it was possible to insert the element,       * @return <tt>true</tt> if it was possible to insert the element,
172       *     else <tt>false</tt>       *     else <tt>false</tt>
173       * @throws NullPointerException if <tt>e</tt> is null and this       * @throws NullPointerException if the specified element is null and this
174       *     deque does not permit null elements       *     deque does not permit null elements
175       */       */
176      boolean offerFirst(E e);      boolean offerFirst(E e);
# Line 184  Line 184 
184       * @param e the element to insert       * @param e the element to insert
185       * @return <tt>true</tt> if it was possible to insert the element,       * @return <tt>true</tt> if it was possible to insert the element,
186       *     else <tt>false</tt>       *     else <tt>false</tt>
187       * @throws NullPointerException if <tt>e</tt> is null and this       * @throws NullPointerException if the specified element is null and this
188       *     deque does not permit null elements       *     deque does not permit null elements
189       */       */
190      boolean offerLast(E e);      boolean offerLast(E e);
191    
192      /**      /**
193       * Inserts the specified element to the front of this deque unless it       * Inserts the specified element at the front of this deque unless it
194       * would violate capacity restrictions.       * would violate capacity restrictions.
195       *       *
196       * @param e the element to insert       * @param e the element to insert
197       * @throws IllegalStateException if it was not possible to insert       * @throws IllegalStateException if it was not possible to insert
198       *    the element due to capacity restrictions       *    the element due to capacity restrictions
199       * @throws NullPointerException if <tt>e</tt> is null and this       * @throws NullPointerException if the specified element is null and this
200       *     deque does not permit null elements       *     deque does not permit null elements
201       */       */
202      void addFirst(E e);      void addFirst(E e);
# Line 208  Line 208 
208       * @param e the element to insert       * @param e the element to insert
209       * @throws IllegalStateException if it was not possible to insert       * @throws IllegalStateException if it was not possible to insert
210       *    the element due to capacity restrictions       *    the element due to capacity restrictions
211       * @throws NullPointerException if <tt>e</tt> is null and this       * @throws NullPointerException if the specified element is null and this
212       *     deque does not permit null elements       *     deque does not permit null elements
213       */       */
214      void addLast(E e);      void addLast(E e);
# Line 271  Line 271 
271    
272      /**      /**
273       * Retrieves, but does not remove, the first element of this       * Retrieves, but does not remove, the first element of this
274       * deque.  This method differs from the <tt>peek</tt> method only       * deque.  This method differs from the <tt>peekFirst</tt> method only
275       * in that it throws an exception if this deque is empty.       * in that it throws an exception if this deque is empty.
276       *       *
277       * @return the first element of this deque       * @return the first element of this deque
# Line 281  Line 281 
281    
282      /**      /**
283       * Retrieves, but does not remove, the last element of this       * Retrieves, but does not remove, the last element of this
284       * deque.  This method differs from the <tt>peek</tt> method only       * deque.  This method differs from the <tt>peekLast</tt> method only
285       * in that it throws an exception if this deque is empty.       * in that it throws an exception if this deque is empty.
286       *       *
287       * @return the last element of this deque       * @return the last element of this deque
# Line 296  Line 296 
296       * such that <tt>(o==null ? e==null : o.equals(e))</tt> (if       * such that <tt>(o==null ? e==null : o.equals(e))</tt> (if
297       * such an element exists).       * such an element exists).
298       *       *
299       * @param e element to be removed from this deque, if present       * @param o element to be removed from this deque, if present
300       * @return <tt>true</tt> if the deque contained the specified element       * @return <tt>true</tt> if the deque contained the specified element
301       * @throws NullPointerException if the specified element is <tt>null</tt>       * @throws NullPointerException if the specified element is <tt>null</tt>
302       */       */
303      boolean removeFirstOccurrence(Object e);      boolean removeFirstOccurrence(Object o);
304    
305      /**      /**
306       * Removes the last occurrence of the specified element in this       * Removes the last occurrence of the specified element in this
# Line 309  Line 309 
309       * such that <tt>(o==null ? e==null : o.equals(e))</tt> (if       * such that <tt>(o==null ? e==null : o.equals(e))</tt> (if
310       * such an element exists).       * such an element exists).
311       *       *
312       * @param e element to be removed from this deque, if present       * @param o element to be removed from this deque, if present
313       * @return <tt>true</tt> if the deque contained the specified element       * @return <tt>true</tt> if the deque contained the specified element
314       * @throws NullPointerException if the specified element is <tt>null</tt>       * @throws NullPointerException if the specified element is <tt>null</tt>
315       */       */
316      boolean removeLastOccurrence(Object e);      boolean removeLastOccurrence(Object o);
317    
318    
319      // *** Queue methods ***      // *** Queue methods ***
# Line 331  Line 331 
331       * @param e the element to insert       * @param e the element to insert
332       * @return <tt>true</tt> if it was possible to insert the element,       * @return <tt>true</tt> if it was possible to insert the element,
333       *     else <tt>false</tt>       *     else <tt>false</tt>
334       * @throws NullPointerException if <tt>e</tt> is null and this       * @throws NullPointerException if the specified element is null and this
335       *     deque does not permit null elements       *     deque does not permit null elements
336       */       */
337      boolean offer(E e);      boolean offer(E e);
# Line 347  Line 347 
347       * @return <tt>true</tt> (as per the spec for {@link Collection#add})       * @return <tt>true</tt> (as per the spec for {@link Collection#add})
348       * @throws IllegalStateException if it was not possible to insert       * @throws IllegalStateException if it was not possible to insert
349       *    the element due to capacity restrictions       *    the element due to capacity restrictions
350       * @throws NullPointerException if <tt>e</tt> is null and this       * @throws NullPointerException if the specified element is null and this
351       *     deque does not permit null elements       *     deque does not permit null elements
352       */       */
353      boolean add(E e);      boolean add(E e);
# Line 381  Line 381 
381       * Retrieves, but does not remove, the head of the queue represented by       * Retrieves, but does not remove, the head of the queue represented by
382       * this deque, returning <tt>null</tt> if this deque is empty.       * this deque, returning <tt>null</tt> if this deque is empty.
383       *       *
384       * <p>This method is equivalent to {@link #peekFirst()}       * <p>This method is equivalent to {@link #peekFirst()}.
385       *       *
386       * @return the head of the queue represented by this deque, or       * @return the head of the queue represented by this deque, or
387       *     <tt>null</tt> if this deque is empty       *     <tt>null</tt> if this deque is empty
# Line 393  Line 393 
393       * this deque.  This method differs from the <tt>peek</tt> method only in       * this deque.  This method differs from the <tt>peek</tt> method only in
394       * that it throws an exception if this deque is empty.       * that it throws an exception if this deque is empty.
395       *       *
396       * <p>This method is equivalent to {@link #getFirst()}       * <p>This method is equivalent to {@link #getFirst()}.
397       *       *
398       * @return the head of the queue represented by this deque       * @return the head of the queue represented by this deque
399       * @throws NoSuchElementException if this deque is empty       * @throws NoSuchElementException if this deque is empty
# Line 405  Line 405 
405    
406      /**      /**
407       * Pushes an element onto the stack represented by this deque.  In other       * Pushes an element onto the stack represented by this deque.  In other
408       * 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
409       * violate capacity restrictions.       * violate capacity restrictions.
410       *       *
411       * <p>This method is equivalent to {@link #addFirst}.       * <p>This method is equivalent to {@link #addFirst}.
412       *       *
413         * @param e the element to push
414       * @throws IllegalStateException if it was not possible to insert       * @throws IllegalStateException if it was not possible to insert
415       *    the element due to capacity restrictions       *    the element due to capacity restrictions
416       * @throws NullPointerException if <tt>e</tt> is null and this       * @throws NullPointerException if the specified element is null and this
417       *     deque does not permit null elements       *     deque does not permit null elements
418       */       */
419      void push(E e);      void push(E e);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8