introduce bitloops

This commit is contained in:
mike
2026-01-14 09:14:03 +01:00
parent bd52bd0ef0
commit afd4a7f53c
4 changed files with 45 additions and 45 deletions

View File

@@ -58,7 +58,6 @@ public record Export() {
record Gridded(@Delegate Grid grid) {
static boolean isLetter(byte b) { return (b & SwedishGenerator.B64) != SwedishGenerator.B0; }
public static IntStream walk(byte base, long lo, long hi) {
if (Slot.increasing(base)) {
return IntStream.concat(
@@ -109,7 +108,7 @@ public record Export() {
}
}
//public boolean isLetterSet(int idx) { return isLetter(g[idx]); }
char NOT_CLUE_NOT_LETTER_TO(byte b, char fallback) { return isLetter(b) ? (char) (64 | b) : fallback; }
char NOT_CLUE_NOT_LETTER_TO(byte b, char fallback) { return b == SwedishGenerator.DASH ? fallback : (char) (64 | b); }
String gridToString(Clues clues) {
var sb = new StringBuilder();
for (var r = 0; r < R; r++) {
@@ -166,10 +165,10 @@ public record Export() {
static final char[] DIRECTION = { Placed.VERTICAL, Placed.HORIZONTAL, Placed.VERTICAL, Placed.HORIZONTAL };
public static final char HORIZONTAL = 'h';
static final char VERTICAL = 'v';
public int arrowCol() { return Grid.c(Slot.clueIndex(slotKey)); }
public int arrowRow() { return Grid.r(Slot.clueIndex(slotKey)); }
public int startRow() { return Grid.r(cells[0]); }
public int startCol() { return Grid.c(cells[0]); }
public int arrowCol() { return SwedishGenerator.IT[Slot.clueIndex(slotKey)].c(); }
public int arrowRow() { return SwedishGenerator.IT[Slot.clueIndex(slotKey)].r(); }
public int startRow() { return SwedishGenerator.IT[cells[0]].r(); }
public int startCol() { return SwedishGenerator.IT[cells[0]].c(); }
public boolean isReversed() { return !Slot.increasing(slotKey); }
public char direction() { return DIRECTION[Slot.dir(slotKey)]; }
}
@@ -214,10 +213,11 @@ public record Export() {
for (var rc : placed) {
for (var c : rc.cells) {
minR = Math.min(minR, Grid.r(c));
minC = Math.min(minC, Grid.c(c));
maxR = Math.max(maxR, Grid.r(c));
maxC = Math.max(maxC, Grid.c(c));
val it = SwedishGenerator.IT[c];
minR = Math.min(minR, it.r());
minC = Math.min(minC, it.c());
maxR = Math.max(maxR, it.r());
maxC = Math.max(maxC, it.c());
}
minR = Math.min(minR, rc.arrowRow());
minC = Math.min(minC, rc.arrowCol());