public abstract class SortedListAccumulator<T>
extends java.lang.Object
Accumulators for sorted lists of things.
Modifier and Type | Method and Description |
---|---|
abstract void |
add(T x)
Add an item to the accumulator.
|
static <T extends java.lang.Comparable<? super T>> |
decreasing(int n)
Create a new sorted list accumulator.
|
static <T> SortedListAccumulator<T> |
decreasing(int n,
java.util.Comparator<? super T> comp)
Create a new sorted list accumulator that sorts in decreasing order.
|
abstract java.util.List<T> |
finish()
Finish accumulating and return the accumulated items.
|
public static <T extends java.lang.Comparable<? super T>> SortedListAccumulator<T> decreasing(int n)
Create a new sorted list accumulator.
n
- The number of results desired; negative for unlimited.public static <T> SortedListAccumulator<T> decreasing(int n, java.util.Comparator<? super T> comp)
Create a new sorted list accumulator that sorts in decreasing order.
n
- The number of results desired; negative for unlimited.comp
- The comparator; items will be picked in decreasing order by this comparator.public abstract void add(@Nonnull T x)
Add an item to the accumulator.
x
- The item to add.public abstract java.util.List<T> finish()
Finish accumulating and return the accumulated items.
When this method is called, the accumulator is reset and can be used to accumulate a fresh set of items.