E
- type of the elementpublic class BoundedPriorityQueue<E> extends AbstractQueue<E> implements Serializable
PriorityQueue
.
Note: elements are returned in reverse order.
For instance, if "top N smallest elements" are required, use new BoundedPriorityQueue(N)
,
and the elements would be returned in largest to smallest order.Constructor and Description |
---|
BoundedPriorityQueue(int maxSize)
Creates a bounded priority queue with the specified maximum size and default ordering.
|
BoundedPriorityQueue(int maxSize,
Comparator<? super E> comparator)
Creates a bounded priority queue with the specified maximum size.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e) |
Iterator<E> |
iterator() |
boolean |
offer(E e) |
E |
peek() |
E |
poll() |
int |
size() |
addAll, clear, element, remove
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
public BoundedPriorityQueue(int maxSize)
maxSize
smallest elements would be kept in the queue.maxSize
- maximum size of the queuepublic BoundedPriorityQueue(int maxSize, Comparator<? super E> comparator)
maxSize
smallest elements would be kept in the queue.maxSize
- maximum size of the queuecomparator
- comparator that orders the elementspublic boolean add(E e)
add
in interface Collection<E>
add
in interface Queue<E>
add
in class AbstractQueue<E>
public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in class AbstractCollection<E>
public int size()
size
in interface Collection<E>
size
in class AbstractCollection<E>
Copyright © 2012–2020 Oracle. All rights reserved.