getMinInRange method

List getMinInRange (Float64List array, int startix, int endix, int incr)

Finds the minimum 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 minimum, its index. If 2 minima with the same value exist, the 1st one is returned.

Implementation

static List<dynamic> getMinInRange(
    Float64List array, int startix, int endix, int incr) {
  if (endix <= startix) return [array[startix], startix];

  double min_value = double.maxFinite;
  int min_index = -1;
  if (array != null) {
    for (int i = startix; i < endix; i += incr) {
      if (array[i] != null && array[i] < min_value) {
        min_value = array[i];
        min_index = i;
      }
    }
  }
//  print("min=$min_value");
  return [min_value, min_index];
}