Class Ranker

java.lang.Object
pal.algorithmics.Ranker

public class Ranker extends Object
Title: Ranker Description: Maintains a list of ranked objects
Version:
1.0
Author:
Matthew Goode
  • Constructor Summary

    Constructors
    Constructor
    Description
    Ranker(int maximumSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Object object, double score, boolean maximising)
    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
    final 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 ranker
    final boolean
    isWorthAdding(double score, boolean maximising)
    Enquire to the merits of adding an object with a particular score
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Ranker

      public Ranker(int maximumSize)
  • Method Details

    • getBestObject

      public final Object 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

      public final Object[] getObjects()
      Obtain the objects in this ranker
      Returns:
      the objects in the order of bestness (such that the first is the best)
    • add

      public void add(Object object, double score, boolean maximising)
      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 in
      score - The score of the object
    • toString

      public String toString()
      Overrides:
      toString in class Object