mark.core.math
Class Objmax

java.lang.Object
  |
  +--mark.core.math.Objmax

public class Objmax
extends java.lang.Object

An Objmax accepts (object, number) pairs and remembers the k pairs that have the greatest numbers. Objects are of type Object and numbers are doubles. Sample Usage: Objmax am = new Objmax (); am.consider ("a", 12.0); am.consider ("b", 2.3); am.consider ("c", 3.0); System.out.println ( "The greatest pair is (" + am.objmax () + ", " + am.nummax ());


Constructor Summary
Objmax()
          Initializes the Objmax with k = 1.
Objmax(int k)
          Initializes the Objmax with the given k.
 
Method Summary
 void consider(java.lang.Object obj, double num)
          Causes the Objmax to consider the given pair.
 double nummax()
          Returns the largest number yet seen.
 double nummax(int n)
          Returns the nth largest number yet seen.
 java.lang.Object objmax()
          Returns the object corresponding to the largest number yet seen.
 java.lang.Object objmax(int n)
          Returns the object corresponding to the nth largest number yet seen.
 boolean remembered(double num)
          Returns whether a pair with the given number would be remembered.
 int size()
          Returns the number of pairs the Objmax is remembering.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Objmax

public Objmax(int k)
Initializes the Objmax with the given k.

Parameters:
k - the number of pairs to remember.

Objmax

public Objmax()
Initializes the Objmax with k = 1.

Method Detail

size

public int size()
Returns the number of pairs the Objmax is remembering.

Returns:
the number of pairs the Objmax is remembering.

remembered

public boolean remembered(double num)
Returns whether a pair with the given number would be remembered.

Parameters:
num - the number.
Returns:
whether the pair would be remembered.

consider

public void consider(java.lang.Object obj,
                     double num)
Causes the Objmax to consider the given pair.

Parameters:
obj - the Objument.
num - the number.

nummax

public double nummax(int n)
Returns the nth largest number yet seen.

Parameters:
n - zero for largest, one for second largest, etc.
Returns:
the nth largest number yet seen.

nummax

public double nummax()
Returns the largest number yet seen.

Returns:
the largest number yet seen.

objmax

public java.lang.Object objmax(int n)
Returns the object corresponding to the nth largest number yet seen.

Parameters:
n - zero for largest, one for second largest, etc.
Returns:
the corresponding object.

objmax

public java.lang.Object objmax()
Returns the object corresponding to the largest number yet seen.

Returns:
the corresponding object.