public final class BoundedPriorityQueue<T> extends Object
| Constructor and Description |
|---|
BoundedPriorityQueue(int maxSize,
Comparator<? super T> comparator)
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(T t)
Adds an element to the queue.
|
List<T> |
asList() |
List<T> |
asOrderedList() |
static <T> BoundedPriorityQueue<T> |
create(int maxSize,
Comparator<? super T> comparator) |
public BoundedPriorityQueue(int maxSize,
Comparator<? super T> comparator)
maxSize - - The maximum size the queue can reach, must be a positive
integer.comparator - - The comparator to be used to compare the elements in the
queue, must be non-null.public static <T> BoundedPriorityQueue<T> create(int maxSize, Comparator<? super T> comparator)
public void add(T t)
maxSize
elements, e will be compared to the lowest element in the queue
using comparator. If e is greater than or equal to the
lowest element, that element will be removed and e will be added
instead. Otherwise, the queue will not be modified and e will not
be added.t - - Element to be added, must be non-null.public List<T> asList()
Collections.unmodifiableList(java.util.List)
unmodifiableList sorted in reverse order.Copyright © 2013–2023. All rights reserved.