getMaxInRangeStep method
Finds the maximum value of the numbers in array
in the range from
firstIx
, inclusive, to endix
, exclusive. incr
is an index increment.
If, e.g., incr
==1, only every second array element is considered.
array
may contain null values, they are skipped.
Returns the maximum, its index
.
If 2 maxima with the same value exist, the 1st one is returned.
Implementation
static List<dynamic> getMaxInRangeStep(
Float64List array, int startix, int endix, int incr) {
if (endix <= startix) return [array[startix], startix];
double max_value = -double.maxFinite;
int max_index = -1;
if (array != null) {
for (int i = startix; i < endix; i += incr) {
if (array[i] != null && array[i] > max_value) {
max_value = array[i];
max_index = i;
}
}
}
// print("max=$max_value");
return [max_value, max_index];
}