introduce bitloops

This commit is contained in:
mike
2026-01-21 07:03:41 +01:00
parent 1e13d39153
commit a659bd5162
4 changed files with 25 additions and 39 deletions

View File

@@ -12,12 +12,14 @@ import puzzle.SwedishGenerator.FillResult;
import puzzle.SwedishGenerator.Grid;
import puzzle.SwedishGenerator.Slotinfo;
import static precomp.Const9x8.INIT_GRID_OUTPUT;
import static precomp.Const9x8.INIT_GRID_OUTPUT_ARR;
import static puzzle.Export.Clue.DOWN0;
import static puzzle.Export.Clue.RIGHT1;
import static puzzle.Masker.Clues.createEmpty;
import static puzzle.Masker.Slot;
import static puzzle.Masker.C;
import static puzzle.SwedishGenerator.Lemma;
import static puzzle.SwedishGenerator.SIZE;
import static puzzle.SwedishGenerator.X;
/**
@@ -118,28 +120,28 @@ public record Export() {
return stream.build();
}
String gridToString() {
var sb = new StringBuilder(INIT_GRID_OUTPUT);
var sb = INIT_GRID_OUTPUT_ARR.clone();
cl.forEachSlot((s, _, _) -> {
val idx = Slot.clueIndex(s);
val r = idx & 7;
val c = idx >>> 3;
val dir = Slot.dir(s);
sb.setCharAt(r * (C + 1) + c, (char) (dir | 48));
sb[r * (C + 1) + c] = (byte) (dir | 48);
});
stream().forEach((l) -> sb.setCharAt(l.index(C + 1), l.human()));
return sb.toString();
stream().forEach((l) -> sb[l.index(C + 1)] = (byte) l.human());
return new String(sb);
}
public String[] exportGrid(Replacar clueChar, char emptyFallback) {
var sb = new StringBuilder(INIT_GRID_OUTPUT);
var sb = INIT_GRID_OUTPUT_ARR.clone();
cl.forEachSlot((s, l, a) -> {
val idx = Slot.clueIndex(s);
val r = idx & 7;
val c = idx >>> 3;
val dir = Slot.dir(s);
sb.setCharAt(r * (C + 1) + c, clueChar.replace(new Rell(grid, cl, idx, (byte) (dir | 48))));
sb[r * (C + 1) + c] = (byte) clueChar.replace(new Rell(grid, cl, idx, (byte) (dir | 48)));
});
stream().forEach((l) -> sb.setCharAt(l.index(C + 1), l.human()));
return sb.toString().replaceAll(" ", "" + emptyFallback).split("\n");
stream().forEach((l) -> sb[l.index(C + 1)] = (byte) l.human());
return new String(sb).replaceAll(" ", "" + emptyFallback).split("\n");
}
public static IntStream cellWalk(byte base, long lo, long hi) {
if (Slotinfo.increasing(base)) {