|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--cosmic.util.Adjudicator
A class for choosing the 'best' among several candidates according to some user-supplied criterion, with ties resolved randomly. Author: James.A.Marshall@imperial.ac.uk
Field Summary | |
static int |
dropAll
Constant to denote dropping all candidates when releasing Adjudicator instance |
static int |
dropLosers
Constant to denote dropping losing candidates when releasing Adjudicator instance |
static int |
dropNone
Constant to denote dropping no candidates when releasing Adjudicator instance |
private double |
mBestDouble
The best double value found so far |
private int |
mBestInt
The best int value found so far |
private java.util.LinkedList |
mCandidates
The list of candidates to be chosen between |
private java.lang.Class |
mClass
The class of candidates to be chosen between |
private boolean |
mLowestWins
The flag that indicates if the winner is the lowest or highest value (true = lowest, false = highest) |
private swarm.objectbase.MessageProbe |
mMessageProbe
The message probe used to determine the winner |
private java.lang.String |
mMessageProbeString
The name of the message probe used to determine the winner |
private static swarm.random.UniformIntegerDist |
msDistribution
Random number generator for all instances of adjudicator |
private static java.util.LinkedList |
msInstances
Instances of the Adjudicator class |
private static java.util.LinkedList |
msUnusedInstances
Unused instances of the Adjudicator class |
private java.util.LinkedList |
mTiedCandidates
The list of candidates that are tied |
private boolean |
mUseable
The flag that indicates if the instantiation is useable |
private java.lang.Object |
mWinner
The winner of the adjudication |
Constructor Summary | |
private |
Adjudicator()
Private constructor for the class Adjudicator |
Method Summary | |
void |
addCandidate(java.lang.Object candidate)
Adds a candidate for selection |
static Adjudicator |
getFreeInstance(java.lang.String messageProbeString,
boolean lowestWins)
Gets an unused instance of the class Adjudicator for adjudication according to the supplied criteria |
ImmutableIterator |
getIteratorOnCandidates()
Gets an iterator over the candidates in the Adjudicator |
java.lang.Object |
getWinner()
Gets the winner of the adjudication (multiple calls will all return the same winner) |
void |
releaseInstance(int dropPolicy)
Releases the Adjudicator instantiation for re-use |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.lang.Class mClass
private swarm.objectbase.MessageProbe mMessageProbe
private java.lang.String mMessageProbeString
private boolean mLowestWins
private int mBestInt
private double mBestDouble
private java.util.LinkedList mCandidates
private java.util.LinkedList mTiedCandidates
private java.lang.Object mWinner
private boolean mUseable
private static java.util.LinkedList msInstances
private static java.util.LinkedList msUnusedInstances
private static swarm.random.UniformIntegerDist msDistribution
public static final int dropNone
public static final int dropLosers
public static final int dropAll
Constructor Detail |
private Adjudicator()
Method Detail |
public void addCandidate(java.lang.Object candidate)
candidate
- (!= null)
java.lang.RuntimeException
- if instance is not useable
java.lang.RuntimeException
- if called after getWinner
java.lang.RuntimeException
- if message probe specified in constructor has unhandled return type (only int and double are valid)
java.lang.RuntimeException
- if candidate does not respond to message specified in constructor
java.lang.RuntimeException
- if called without first calling newAdjudicationpublic ImmutableIterator getIteratorOnCandidates()
java.lang.RuntimeException
- if instance is not useable
java.lang.RuntimeException
- if called before getWinnerpublic java.lang.Object getWinner()
java.lang.RuntimeException
- if instance is not useable
java.lang.RuntimeException
- if called without first calling newAdjudicationpublic void releaseInstance(int dropPolicy)
dropPolicy
- (dropNone || dropLosers || dropAll)
java.lang.RuntimeException
- if instance is not useablepublic static Adjudicator getFreeInstance(java.lang.String messageProbeString, boolean lowestWins)
messageProbeString
- - the name of the function to be used in evaluating the winnerlowestWins
- - true indicates the lowest value wins, false indicates the highest value wins
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |