reduceMinMax method

  1. @override
MinMax reduceMinMax(
  1. Int16List samples
)
override

This method reduces samples to the pair of extremes that the samples span.

Implementation

@override
MinMax reduceMinMax(Int16List samples) {
  reductions.add(samples);

  final canned = nextResult;
  if (canned != null) {
    nextResult = null;
    return canned;
  }
  if (samples.isEmpty) return (min: 0, max: 0);

  // Mirrors the C kernel so a host testing against the fake sees the same
  // shape of answer the real core gives.
  var lo = samples.first;
  var hi = samples.first;
  for (final s in samples) {
    if (s < lo) lo = s;
    if (s > hi) hi = s;
  }
  return (min: lo, max: hi);
}