public final class TopNLong2DoubleAccumulator extends java.lang.Object implements Long2DoubleAccumulator
Accumulate the top N scored IDs. IDs are sorted by their associated scores.
| Constructor and Description |
|---|
TopNLong2DoubleAccumulator(int n)
Create a new accumulator to accumulate the top n IDs.
|
| Modifier and Type | Method and Description |
|---|---|
LongList |
finishList()
Accumulate the scored items into a list.
|
Long2DoubleMap |
finishMap()
Accumulate the scores into a map and reset the accumulator.
|
LongSet |
finishSet()
Accumulate the scored items into a set.
|
boolean |
isEmpty()
Query whether the accumulator is empty.
|
void |
put(long item,
double score)
Put a new item in the accumulator.
|
int |
size()
Get the number of items in the accumulator.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitputAllpublic TopNLong2DoubleAccumulator(int n)
Create a new accumulator to accumulate the top n IDs.
n - The number of IDs to retain.public boolean isEmpty()
Long2DoubleAccumulatorQuery whether the accumulator is empty.
isEmpty in interface Long2DoubleAccumulatortrue if the accumulator has no items.public int size()
Long2DoubleAccumulatorGet the number of items in the accumulator.
size in interface Long2DoubleAccumulatorpublic void put(long item,
double score)
Long2DoubleAccumulatorPut a new item in the accumulator. Putting the same item twice does not replace the previous entry - it adds a new entry with the same ID.
put in interface Long2DoubleAccumulatoritem - The item to add to the accumulator.score - The item’s score.public Long2DoubleMap finishMap()
Long2DoubleAccumulatorAccumulate the scores into a map and reset the accumulator.
After this method is called, the accumulator is ready for another accumulation.
finishMap in interface Long2DoubleAccumulatorpublic LongSet finishSet()
Long2DoubleAccumulatorAccumulate the scored items into a set.
finishSet in interface Long2DoubleAccumulatorpublic LongList finishList()
Long2DoubleAccumulatorAccumulate the scored items into a list.
finishList in interface Long2DoubleAccumulator