getMinMaxVals method
Returns a pair of doubles which are the max and min values contained in array
,
in the following order: min, max
or max, min
depending on whether
min occurs before max in the array, or the other way around.
Implementation
static List<double> getMinMaxVals(Float64List array) {
int max_index = -1;
double max_value = -double.maxFinite;
double curval;
for (int i = 0; i < array.length; i++) {
curval = array[i];
if (curval > max_value) {
max_value = curval;
max_index = i;
}
}
var min_index = -1;
var min_value = double.maxFinite;
for (int i = 0; i < array.length; i++) {
curval = array[i];
if (curval < min_value) {
min_value = curval;
min_index = i;
}
}
if (min_index <= max_index) {
return [min_value, max_value];
} else {
return [max_value, min_value];
}
}