select method

  1. @override
int select(
  1. int set,
  2. List<bool> valid
)
override

Selects a way in set given the current validity of its ways.

Implementation

@override
int select(int set, List<bool> valid) {
  if (set < 0 || set >= _next.length || valid.length != _ways) {
    throw ArgumentError('Replacement geometry does not match the cache.');
  }
  for (var offset = 0; offset < _ways; offset++) {
    final candidate = (_next[set] + offset) % _ways;
    if (!valid[candidate]) {
      return candidate;
    }
  }
  return _next[set];
}