ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/PriorityBlockingQueue.java
Revision: 1.4
Committed: Fri Jun 6 16:53:05 2003 UTC (21 years ago) by dl
Branch: MAIN
CVS Tags: JSR166_PRELIMINARY_TEST_RELEASE_1
Changes since 1.3: +4 -5 lines
Log Message:
Minor doc updates; FairReentrantLock serialize now

File Contents

# User Rev Content
1 dl 1.2 /*
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 tim 1.1 package java.util.concurrent;
8     import java.util.*;
9    
10     /**
11 dl 1.4 * A blocking queue based on a {@link PriorityQueue}, obeying its
12     * ordering rules and implementation characteristics. The queue is
13     * essentially unbounded; it blocks only on attempts to insert more
14     * than <tt>Integer.MAX_VALUE</tt> untaken elements.
15 tim 1.1 **/
16 dl 1.2 public class PriorityBlockingQueue<E> extends AbstractBlockingQueueFromQueue<E>
17 tim 1.1 implements BlockingQueue<E>, java.io.Serializable {
18    
19 dl 1.2 /**
20     * Create a new priority queue with the default initial capacity (11)
21     * that orders its elements according to their natural ordering.
22     */
23     public PriorityBlockingQueue() {
24     super(new PriorityQueue<E>(), Integer.MAX_VALUE);
25     }
26    
27     /**
28     * Create a new priority queue with the specified initial capacity
29     * that orders its elements according to their natural ordering.
30     *
31     * @param initialCapacity the initial capacity for this priority queue.
32     */
33     public PriorityBlockingQueue(int initialCapacity) {
34     super(new PriorityQueue<E>(initialCapacity, null), Integer.MAX_VALUE);
35     }
36    
37     /**
38     * Create a new priority queue with the specified initial capacity (11)
39     * that orders its elements according to the specified comparator.
40     *
41     * @param initialCapacity the initial capacity for this priority queue.
42     * @param comparator the comparator used to order this priority queue.
43     */
44 dl 1.3 public PriorityBlockingQueue(int initialCapacity, Comparator<E> comparator) {
45 dl 1.2 super(new PriorityQueue<E>(initialCapacity, comparator), Integer.MAX_VALUE);
46     }
47    
48     /**
49     * Create a new priority queue containing the elements in the specified
50     * collection. The priority queue has an initial capacity of 110% of the
51     * size of the specified collection. If the specified collection
52     * implements the {@link Sorted} interface, the priority queue will be
53     * sorted according to the same comparator, or according to its elements'
54     * natural order if the collection is sorted according to its elements'
55     * natural order. If the specified collection does not implement the
56     * <tt>Sorted</tt> interface, the priority queue is ordered according to
57     * its elements' natural order.
58     *
59     * @param initialElements the collection whose elements are to be placed
60     * into this priority queue.
61     * @throws ClassCastException if elements of the specified collection
62     * cannot be compared to one another according to the priority
63     * queue's ordering.
64     * @throws NullPointerException if the specified collection or an
65     * element of the specified collection is <tt>null</tt>.
66     */
67     public PriorityBlockingQueue(Collection<E> initialElements) {
68     super(new PriorityQueue<E>(initialElements), Integer.MAX_VALUE);
69 tim 1.1 }
70    
71     }