diff --git a/core/src/processing/data/FloatDict.java b/core/src/processing/data/FloatDict.java index 71ea99ffd..cccfc17da 100644 --- a/core/src/processing/data/FloatDict.java +++ b/core/src/processing/data/FloatDict.java @@ -668,7 +668,22 @@ public class FloatDict { Sort s = new Sort() { @Override public int size() { - return count; + if (useKeys) { + return count; // don't worry about NaN values + + } else { // first move NaN values to the end of the list + int right = count - 1; + while (values[right] != values[right]) { + right--; + } + for (int i = right; i >= 0; --i) { + if (Float.isNaN(values[i])) { + swap(i, right); + --right; + } + } + return right + 1; + } } @Override diff --git a/core/src/processing/data/FloatList.java b/core/src/processing/data/FloatList.java index 7d2f6a28d..3a00bbe05 100644 --- a/core/src/processing/data/FloatList.java +++ b/core/src/processing/data/FloatList.java @@ -566,7 +566,20 @@ public class FloatList implements Iterable { new Sort() { @Override public int size() { - return count; + // move NaN values to the end of the list and don't sort them + int right = count - 1; + while (data[right] != data[right]) { + right--; + } + for (int i = right; i >= 0; --i) { + float v = data[i]; + if (v != v) { + data[i] = data[right]; + data[right] = v; + --right; + } + } + return right + 1; } @Override diff --git a/core/src/processing/data/Sort.java b/core/src/processing/data/Sort.java index d205edb12..b42e0f141 100644 --- a/core/src/processing/data/Sort.java +++ b/core/src/processing/data/Sort.java @@ -31,8 +31,8 @@ public abstract class Sort implements Runnable { protected int partition(int left, int right) { int pivot = right; do { - while (compare(++left, pivot) < 0) ; - while ((right != 0) && (compare(--right, pivot) > 0)) ; + while (compare(++left, pivot) < 0) { } + while ((right != 0) && (compare(--right, pivot) > 0)) { } swap(left, right); } while (left < right); swap(left, right); diff --git a/core/todo.txt b/core/todo.txt index 0131b6dc4..72637a8b7 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,15 +1,22 @@ 0229 core (3.0a2) -X add copy() method to Table -X return null from getString() on NaN float and double values -X affects how saveTable() works (writes blank entries instead of NaN) -X get(5) with an empty Int/Float/StringList was returning 0 -X https://github.com/processing/processing/pull/2343 X PImage resize() causes images to not draw X https://github.com/processing/processing/issues/2228 X https://github.com/processing/processing/pull/2324 X move to native OS X full screen (gets rid of native code) X https://github.com/processing/processing/issues/2641 +data +X add copy() method to Table +X return null from getString() on NaN float and double values +X affects how saveTable() works (writes blank entries instead of NaN) +X get(5) with an empty Int/Float/StringList was returning 0 +X https://github.com/processing/processing/pull/2343 +o fix for maxValue() and minValue() when all entries are bad +o on FloatDict it was NaN, check across the lists and other dict types +X nothing else to do here +X FloatDict and FloatList should always put NaN values at the end on sort +X same for the other list and dict classes +X (this is part of the point of having these easier versions) pulls X implement A and a (elliptical arcs) @@ -33,11 +40,6 @@ processing.data _ need a better method for "missing" data in Table _ if missing int is zero, can't just remove those values from saving a table _ but for NaN values, it's a necessity -_ fix for maxValue() and minValue() when all entries are bad -_ on FloatDict it was NaN, check across the lists and other dict types -_ StringDict should always put NaN values at the end on sort -_ same for the other list and dict classes -_ (this is part of the point of having these easier versions) _ get() methods in List/Dict shouldn't allow you to get bad values _ but set() methods can automatically resize the arrays _ though that means insert() should allow you to insert past the end @@ -54,6 +56,7 @@ _ match and iterators _ add match version that returns table that's only a pointer to original _ save the constructor for the version that actually copies data _ the table pointer version will be speedy and allow chaining +_ add Double and Long versions of the classes? later diff --git a/todo.txt b/todo.txt index 4e00313c8..ee31ded1c 100644 --- a/todo.txt +++ b/todo.txt @@ -31,6 +31,7 @@ X remove welcome message from the sound library X URL opening problem fixed by use of getCanonicalPath() on Windows X https://github.com/processing/processing/issues/2656 X add a new pref for the 3.0 sketchbook location +_ when renaming a tab, include the previous name to be edited gsoc X clear status messages in the Contribution Manager