E - type of the elementSerializable, Iterable<E>, Collection<E>, Queue<E>public 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 | 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 | Description |
|---|---|---|
boolean |
add(E e) |
|
Iterator<E> |
iterator() |
|
boolean |
offer(E e) |
|
E |
peek() |
|
E |
poll() |
|
int |
size() |
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringaddAll, clear, element, removecontains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArraypublic 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 Collection<E>iterator in interface Iterable<E>iterator in class AbstractCollection<E>public int size()
size in interface Collection<E>size in class AbstractCollection<E>Copyright © 2012-2017 Oracle. All Rights Reserved.