introduce bitloops
This commit is contained in:
@@ -175,7 +175,7 @@ public record SwedishGenerator(Rng rng) {
|
||||
this.hi = hi;
|
||||
}
|
||||
static Grid createEmpty() { return new Grid(new byte[SIZE], X, X); }
|
||||
int digitAt(int index) { return g[index] - 48; }
|
||||
int digitAt(int index) { return g[index] & ~48; }
|
||||
public static int r(int offset) { return offset & 7; }
|
||||
public static int c(int offset) { return offset >>> 3; }
|
||||
static int offset(int r, int c) { return r | (c << 3); }
|
||||
@@ -344,38 +344,7 @@ public record SwedishGenerator(Rng rng) {
|
||||
}
|
||||
}
|
||||
|
||||
static int intersectSorted(int[] a, int aLen, int[] b, int bLen, int[] out) {
|
||||
if (aLen == 0 || bLen == 0) return 0;
|
||||
if (aLen < bLen >>> 4) {
|
||||
int k = 0;
|
||||
for (int i = 0; i < aLen; i++) {
|
||||
int x = a[i];
|
||||
if (Arrays.binarySearch(b, 0, bLen, x) >= 0) out[k++] = x;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
if (bLen < aLen >>> 4) {
|
||||
int k = 0;
|
||||
for (int i = 0; i < bLen; i++) {
|
||||
int y = b[i];
|
||||
if (Arrays.binarySearch(a, 0, aLen, y) >= 0) out[k++] = y;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
int i = 0, j = 0, k = 0, x, y;
|
||||
while (i < aLen && j < bLen) {
|
||||
x = a[i];
|
||||
y = b[j];
|
||||
if (x == y) {
|
||||
out[k++] = x;
|
||||
i++;
|
||||
j++;
|
||||
} else if (x < y) i++;
|
||||
else j++;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
|
||||
static record Slot(int key, long packedPos) {
|
||||
|
||||
static final int BIT_FOR_DIR = 3;
|
||||
@@ -428,7 +397,7 @@ public record SwedishGenerator(Rng rng) {
|
||||
|
||||
for (int i = 0; i < 65; i += 64) {
|
||||
for (long bits = (i == 0 ? lo_cl : hi_cl); bits != X; bits &= bits - 1) {
|
||||
int clueIdx = i + Long.numberOfTrailingZeros(bits);
|
||||
int clueIdx = i | Long.numberOfTrailingZeros(bits);
|
||||
var d = grid.digitAt(clueIdx);
|
||||
var nbrs16 = OFFSETS[d];
|
||||
long packed = nbrs16.path()[clueIdx];
|
||||
@@ -778,7 +747,6 @@ public record SwedishGenerator(Rng rng) {
|
||||
val multiThreaded = Thread.currentThread().getName().contains("pool");
|
||||
val grid = mask.deepCopyGrid();
|
||||
val used = new Bit1029();
|
||||
// val assigned = new HashMap<Integer, Lemma>();
|
||||
|
||||
long[] assigned = new long[BIGG];
|
||||
val ctx = CTX.get();
|
||||
|
||||
Reference in New Issue
Block a user