|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.mmm.util.collection.base.RankMap<E>
E - is the type of the elements (decisions) to rank.public class RankMap<E>
This class is like a Map that maps elements (<E>)
to an int value that represents the rank of the according element.
This is useful for heuristic decisions where specific detections indicate a
gain or loss of a specific element
(representing a decision). Additionally an element can be
declared unacceptable so it is out of the decision.
| Nested Class Summary | |
|---|---|
private static class |
RankMap.Ranking
This inner class represents the RankMap.Ranking.rank of an element. |
| Field Summary | |
|---|---|
private Collection<E> |
elements
|
private Map<E,RankMap.Ranking> |
map
|
static int |
RANK_UNACCEPTABLE
The rank that represents an element that has been disqualified. |
| Constructor Summary | |
|---|---|
RankMap()
The constructor. |
|
| Method Summary | |
|---|---|
int |
addRank(E element,
int gain)
This method adds the given gain to the current
rank of the given element. |
E |
getBest()
This method gets the element that has currently the best (highest) positive rank. |
E |
getBest(int threshold)
This method gets the element that has currently the best (highest) rank greater or equal to the given
threshold. |
List<E> |
getBests()
This method gets a List containing the element(s) that has
currently the best (highest) rank. |
List<E> |
getBetterOrEqual(int threshold)
This method gets all elements with a rank greater
or equal to the given threshold. |
Collection<E> |
getElements()
This method gets all elements in this RankMap that have been
actively ranked (by addRank(Object, int) or
setUnacceptable(Object)). |
int |
getRank(E element)
This method gets the current rank for the given element. |
boolean |
isUnacceptable(E element)
This method determines if the given element has been
declared unacceptable. |
void |
setUnacceptable(E element)
This method ranks the given element as
unacceptable. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int RANK_UNACCEPTABLE
addRank(Object, int) will have no effect.
setUnacceptable(Object),
Constant Field Valuesprivate final Map<E,RankMap.Ranking> map
getRank(Object)private final Collection<E> elements
getElements()| Constructor Detail |
|---|
public RankMap()
| Method Detail |
|---|
public Collection<E> getElements()
RankMap that have been
actively ranked (by addRank(Object, int) or
setUnacceptable(Object)).
Collection with the ranked elements.public int getRank(E element)
element. The
rank is in the range from -1 to
Integer.MAX_VALUE. If the element has no
rank, a value of 0 will be returned.
element - is the element for which the rank is requested.
element.RANK_UNACCEPTABLE,
addRank(Object, int)public void setUnacceptable(E element)
element as
unacceptable. After the call of this method the
rank of the given element is set to
RANK_UNACCEPTABLE and can NOT be changed again.
element - is the unacceptable element.public boolean isUnacceptable(E element)
element has been
declared unacceptable.
element - is the element to check.
true if the given element is
unacceptable, false if the given element is
acceptable.
public int addRank(E element,
int gain)
gain to the current
rank of the given element. If the
element is unacceptable, this
method will have no effect. This method guarantees that there will be no
overflow of the rank.
element - is the element to rank.gain - is the value to add to the current rank. It may be negative to
reduce the rank. A value of 0 will have no effect.
public E getBest()
rank. If there are multiple best elements, it is
unspecified which one is returned.
null if
there is no element with a positive rank.getBests()public E getBest(int threshold)
rank greater or equal to the given
threshold. If there are multiple best elements, it is
unspecified which one is returned.
threshold - is the minimum rank accepted for the best element.
threshold or null if there is no such
element.getBests()public List<E> getBests()
List containing the element(s) that has
currently the best (highest) rank. If there is no
element with a positive rank, an empty List will be returned. If
there are multiple elements with the (same) best rank,
they will all be contained in the returned List.
List with the best element(s).public List<E> getBetterOrEqual(int threshold)
rank greater
or equal to the given threshold.
threshold - is the minimum accepted rank.
threshold.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||