119 * {@linkplain Comparable natural ordering}.
120 */
121 public PriorityQueue() {
122 this(DEFAULT_INITIAL_CAPACITY, null);
123 }
124
125 /**
126 * Creates a {@code PriorityQueue} with the specified initial
127 * capacity that orders its elements according to their
128 * {@linkplain Comparable natural ordering}.
129 *
130 * @param initialCapacity the initial capacity for this priority queue
131 * @throws IllegalArgumentException if {@code initialCapacity} is less
132 * than 1
133 */
134 public PriorityQueue(int initialCapacity) {
135 this(initialCapacity, null);
136 }
137
138 /**
139 * Creates a {@code PriorityQueue} with the specified initial capacity
140 * that orders its elements according to the specified comparator.
141 *
142 * @param initialCapacity the initial capacity for this priority queue
143 * @param comparator the comparator that will be used to order this
144 * priority queue. If {@code null}, the {@linkplain Comparable
145 * natural ordering} of the elements will be used.
146 * @throws IllegalArgumentException if {@code initialCapacity} is
147 * less than 1
148 */
149 public PriorityQueue(int initialCapacity,
150 Comparator<? super E> comparator) {
151 // Note: This restriction of at least one is not actually needed,
152 // but continues for 1.5 compatibility
153 if (initialCapacity < 1)
154 throw new IllegalArgumentException();
155 this.queue = new Object[initialCapacity];
156 this.comparator = comparator;
157 }
158
|
119 * {@linkplain Comparable natural ordering}.
120 */
121 public PriorityQueue() {
122 this(DEFAULT_INITIAL_CAPACITY, null);
123 }
124
125 /**
126 * Creates a {@code PriorityQueue} with the specified initial
127 * capacity that orders its elements according to their
128 * {@linkplain Comparable natural ordering}.
129 *
130 * @param initialCapacity the initial capacity for this priority queue
131 * @throws IllegalArgumentException if {@code initialCapacity} is less
132 * than 1
133 */
134 public PriorityQueue(int initialCapacity) {
135 this(initialCapacity, null);
136 }
137
138 /**
139 * Creates a {@code PriorityQueue} with the default initial capacity
140 * that orders its elements according to the specified comparator.
141 *
142 * @param comparator the comparator that will be used to order this
143 * priority queue. If {@code null}, the {@linkplain Comparable
144 * natural ordering} of the elements will be used.
145 * @since 1.8
146 */
147 public PriorityQueue(Comparator<? super E> comparator) {
148 this(DEFAULT_INITIAL_CAPACITY, comparator);
149 }
150
151 /**
152 * Creates a {@code PriorityQueue} with the specified initial capacity
153 * that orders its elements according to the specified comparator.
154 *
155 * @param initialCapacity the initial capacity for this priority queue
156 * @param comparator the comparator that will be used to order this
157 * priority queue. If {@code null}, the {@linkplain Comparable
158 * natural ordering} of the elements will be used.
159 * @throws IllegalArgumentException if {@code initialCapacity} is
160 * less than 1
161 */
162 public PriorityQueue(int initialCapacity,
163 Comparator<? super E> comparator) {
164 // Note: This restriction of at least one is not actually needed,
165 // but continues for 1.5 compatibility
166 if (initialCapacity < 1)
167 throw new IllegalArgumentException();
168 this.queue = new Object[initialCapacity];
169 this.comparator = comparator;
170 }
171
|