more bug fixes

This commit is contained in:
Ben Fry
2014-07-25 10:21:08 -04:00
parent f0b0f9abd9
commit a9a4d48ba9
2 changed files with 27 additions and 6 deletions
+22 -6
View File
@@ -411,13 +411,21 @@ public class FloatDict {
public String minKey() {
checkMinMax("minKey");
return keys[minIndex()];
int index = minIndex();
if (index == -1) {
return null;
}
return keys[index];
}
public float minValue() {
checkMinMax("minValue");
return values[minIndex()];
int index = minIndex();
if (index == -1) {
return Float.NaN;
}
return values[index];
}
@@ -452,17 +460,25 @@ public class FloatDict {
}
/** The key for a max value. */
/** The key for a max value, or null if everything is NaN (no max). */
public String maxKey() {
checkMinMax("maxKey");
return keys[maxIndex()];
int index = maxIndex();
if (index == -1) {
return null;
}
return keys[index];
}
/** The max value. */
/** The max value. (Or NaN if they're all NaN.) */
public float maxValue() {
checkMinMax("maxValue");
return values[maxIndex()];
int index = maxIndex();
if (index == -1) {
return Float.NaN;
}
return values[index];
}