|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--mark.core.math.Objmax
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 |
public Objmax(int k)
k - the number of pairs to remember.public Objmax()
| Method Detail |
public int size()
public boolean remembered(double num)
num - the number.
public void consider(java.lang.Object obj,
double num)
obj - the Objument.num - the number.public double nummax(int n)
n - zero for largest, one for second largest, etc.
public double nummax()
public java.lang.Object objmax(int n)
n - zero for largest, one for second largest, etc.
public java.lang.Object objmax()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||