E - is the type of the elements (decisions) to rank.public class RankMap<E> extends Object
Map that maps elements (<E>) to an int value that represents the
rank of the according element. gain or
loss of a specific element (representing a decision). Additionally an element can be declared unacceptable so it is out of the decision.| Modifier and Type | Class and Description |
|---|---|
private static class |
RankMap.Ranking
This inner class represents the
RankMap.Ranking.rank of an element. |
| Modifier and Type | Field and Description |
|---|---|
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 and Description |
|---|
RankMap()
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
addRank(E element,
int gain)
|
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()
|
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)
|
void |
setUnacceptable(E element)
This method ranks the given
element as unacceptable. |
public static final int RANK_UNACCEPTABLE
addRank(Object, int) will have no effect.setUnacceptable(Object),
Constant Field Valuesprivate final Map<E,RankMap.Ranking> map
private final Collection<E> elements
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 - 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).Copyright © 2001–2016 mmm-Team. All rights reserved.