getMax method

List getMax (Float64List array)

Finds the maximum value of the numbers in array. 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> getMax(Float64List array) {
  double max_value = -double.maxFinite;
  int max_index = -1;
  if (array != null) {
    for (int i = 0; i < array.length; i += 1) {
      if (array[i] != null && array[i] > max_value) {
        max_value = array[i];
        max_index = i;
      }
    }
  }
  return [max_value, max_index];
}