Class Ranker


  • public class Ranker
    extends java.lang.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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.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
      java.lang.Object getBestObject()  
      double getBestScore()
      Obtain the best score which may be the highest score (if maximising), or the lowest score (if minimising)
      java.lang.Object[] getObjects()
      Obtain the objects in this ranker
      boolean isWorthAdding​(double score, boolean maximising)
      Enquire to the merits of adding an object with a particular score
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • Ranker

        public Ranker​(int maximumSize)
    • Method Detail

      • getBestObject

        public final java.lang.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 java.lang.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​(java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object