public final class ClusteredScoreMap<E> extends AbstractScoreMap<E> implements ReversibleScoreMap<E>
Modifier and Type | Class and Description |
---|---|
private class |
ClusteredScoreMap.reverseScoreIterator<A extends E> |
private class |
ClusteredScoreMap.simpleScoreIterator<A extends E> |
Modifier and Type | Field and Description |
---|---|
private int |
encnt |
private long |
gcount |
private java.util.Map<E,java.lang.Long> |
map |
private java.util.TreeMap<java.lang.Long,E> |
pam |
Constructor and Description |
---|
ClusteredScoreMap(boolean sortedKeys)
create a sorted map where there is a choice between a hash map or a tree map for the key store
|
ClusteredScoreMap(java.util.Comparator<E> c) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(E obj) |
void |
dec(E obj) |
void |
dec(E obj,
int incrementScore) |
int |
delete(E obj) |
int |
get(E obj) |
E |
getMaxKey() |
int |
getMaxScore() |
E |
getMinKey() |
int |
getMinScore() |
void |
inc(E obj) |
void |
inc(E obj,
int incrementScore) |
boolean |
isEmpty() |
java.util.Iterator<E> |
iterator() |
java.util.Iterator<E> |
keys(boolean up) |
static void |
main(java.lang.String[] args) |
private long |
scoreKey(int elementNr,
int elementCount) |
void |
set(E obj,
int newScore) |
void |
shrinkToMaxSize(int maxsize)
shrink the cluster to a demanded size
|
void |
shrinkToMinScore(int minScore)
shrink the cluster in such a way that the smallest score is equal or greater than a given minScore
|
int |
size() |
boolean |
sizeSmaller(int size) |
private long |
totalCount() |
inc, keyList, lowerHalf, toString
private final java.util.Map<E,java.lang.Long> map
private final java.util.TreeMap<java.lang.Long,E> pam
private long gcount
private int encnt
public ClusteredScoreMap(boolean sortedKeys)
sortedKeys
- if true, a tree map is used for key storage; in this case the iterator() returns a sorted list of keys; if sortedKey is set to false, a linked hash map is used which preserves the original key appearance orderpublic ClusteredScoreMap(java.util.Comparator<E> c)
public java.util.Iterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
public void shrinkToMaxSize(int maxsize)
shrinkToMaxSize
in interface ScoreMap<E>
maxsize
- public void shrinkToMinScore(int minScore)
shrinkToMinScore
in interface ScoreMap<E>
minScore
- private long scoreKey(int elementNr, int elementCount)
private long totalCount()
public boolean sizeSmaller(int size)
sizeSmaller
in interface ScoreMap<E>
public boolean containsKey(E obj)
containsKey
in interface ScoreMap<E>
public int getMaxScore()
getMaxScore
in interface ReversibleScoreMap<E>
public int getMinScore()
getMinScore
in interface ReversibleScoreMap<E>
public E getMaxKey()
getMaxKey
in interface ReversibleScoreMap<E>
public E getMinKey()
getMinKey
in interface ReversibleScoreMap<E>
public static void main(java.lang.String[] args)