21 |
|
* |
22 |
|
* <p>This class and its iterator implement all of the |
23 |
|
* <em>optional</em> methods of the {@link Collection} and {@link |
24 |
< |
* Iterator} interfaces. |
24 |
> |
* Iterator} interfaces. |
25 |
|
* The Iterator provided in method {@link #iterator()} is |
26 |
|
* <em>not</em> guaranteed to traverse the elements of the |
27 |
|
* PriorityBlockingQueue in any particular order. If you need ordered |
44 |
|
private final Condition notEmpty = lock.newCondition(); |
45 |
|
|
46 |
|
/** |
47 |
< |
* Creates a <tt>PriorityBlockingQueue</tt> with the default initial |
47 |
> |
* Creates a <tt>PriorityBlockingQueue</tt> with the default initial |
48 |
|
* capacity |
49 |
|
* (11) that orders its elements according to their natural |
50 |
|
* ordering (using <tt>Comparable</tt>). |
55 |
|
|
56 |
|
/** |
57 |
|
* Creates a <tt>PriorityBlockingQueue</tt> with the specified initial |
58 |
< |
* capacity |
59 |
< |
* that orders its elements according to their natural ordering |
60 |
< |
* (using <tt>Comparable</tt>). |
58 |
> |
* capacity that orders its elements according to their {@linkplain |
59 |
> |
* Comparable natural ordering}. |
60 |
|
* |
61 |
|
* @param initialCapacity the initial capacity for this priority queue. |
62 |
|
* @throws IllegalArgumentException if <tt>initialCapacity</tt> is less |
68 |
|
|
69 |
|
/** |
70 |
|
* Creates a <tt>PriorityBlockingQueue</tt> with the specified initial |
71 |
< |
* capacity |
72 |
< |
* that orders its elements according to the specified comparator. |
71 |
> |
* capacity that orders its elements according to the specified |
72 |
> |
* comparator. |
73 |
|
* |
74 |
|
* @param initialCapacity the initial capacity for this priority queue. |
75 |
|
* @param comparator the comparator used to order this priority queue. |
86 |
|
/** |
87 |
|
* Creates a <tt>PriorityBlockingQueue</tt> containing the elements |
88 |
|
* in the specified collection. The priority queue has an initial |
89 |
< |
* capacity of 110% of the size of the specified collection. If |
89 |
> |
* capacity of 110% of the size of the specified collection. If |
90 |
|
* the specified collection is a {@link SortedSet} or a {@link |
91 |
|
* PriorityQueue}, this priority queue will be sorted according to |
92 |
< |
* the same comparator, or according to its elements' natural |
93 |
< |
* order if the collection is sorted according to its elements' |
94 |
< |
* natural order. Otherwise, this priority queue is ordered |
95 |
< |
* according to its elements' natural order. |
92 |
> |
* the same comparator, or according to the natural ordering of its |
93 |
> |
* elements if the collection is sorted according to the natural |
94 |
> |
* ordering of its elements. Otherwise, this priority queue is |
95 |
> |
* ordered according to the natural ordering of its elements. |
96 |
|
* |
97 |
|
* @param c the collection whose elements are to be placed |
98 |
|
* into this priority queue. |
125 |
|
} |
126 |
|
|
127 |
|
/** |
128 |
< |
* Returns the comparator used to order this collection, or <tt>null</tt> |
129 |
< |
* if this collection is sorted according to its elements natural ordering |
130 |
< |
* (using <tt>Comparable</tt>). |
128 |
> |
* Returns the comparator used to order the elements in this queue, |
129 |
> |
* or <tt>null</tt> if this queue uses the {@linkplain Comparable |
130 |
> |
* natural ordering} of its elements. |
131 |
|
* |
132 |
< |
* @return the comparator used to order this collection, or <tt>null</tt> |
133 |
< |
* if this collection is sorted according to its elements natural ordering. |
132 |
> |
* @return the comparator used to order the elements in this queue, |
133 |
> |
* or <tt>null</tt> if this queue uses the natural |
134 |
> |
* ordering of its elements. |
135 |
|
*/ |
136 |
|
public Comparator<? super E> comparator() { |
137 |
|
return q.comparator(); |
387 |
|
* Returns an iterator over the elements in this queue. The |
388 |
|
* iterator does not return the elements in any particular order. |
389 |
|
* The returned iterator is a thread-safe "fast-fail" iterator |
390 |
< |
* that will throw {@link |
391 |
< |
* java.util.ConcurrentModificationException} upon detected |
392 |
< |
* interference. |
390 |
> |
* that will throw {@link ConcurrentModificationException} upon |
391 |
> |
* detected interference. |
392 |
|
* |
393 |
|
* @return an iterator over the elements in this queue. |
394 |
|
*/ |