B
- the upper bound on the eventual type that can be produced by
this builder (for example, a Builder<Number>
can produce a
Queue<Number>
or Queue<Integer>
but not a Queue<Object>
).@Beta public static final class MinMaxPriorityQueue.Builder<B> extends java.lang.Object
MinMaxPriorityQueue.orderedBy(Comparator)
, MinMaxPriorityQueue.expectedSize(int)
or MinMaxPriorityQueue.maximumSize(int)
.Modifier and Type | Field and Description |
---|---|
private java.util.Comparator<B> |
comparator |
private int |
expectedSize |
private int |
maximumSize |
private static int |
UNSET_EXPECTED_SIZE |
Modifier | Constructor and Description |
---|---|
private |
Builder(java.util.Comparator<B> comparator) |
Modifier and Type | Method and Description |
---|---|
<T extends B> |
create()
Builds a new min-max priority queue using the previously specified
options, and having no initial contents.
|
<T extends B> |
create(java.lang.Iterable<? extends T> initialContents)
Builds a new min-max priority queue using the previously specified
options, and having the given initial elements.
|
MinMaxPriorityQueue.Builder<B> |
expectedSize(int expectedSize)
Configures this builder to build min-max priority queues with an initial
expected size of
expectedSize . |
MinMaxPriorityQueue.Builder<B> |
maximumSize(int maximumSize)
Configures this builder to build
MinMaxPriorityQueue instances
that are limited to maximumSize elements. |
private <T extends B> |
ordering() |
private static final int UNSET_EXPECTED_SIZE
private final java.util.Comparator<B> comparator
private int expectedSize
private int maximumSize
private Builder(java.util.Comparator<B> comparator)
public MinMaxPriorityQueue.Builder<B> expectedSize(int expectedSize)
expectedSize
.public MinMaxPriorityQueue.Builder<B> maximumSize(int maximumSize)
MinMaxPriorityQueue
instances
that are limited to maximumSize
elements. Each time a queue grows
beyond this bound, it immediately removes its greatest element (according
to its comparator), which might be the element that was just added.public <T extends B> MinMaxPriorityQueue<T> create()
public <T extends B> MinMaxPriorityQueue<T> create(java.lang.Iterable<? extends T> initialContents)