|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--mark.core.math.Argmax
An Argmax accepts (argument, number) pairs and remembers the k pairs that have the greatest numbers. Arguments are integers, and numbers are doubles. Sample Usage: Argmax am = new Argmax (); am.consider (0, 12.0); am.consider (1, 2.3); am.consider (2, 3.0); System.out.println ( "The greatest pair is (" + am.argmax () + ", " + am.nummax ());
| Constructor Summary | |
Argmax()
Initializes the Argmax with k = 1. |
|
Argmax(double[] nums)
Initializes the Argmax with k = 1 and causes it to consider a number of pairs. |
|
Argmax(int k)
Initializes the Argmax with the given k. |
|
Argmax(int k,
double[] nums)
Initializes the Argmax with the given k and causes it to consider a number of pairs. |
|
| Method Summary | |
int |
argmax()
Returns the argument corresponding to the largest number yet seen (starting at zero). |
int |
argmax(int n)
Returns the argument corresponding to the nth largest number yet seen. |
void |
consider(double[] nums)
Causes the Argmax to consider a number of pairs. |
void |
consider(int arg,
double num)
Causes the Argmax to consider the given pair. |
double |
nummax()
Returns the largest number yet seen. |
double |
nummax(int n)
Returns the nth largest number yet seen. |
int |
size()
Returns the number of pairs the Argmax is remembering. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Argmax(int k)
k - the number of pairs to remember.
public Argmax(int k,
double[] nums)
nums - an arrray of doubles that contains the pairs to
consider. Arguments are the indices of the array.
Numbers are the values of the array.public Argmax()
public Argmax(double[] nums)
nums - an arrray of doubles that contains the pairs to
consider. Arguments are the indices of the array.
Numbers are the values of the array.| Method Detail |
public int size()
public void consider(int arg,
double num)
arg - the argument.num - the number.public void consider(double[] nums)
nums - an arrray of doubles that contains the pairs to
consider. Arguments are the indices of the array.
Numbers are the values of the array.public double nummax(int n)
n - zero for largest, one for second largest, etc.
public double nummax()
public int argmax(int n)
n - zero for largest, one for second largest, etc.
public int argmax()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||