ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/PriorityBlockingQueue.java
Revision: 1.3
Committed: Thu May 29 13:49:24 2003 UTC (21 years ago) by dl
Branch: MAIN
CVS Tags: JSR166_PRERELEASE_0_1
Changes since 1.2: +1 -1 lines
Log Message:
Please the new generics compiler

File Contents

# Content
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.concurrent;
8 import java.util.*;
9
10 /**
11 * A blocking priority queue. Ordering follows the
12 * java.util.Collection conventions: Either the elements must be
13 * Comparable, or a Comparator must be supplied. Elements with tied
14 * priorities are returned in arbitrary order. Comparison failures
15 * throw ClassCastExceptions during insertions and extractions.
16 **/
17 public class PriorityBlockingQueue<E> extends AbstractBlockingQueueFromQueue<E>
18 implements BlockingQueue<E>, java.io.Serializable {
19
20 /**
21 * Create a new priority queue with the default initial capacity (11)
22 * that orders its elements according to their natural ordering.
23 */
24 public PriorityBlockingQueue() {
25 super(new PriorityQueue<E>(), Integer.MAX_VALUE);
26 }
27
28 /**
29 * Create a new priority queue with the specified initial capacity
30 * that orders its elements according to their natural ordering.
31 *
32 * @param initialCapacity the initial capacity for this priority queue.
33 */
34 public PriorityBlockingQueue(int initialCapacity) {
35 super(new PriorityQueue<E>(initialCapacity, null), Integer.MAX_VALUE);
36 }
37
38 /**
39 * Create a new priority queue with the specified initial capacity (11)
40 * that orders its elements according to the specified comparator.
41 *
42 * @param initialCapacity the initial capacity for this priority queue.
43 * @param comparator the comparator used to order this priority queue.
44 */
45 public PriorityBlockingQueue(int initialCapacity, Comparator<E> comparator) {
46 super(new PriorityQueue<E>(initialCapacity, comparator), Integer.MAX_VALUE);
47 }
48
49 /**
50 * Create a new priority queue containing the elements in the specified
51 * collection. The priority queue has an initial capacity of 110% of the
52 * size of the specified collection. If the specified collection
53 * implements the {@link Sorted} interface, the priority queue will be
54 * sorted according to the same comparator, or according to its elements'
55 * natural order if the collection is sorted according to its elements'
56 * natural order. If the specified collection does not implement the
57 * <tt>Sorted</tt> interface, the priority queue is ordered according to
58 * its elements' natural order.
59 *
60 * @param initialElements the collection whose elements are to be placed
61 * into this priority queue.
62 * @throws ClassCastException if elements of the specified collection
63 * cannot be compared to one another according to the priority
64 * queue's ordering.
65 * @throws NullPointerException if the specified collection or an
66 * element of the specified collection is <tt>null</tt>.
67 */
68 public PriorityBlockingQueue(Collection<E> initialElements) {
69 super(new PriorityQueue<E>(initialElements), Integer.MAX_VALUE);
70 }
71
72 }