Package pal.algorithmics
Class Ranker
java.lang.Object
pal.algorithmics.Ranker
Title: Ranker
Description: Maintains a list of ranked objects
- Version:
- 1.0
- Author:
- Matthew Goode
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add in (if it's good enough) a new object based on a score If an object has equality with an object already in the store that object is replaced by the new versionfinal Object
final double
Obtain the best score which may be the highest score (if maximising), or the lowest score (if minimising)final Object[]
Obtain the objects in this rankerfinal boolean
isWorthAdding
(double score, boolean maximising) Enquire to the merits of adding an object with a particular scoretoString()
-
Constructor Details
-
Ranker
public Ranker(int maximumSize)
-
-
Method Details
-
getBestObject
-
getBestScore
public final double getBestScore()Obtain the best score which may be the highest score (if maximising), or the lowest score (if minimising)- Returns:
- the best score
-
isWorthAdding
public final boolean isWorthAdding(double score, boolean maximising) Enquire to the merits of adding an object with a particular score- Parameters:
score
- The score in question- Returns:
- true if an object with such a score is going to make a difference to the current state of this ranker
-
getObjects
Obtain the objects in this ranker- Returns:
- the objects in the order of bestness (such that the first is the best)
-
add
Add in (if it's good enough) a new object based on a score If an object has equality with an object already in the store that object is replaced by the new version- Parameters:
object
- The object to add inscore
- The score of the object
-
toString
-