lookup static method
Returns cluster * 1000 + codeword for pattern, or -1 when nothing fits.
Implementation
static int lookup(int pattern, {int maxDistance = 2}) {
final int? exact = byPattern[pattern];
if (exact != null) return exact;
if (maxDistance <= 0 || pattern == 0) return -1;
int best = -1;
int bestDistance = maxDistance + 1;
byPattern.forEach((int candidate, int value) {
final int distance = _bitDistance(candidate, pattern);
if (distance < bestDistance) {
bestDistance = distance;
best = value;
}
});
return bestDistance <= maxDistance ? best : -1;
}