introduce bitloops
This commit is contained in:
@@ -285,6 +285,14 @@ public record SwedishGenerator(Rng rng, int[] stack, Clues cache) {
|
||||
static int offset(int r, int c) { return r | (c << 3); }
|
||||
/// the pos will never target a clue
|
||||
public byte letter32At(int pos) { return g[pos]; }
|
||||
public boolean lisLetterAt(int pos) {
|
||||
if ((pos & 64) == 0)
|
||||
return lisLetterAtLo(pos);
|
||||
return lisLetterAtHi(pos);
|
||||
}
|
||||
|
||||
public boolean lisLetterAtLo(int pos) { return (lo & (1L << pos)) != 0; }
|
||||
public boolean lisLetterAtHi(int pos) { return (hi & (1L << (pos & 63))) != 0; }
|
||||
void setLetterLo(int idx, byte ch) {
|
||||
lo |= (1L << idx);
|
||||
|
||||
@@ -313,8 +321,11 @@ public record SwedishGenerator(Rng rng, int[] stack, Clues cache) {
|
||||
hi &= ~(1L << (idx & 63));
|
||||
}
|
||||
void undoPlace(long maskLo, long maskHi) {
|
||||
for (long b = maskLo; b != 0; b &= b - 1) clearletterLo(Long.numberOfTrailingZeros(b));
|
||||
for (long b = maskHi; b != 0; b &= b - 1) clearletterHi(64 | Long.numberOfTrailingZeros(b));
|
||||
lo &= ~maskLo;
|
||||
hi &= ~maskHi;
|
||||
|
||||
/*for (long b = maskLo; b != 0; b &= b - 1) clearletterLo(Long.numberOfTrailingZeros(b));
|
||||
for (long b = maskHi; b != 0; b &= b - 1) clearletterHi(64 | Long.numberOfTrailingZeros(b));*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user