94
95 /**
96 * Priority queue represented as a balanced binary heap: the two
97 * children of queue[n] are queue[2*n+1] and queue[2*(n+1)]. The
98 * priority queue is ordered by comparator, or by the elements'
99 * natural ordering, if comparator is null: For each node n in the
100 * heap and each descendant d of n, n <= d. The element with the
101 * lowest value is in queue[0], assuming the queue is nonempty.
102 */
103 transient Object[] queue; // non-private to simplify nested class access
104
105 /**
106 * The number of elements in the priority queue.
107 */
108 int size;
109
110 /**
111 * The comparator, or null if priority queue uses elements'
112 * natural ordering.
113 */
114 private final Comparator<? super E> comparator;
115
116 /**
117 * The number of times this priority queue has been
118 * <i>structurally modified</i>. See AbstractList for gory details.
119 */
120 transient int modCount; // non-private to simplify nested class access
121
122 /**
123 * Creates a {@code PriorityQueue} with the default initial
124 * capacity (11) that orders its elements according to their
125 * {@linkplain Comparable natural ordering}.
126 */
127 public PriorityQueue() {
128 this(DEFAULT_INITIAL_CAPACITY, null);
129 }
130
131 /**
132 * Creates a {@code PriorityQueue} with the specified initial
133 * capacity that orders its elements according to their
|
94
95 /**
96 * Priority queue represented as a balanced binary heap: the two
97 * children of queue[n] are queue[2*n+1] and queue[2*(n+1)]. The
98 * priority queue is ordered by comparator, or by the elements'
99 * natural ordering, if comparator is null: For each node n in the
100 * heap and each descendant d of n, n <= d. The element with the
101 * lowest value is in queue[0], assuming the queue is nonempty.
102 */
103 transient Object[] queue; // non-private to simplify nested class access
104
105 /**
106 * The number of elements in the priority queue.
107 */
108 int size;
109
110 /**
111 * The comparator, or null if priority queue uses elements'
112 * natural ordering.
113 */
114 @SuppressWarnings("serial") // Conditionally serializable
115 private final Comparator<? super E> comparator;
116
117 /**
118 * The number of times this priority queue has been
119 * <i>structurally modified</i>. See AbstractList for gory details.
120 */
121 transient int modCount; // non-private to simplify nested class access
122
123 /**
124 * Creates a {@code PriorityQueue} with the default initial
125 * capacity (11) that orders its elements according to their
126 * {@linkplain Comparable natural ordering}.
127 */
128 public PriorityQueue() {
129 this(DEFAULT_INITIAL_CAPACITY, null);
130 }
131
132 /**
133 * Creates a {@code PriorityQueue} with the specified initial
134 * capacity that orders its elements according to their
|