public class LimitedSetStatistic<K>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
LimitedSetStatistic.CountComparator<KK> |
private static class |
LimitedSetStatistic.TimeComparator<KK> |
Modifier and Type | Field and Description |
---|---|
private int |
bufferSize |
private int |
limit |
private java.util.Map<K,LimitedSetStatisticEntry<K>> |
map |
Constructor and Description |
---|
LimitedSetStatistic(int aLimit,
Creates a new instance of LimitedSetStatistic.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all elements from this Set.
|
protected LimitedSetStatisticEntry<K> |
createStatisticEntry(K aKey) |
LimitedSetStatisticEntry<K> |
getElement(K aKey)
Returns an element by its key.
|
java.util.List<? extends LimitedSetStatisticEntry<K>> |
getTopElements(int aCount)
Returns top aCount elements sorted desc. by the counter.
|
void |
inc(K aKey)
Increase the counter of an entry by 1.
|
void |
inc(K aKey,
Increases the counter of an entry by an aAmount.
|
void |
inc(K aKey, |
private LimitedSetStatisticEntry<K> |
prepareEntryToInsert(K aKey) |
void |
setCounter(K aKey,
Sets the counter of an entry.
|
private void |
shrinkMapToLimit()
Clears the buffer.
|
aLimit
- a number of objects in Set that is assured not to be removed.aBufferSize
- a number of objects in Set that could be inserted before Set is shrinked to aLimit.aCount
- Number of elements to return. Returns smaller List if there is not enough elements.aKey
- an entry keyaKey
- an entry keyaCounter
- the counter value to be setaKey
- a key of an elementaKey
- an entry keyaAmount
-