introduce bitloops

This commit is contained in:
mike
2026-01-12 09:23:38 +01:00
parent fdd1c76bae
commit 84e832df40
7 changed files with 96 additions and 80 deletions

View File

@@ -1,5 +1,7 @@
package puzzle;
import lombok.Getter;
import lombok.experimental.Accessors;
import lombok.experimental.Delegate;
import puzzle.SwedishGenerator.Dict;
import puzzle.SwedishGenerator.FillResult;
@@ -96,7 +98,7 @@ public record Export() {
}
}
public record ExportedPuzzle(String[] gridv2, WordOut[] words, int difficulty, Rewards rewards) { }
public record ExportedPuzzle(String[] grid, WordOut[] words, int difficulty, Rewards rewards) { }
public record PuzzleResult(SwedishGenerator swe, Dict dict, Gridded mask, FillResult filled) {
@@ -215,24 +217,23 @@ public record Export() {
}
}
record DictEntryDTO(ArrayList<Lemma> words, IntListDTO[][] pos) {
record DictEntryDTO(LongArrayList words, IntListDTO[][] pos) {
public DictEntryDTO(int L) {
this(new ArrayList<>(), new IntListDTO[L][26]);
this(new LongArrayList(1024), new IntListDTO[L][26]);
for (var i = 0; i < L; i++) for (var j = 0; j < 26; j++) pos[i][j] = new IntListDTO();
}
}
@Getter
@Accessors(fluent = true)
static final class IntListDTO {
int[] a = new int[8];
int n = 0;
int[] data = new int[8];
int size = 0;
void add(int v) {
if (n >= a.length) a = Arrays.copyOf(a, a.length * 2);
a[n++] = v;
if (size >= data.length) data = Arrays.copyOf(data, data.length * 2);
data[size++] = v;
}
int size() { return n; }
int[] data() { return a; }
}
}