From a9a4d48ba92411dbf445a6a6123682480d97b9e7 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 25 Jul 2014 10:21:08 -0400 Subject: [PATCH] more bug fixes --- core/src/processing/data/FloatDict.java | 28 +++++++++++++++++++------ core/todo.txt | 5 +++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/core/src/processing/data/FloatDict.java b/core/src/processing/data/FloatDict.java index e9b902396..71ea99ffd 100644 --- a/core/src/processing/data/FloatDict.java +++ b/core/src/processing/data/FloatDict.java @@ -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]; } diff --git a/core/todo.txt b/core/todo.txt index 3061686db..8fdf0de6c 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -19,6 +19,11 @@ X drastic performance improvements for addRow() X when using setColumnType(), replace nulls with missingInt, missingFloat, etc X formerly, was throwing a NullPointerException +data types +X if all data is NaN in a FloatDict, return NaN for maxValue() and minValue() +X formerly as AIOOBE -1 because -1 means "not found" +X but that was indexing directly into the data array +_ add this handling for IntDict and others applet removal _ remove Applet as base class