introduce bitloops
This commit is contained in:
@@ -259,18 +259,7 @@ public record SwedishGenerator(Rng rng, int[] stack, Clues cache) {
|
||||
for (int i = 0; i < SIZE; i++) if (digitAt(i) == b.digitAt(i)) same++;
|
||||
return same / SIZED;*/
|
||||
}
|
||||
public Grid toGrid() {
|
||||
var grid = new Grid(new byte[SIZE], lo, hi);
|
||||
for (var l = lo; l != X; l &= l - 1) {
|
||||
int idx = Long.numberOfTrailingZeros(l);
|
||||
grid.setLetter(idx, digitAt(idx));
|
||||
}
|
||||
for (var h = hi; h != X; h &= h - 1) {
|
||||
int idx = 64 | Long.numberOfTrailingZeros(h);
|
||||
grid.setLetter(idx, digitAt(idx));
|
||||
}
|
||||
return grid;
|
||||
}
|
||||
public Grid toGrid() { return new Grid(new byte[SIZE], lo, hi); }
|
||||
public void forEachSlot(SlotVisitor visitor) {
|
||||
for (var l = lo; l != X; l &= l - 1) processSlot(this, visitor, Long.numberOfTrailingZeros(l));
|
||||
for (var h = hi; h != X; h &= h - 1) processSlot(this, visitor, 64 | Long.numberOfTrailingZeros(h));
|
||||
|
||||
Reference in New Issue
Block a user