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, removecontains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringpublic 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-2015 Oracle. All Rights Reserved.