Lines Matching defs:queue

31  * An unbounded priority {@linkplain Queue queue} based on a priority heap.
32 * The elements of the priority queue are ordered according to their
34 * provided at queue construction time, depending on which constructor is
35 * used. A priority queue does not permit {@code null} elements.
36 * A priority queue relying on natural ordering also does not permit
40 * <p>The <em>head</em> of this queue is the <em>least</em> element
43 * broken arbitrarily. The queue retrieval operations {@code poll},
45 * element at the head of the queue.
47 * <p>A priority queue is unbounded, but has an internal
49 * elements on the queue. It is always at least as large as the queue
50 * size. As elements are added to a priority queue, its capacity
58 * the priority queue in any particular order. If you need ordered
63 * instance concurrently if any of the threads modifies the queue.
80 * @param <E> the type of elements held in this queue
90 * Priority queue represented as a balanced binary heap: the two
91 * children of queue[n] are queue[2*n+1] and queue[2*(n+1)]. The
92 * priority queue is ordered by comparator, or by the elements'
95 * lowest value is in queue[0], assuming the queue is nonempty.
97 transient Object[] queue; // non-private to simplify nested class access
100 * The number of elements in the priority queue.
105 * The comparator, or null if priority queue uses elements'
111 * The number of times this priority queue has been
130 * @param initialCapacity the initial capacity for this priority queue
143 * priority queue. If {@code null}, the {@linkplain Comparable
155 * @param initialCapacity the initial capacity for this priority queue
157 * priority queue. If {@code null}, the {@linkplain Comparable
168 this.queue = new Object[initialCapacity];
176 * priority queue will be ordered according to the same ordering.
177 * Otherwise, this priority queue will be ordered according to the
181 * into this priority queue
184 * queue's ordering
208 * specified priority queue. This priority queue will be
210 * queue.
212 * @param c the priority queue whose elements are to be placed
213 * into this priority queue
217 * @throws NullPointerException if the specified priority queue or any
228 * specified sorted set. This priority queue will be ordered
232 * into this priority queue
247 this.queue = c.toArray();
264 this.queue = a;
269 * Initializes queue array with elements from the given Collection.
292 int oldCapacity = queue.length;
300 queue = Arrays.copyOf(queue, newCapacity);
312 * Inserts the specified element into this priority queue.
316 * compared with elements currently in this priority queue
317 * according to the priority queue's ordering
325 * Inserts the specified element into this priority queue.
329 * compared with elements currently in this priority queue
330 * according to the priority queue's ordering
338 if (i >= queue.length)
342 queue[0] = e;
350 return (size == 0) ? null : (E) queue[0];
356 if (o.equals(queue[i]))
363 * Removes a single instance of the specified element from this queue,
365 * that {@code o.equals(e)}, if this queue contains one or more such
366 * elements. Returns {@code true} if and only if this queue contained
367 * the specified element (or equivalently, if this queue changed as a
370 * @param o element to be removed from this queue, if present
371 * @return {@code true} if this queue changed as a result of the call
387 * @param o element to be removed from this queue, if present
392 if (o == queue[i]) {
401 * Returns {@code true} if this queue contains the specified element.
402 * More formally, returns {@code true} if and only if this queue contains
405 * @param o object to be checked for containment in this queue
406 * @return {@code true} if this queue contains the specified element
413 * Returns an array containing all of the elements in this queue.
417 * maintained by this queue. (In other words, this method must allocate
423 * @return an array containing all of the elements in this queue
426 return Arrays.copyOf(queue, size);
430 * Returns an array containing all of the elements in this queue; the
433 * If the queue fits in the specified array, it is returned therein.
435 * specified array and the size of this queue.
437 * <p>If the queue fits in the specified array with room to spare
438 * (i.e., the array has more elements than the queue), the element in
447 * <p>Suppose {@code x} is a queue known to contain only strings.
448 * The following code can be used to dump the queue into a newly
456 * @param a the array into which the elements of the queue are to
459 * @return an array containing all of the elements in this queue
462 * this queue
470 return (T[]) Arrays.copyOf(queue, size, a.getClass());
471 System.arraycopy(queue, 0, a, 0, size);
478 * Returns an iterator over the elements in this queue. The iterator
481 * @return an iterator over the elements in this queue
489 * Index (into queue array) of element to be returned by
502 * A queue of elements that were moved from the unvisited portion of
537 return (E) queue[lastRet = cursor++];
575 * Removes all of the elements from this priority queue.
576 * The queue will be empty after this call returns.
581 queue[i] = null;
591 E result = (E) queue[0];
592 E x = (E) queue[s];
593 queue[s] = null;
600 * Removes the ith element from queue.
617 queue[i] = null;
619 E moved = (E) queue[s];
620 queue[s] = null;
622 if (queue[i] == moved) {
624 if (queue[i] != moved)
655 Object e = queue[parent];
658 queue[k] = e;
661 queue[k] = key;
668 Object e = queue[parent];
671 queue[k] = e;
674 queue[k] = x;
698 Object c = queue[child];
701 ((Comparable<? super E>) c).compareTo((E) queue[right]) > 0)
702 c = queue[child = right];
705 queue[k] = c;
708 queue[k] = key;
716 Object c = queue[child];
719 comparator.compare((E) c, (E) queue[right]) > 0)
720 c = queue[child = right];
723 queue[k] = c;
726 queue[k] = x;
736 siftDown(i, (E) queue[i]);
741 * queue, or {@code null} if this queue is sorted according to
744 * @return the comparator used to order this queue, or
745 * {@code null} if this queue is sorted according to the
753 * Saves this queue to a stream (that is, serializes it).
771 s.writeObject(queue[i]);
791 queue = new Object[size];
795 queue[i] = s.readObject();
805 * queue.
812 * @return a {@code Spliterator} over the elements in this queue
860 if ((q = pq) != null && (a = q.queue) != null) {
890 @SuppressWarnings("unchecked") E e = (E)pq.queue[lo];