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

Comparing jsr166/src/main/java/util/concurrent/PriorityBlockingQueue.java (file contents):
Revision 1.62 by jsr166, Mon Oct 11 17:55:13 2010 UTC vs.
Revision 1.63 by jsr166, Mon Oct 11 18:04:56 2010 UTC

# Line 14 | Line 14 | import java.util.*;
14   * the same ordering rules as class {@link PriorityQueue} and supplies
15   * blocking retrieval operations.  While this queue is logically
16   * unbounded, attempted additions may fail due to resource exhaustion
17 < * (causing <tt>OutOfMemoryError</tt>). This class does not permit
18 < * <tt>null</tt> elements.  A priority queue relying on {@linkplain
17 > * (causing {@code OutOfMemoryError}). This class does not permit
18 > * {@code null} elements.  A priority queue relying on {@linkplain
19   * Comparable natural ordering} also does not permit insertion of
20   * non-comparable objects (doing so results in
21 < * <tt>ClassCastException</tt>).
21 > * {@code ClassCastException}).
22   *
23   * <p>This class and its iterator implement all of the
24   * <em>optional</em> methods of the {@link Collection} and {@link
# Line 26 | Line 26 | import java.util.*;
26   * #iterator()} is <em>not</em> guaranteed to traverse the elements of
27   * the PriorityBlockingQueue in any particular order. If you need
28   * ordered traversal, consider using
29 < * <tt>Arrays.sort(pq.toArray())</tt>.  Also, method <tt>drainTo</tt>
29 > * {@code Arrays.sort(pq.toArray())}.  Also, method {@code drainTo}
30   * can be used to <em>remove</em> some or all elements in priority
31   * order and place them in another collection.
32   *
# Line 36 | Line 36 | import java.util.*;
36   * secondary key to break ties in primary priority values.  For
37   * example, here is a class that applies first-in-first-out
38   * tie-breaking to comparable elements. To use it, you would insert a
39 < * <tt>new FIFOEntry(anEntry)</tt> instead of a plain entry object.
39 > * {@code new FIFOEntry(anEntry)} instead of a plain entry object.
40   *
41   *  <pre> {@code
42   * class FIFOEntry<E extends Comparable<? super E>>
# Line 127 | Line 127 | public class PriorityBlockingQueue<E> ex
127      private transient volatile int allocationSpinLock;
128  
129      /**
130 <     * Creates a <tt>PriorityBlockingQueue</tt> with the default
130 >     * Creates a {@code PriorityBlockingQueue} with the default
131       * initial capacity (11) that orders its elements according to
132       * their {@linkplain Comparable natural ordering}.
133       */
# Line 136 | Line 136 | public class PriorityBlockingQueue<E> ex
136      }
137  
138      /**
139 <     * Creates a <tt>PriorityBlockingQueue</tt> with the specified
139 >     * Creates a {@code PriorityBlockingQueue} with the specified
140       * initial capacity that orders its elements according to their
141       * {@linkplain Comparable natural ordering}.
142       *
143       * @param initialCapacity the initial capacity for this priority queue
144 <     * @throws IllegalArgumentException if <tt>initialCapacity</tt> is less
144 >     * @throws IllegalArgumentException if {@code initialCapacity} is less
145       *         than 1
146       */
147      public PriorityBlockingQueue(int initialCapacity) {
# Line 149 | Line 149 | public class PriorityBlockingQueue<E> ex
149      }
150  
151      /**
152 <     * Creates a <tt>PriorityBlockingQueue</tt> with the specified initial
152 >     * Creates a {@code PriorityBlockingQueue} with the specified initial
153       * capacity that orders its elements according to the specified
154       * comparator.
155       *
# Line 157 | Line 157 | public class PriorityBlockingQueue<E> ex
157       * @param  comparator the comparator that will be used to order this
158       *         priority queue.  If {@code null}, the {@linkplain Comparable
159       *         natural ordering} of the elements will be used.
160 <     * @throws IllegalArgumentException if <tt>initialCapacity</tt> is less
160 >     * @throws IllegalArgumentException if {@code initialCapacity} is less
161       *         than 1
162       */
163      public PriorityBlockingQueue(int initialCapacity,
# Line 169 | Line 169 | public class PriorityBlockingQueue<E> ex
169      }
170  
171      /**
172 <     * Creates a <tt>PriorityBlockingQueue</tt> containing the elements
172 >     * Creates a {@code PriorityBlockingQueue} containing the elements
173       * in the specified collection.  If the specified collection is a
174       * {@link SortedSet} or a {@link PriorityQueue},  this
175       * priority queue will be ordered according to the same ordering.
# Line 402 | Line 402 | public class PriorityBlockingQueue<E> ex
402       * Inserts the specified element into this priority queue.
403       *
404       * @param e the element to add
405 <     * @return <tt>true</tt> (as specified by {@link Collection#add})
405 >     * @return {@code true} (as specified by {@link Collection#add})
406       * @throws ClassCastException if the specified element cannot be compared
407       *         with elements currently in the priority queue according to the
408       *         priority queue's ordering
# Line 416 | Line 416 | public class PriorityBlockingQueue<E> ex
416       * Inserts the specified element into this priority queue.
417       *
418       * @param e the element to add
419 <     * @return <tt>true</tt> (as specified by {@link Queue#offer})
419 >     * @return {@code true} (as specified by {@link Queue#offer})
420       * @throws ClassCastException if the specified element cannot be compared
421       *         with elements currently in the priority queue according to the
422       *         priority queue's ordering
# Line 465 | Line 465 | public class PriorityBlockingQueue<E> ex
465       * @param e the element to add
466       * @param timeout This parameter is ignored as the method never blocks
467       * @param unit This parameter is ignored as the method never blocks
468 <     * @return <tt>true</tt>
468 >     * @return {@code true} always
469       * @throws ClassCastException if the specified element cannot be compared
470       *         with elements currently in the priority queue according to the
471       *         priority queue's ordering
# Line 527 | Line 527 | public class PriorityBlockingQueue<E> ex
527  
528      /**
529       * Returns the comparator used to order the elements in this queue,
530 <     * or <tt>null</tt> if this queue uses the {@linkplain Comparable
530 >     * or {@code null} if this queue uses the {@linkplain Comparable
531       * natural ordering} of its elements.
532       *
533       * @return the comparator used to order the elements in this queue,
534 <     *         or <tt>null</tt> if this queue uses the natural
534 >     *         or {@code null} if this queue uses the natural
535       *         ordering of its elements
536       */
537      public Comparator<? super E> comparator() {
# Line 551 | Line 551 | public class PriorityBlockingQueue<E> ex
551      }
552  
553      /**
554 <     * Always returns <tt>Integer.MAX_VALUE</tt> because
555 <     * a <tt>PriorityBlockingQueue</tt> is not capacity constrained.
556 <     * @return <tt>Integer.MAX_VALUE</tt>
554 >     * Always returns {@code Integer.MAX_VALUE} because
555 >     * a {@code PriorityBlockingQueue} is not capacity constrained.
556 >     * @return {@code Integer.MAX_VALUE} always
557       */
558      public int remainingCapacity() {
559          return Integer.MAX_VALUE;
# Line 593 | Line 593 | public class PriorityBlockingQueue<E> ex
593       * result of the call).
594       *
595       * @param o element to be removed from this queue, if present
596 <     * @return <tt>true</tt> if this queue changed as a result of the call
596 >     * @return {@code true} if this queue changed as a result of the call
597       */
598      public boolean remove(Object o) {
599          boolean removed = false;
# Line 636 | Line 636 | public class PriorityBlockingQueue<E> ex
636       * at least one element {@code e} such that {@code o.equals(e)}.
637       *
638       * @param o object to be checked for containment in this queue
639 <     * @return <tt>true</tt> if this queue contains the specified element
639 >     * @return {@code true} if this queue contains the specified element
640       */
641      public boolean contains(Object o) {
642          int index;
# Line 776 | Line 776 | public class PriorityBlockingQueue<E> ex
776       * <p>If this queue fits in the specified array with room to spare
777       * (i.e., the array has more elements than this queue), the element in
778       * the array immediately following the end of the queue is set to
779 <     * <tt>null</tt>.
779 >     * {@code null}.
780       *
781       * <p>Like the {@link #toArray()} method, this method acts as bridge between
782       * array-based and collection-based APIs.  Further, this method allows
783       * precise control over the runtime type of the output array, and may,
784       * under certain circumstances, be used to save allocation costs.
785       *
786 <     * <p>Suppose <tt>x</tt> is a queue known to contain only strings.
786 >     * <p>Suppose {@code x} is a queue known to contain only strings.
787       * The following code can be used to dump the queue into a newly
788 <     * allocated array of <tt>String</tt>:
788 >     * allocated array of {@code String}:
789       *
790       * <pre>
791       *     String[] y = x.toArray(new String[0]);</pre>
792       *
793 <     * Note that <tt>toArray(new Object[0])</tt> is identical in function to
794 <     * <tt>toArray()</tt>.
793 >     * Note that {@code toArray(new Object[0])} is identical in function to
794 >     * {@code toArray()}.
795       *
796       * @param a the array into which the elements of the queue are to
797       *          be stored, if it is big enough; otherwise, a new array of the
# Line 821 | Line 821 | public class PriorityBlockingQueue<E> ex
821      /**
822       * Returns an iterator over the elements in this queue. The
823       * iterator does not return the elements in any particular order.
824 <     * The returned <tt>Iterator</tt> is a "weakly consistent"
824 >     * The returned {@code Iterator} is a "weakly consistent"
825       * iterator that will never throw {@link
826       * ConcurrentModificationException}, and guarantees to traverse
827       * elements as they existed upon construction of the iterator, and

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines