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

Comparing jsr166/src/main/java/util/Queue.java (file contents):
Revision 1.2 by tim, Sun May 18 18:10:02 2003 UTC vs.
Revision 1.6 by brian, Mon Jun 23 02:26:15 2003 UTC

# Line 1 | Line 1
1 + /*
2 + * Written by Doug Lea with assistance from members of JCP JSR-166
3 + * Expert Group and released to the public domain. Use, modify, and
4 + * redistribute this code in any way without acknowledgement.
5 + */
6 +
7   package java.util;
8  
9   /**
10   * A Collection designed for holding elements prior to processing.
11   * Besides basic {@link Collection} operations, queues provide
12   * additional insertion, extraction, and inspection operations.
13 < *
13 > 0 *
14   * <p>Queues typically, but do not necessarily, order elements in a
15 < * FIFO (first-in-first-out) manner.  Among the exceptions are priority
16 < * queues, which order elements according to a supplied comparators, or
17 < * the elements natural ordering.  Every Queue implementation must specify
18 < * its ordering guarantees.
15 > * FIFO (first-in-first-out) manner.  Among the exceptions are
16 > * priority queues, which order elements according to a supplied
17 > * comparator, or the elements' natural ordering.  Every Queue
18 > * implementation must specify its ordering guarantees.
19   *
20   * <p>The {@link #offer(E)} method adds an element if possible, otherwise
21   * returning <tt>false</tt>.  This differs from the {@link
# Line 17 | Line 23 | package java.util;
23   * failure. It is designed for use in collections in which failure to
24   * add is a normal, rather than exceptional occurrence, for example,
25   * in fixed-capacity (or &ldquo;bounded&rdquo;) queues.
26 < *
26 >
27 > *
28   * <p>The {@link #remove()} and {@link #poll()} methods remove and return an
29 < * element in accord with the implementation's ordering policy. For example,
30 < * in FIFO queues, they remove and return the oldest element in the queue.
29 > * element in accord with the implementation's ordering policy.
30 > * Exactly which element is removed from the queue is a function
31 > * of the queue's ordering policy, which differs from implementation
32 > * to implementation.  Possible orderings include (but are not limited
33 > * to) first-in-first-out (FIFO), last-in-first-out (LIFO), element priority, and arbitrary.
34   * The <tt>remove()</tt> and <tt>poll()</tt> methods differ only in their
35   * behavior when the queue is empty: the <tt>remove()</tt> method throws an
36   * exception, while the <tt>poll()</tt> method returns <tt>null</tt>.
# Line 36 | Line 46 | package java.util;
46   * extends this interface.
47   *
48   * <p><tt>Queue</tt> implementations generally do not allow insertion of
49 < * <tt>null</tt> elements.  Even in the few implementations that permit it,
50 < * it is a bad idea, as <tt>null</tt> is also used as a special return value
49 > * <tt>null</tt> elements, although some implementations, such as
50 > * {@link LinkedList}, do not prohibit insertion of <tt>null</tt>.
51 > * Even in the implementations that permit it, <tt>null</tt> should not be inserted into
52 > * a <tt>Queue</tt>, as <tt>null</tt> is also used as a special return value
53   * by the <tt>poll</tt> method to indicate that the queue contains no
54   * elements.
55   *
# Line 48 | Line 60 | package java.util;
60   * @see Collection
61   * @see LinkedList
62   * @see PriorityQueue
63 < * @see LinkedQueue
63 > * @see java.util.concurrent.LinkedQueue
64   * @see java.util.concurrent.BlockingQueue
65   * @see java.util.concurrent.ArrayBlockingQueue
66   * @see java.util.concurrent.LinkedBlockingQueue
# Line 65 | Line 77 | public interface Queue<E> extends Collec
77  
78      /**
79       * Remove and return an element from the queue if one is available.
68     * Exactly which element is removed from the queue is a function
69     * of the queue's ordering policy, which differs from implementation
70     * to implementation.  Possible orderings include (but are not limited
71     * to) first-in-first-out (FIFO), element priority, and arbitrary.
80       *
81       * @return an element previously on the queue, or <tt>null</tt> if the
82 <     *         queue is empty.
82 >     *         queue is empty.
83       */
84      public E poll();
85  
86      /**
87       * Remove and return an element from the queue.  This method differs
88       * from the <tt>poll</tt> method in that it throws an exception if the
89 <     * queue is empty.
89 >     * queue is empty.
90       *
91       * @return an element previously on the queue.
92       * @throws NoSuchElementException if the queue is empty.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines