more NaN check business

This commit is contained in:
Ben Fry
2014-08-02 07:38:34 -04:00
parent 7dadaed210
commit 8405fdcc4f
2 changed files with 7 additions and 0 deletions

View File

@@ -671,6 +671,9 @@ public class FloatDict {
if (useKeys) {
return count; // don't worry about NaN values
} else if (count == 0) { // skip the NaN check, it'll AIOOBE
return 0;
} else { // first move NaN values to the end of the list
int right = count - 1;
while (values[right] != values[right]) {

View File

@@ -566,6 +566,10 @@ public class FloatList implements Iterable<Float> {
new Sort() {
@Override
public int size() {
// if empty, don't even mess with the NaN check, it'll AIOOBE
if (count == 0) {
return 0;
}
// move NaN values to the end of the list and don't sort them
int right = count - 1;
while (data[right] != data[right]) {