isFinderPattern static method

bool isFinderPattern(
  1. List<int> counters
)

Implementation

static bool isFinderPattern(List<int> counters) {
  final firstTwoSum = counters[0] + counters[1];
  final sum = firstTwoSum + counters[2] + counters[3];
  final ratio = firstTwoSum / sum;
  if (ratio >= _minFinderPatternRatio && ratio <= _maxFinderPatternRatio) {
    // passes ratio test in spec, but see if the counts are unreasonable
    int minCounter = MathUtils.maxValue;
    int maxCounter = MathUtils.minValue;
    for (int counter in counters) {
      if (counter > maxCounter) {
        maxCounter = counter;
      }
      if (counter < minCounter) {
        minCounter = counter;
      }
    }
    return maxCounter < 10 * minCounter;
  }
  return false;
}