Skip to content

Commit

Permalink
Solver implements default config method
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jan 7, 2024
1 parent 7a5c2c9 commit 552f8b7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/de/nqueensfaf/Solver.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public abstract class Solver {
private Consumer<Solver> initCb, finishCb;
private int solutionsSmallN = 0;
private boolean isSaving = false;
private Config config = new Config();
private final Thread shutdownHook = new Thread(() -> {
try {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
Expand All @@ -36,8 +37,6 @@ public abstract class Solver {
public abstract float getProgress();
public abstract long getSolutions();

public abstract <T extends Config> T config();

protected abstract void run();
protected abstract void save_(String filepath) throws IOException;
protected abstract void load_(String filepath) throws IOException;
Expand Down Expand Up @@ -198,6 +197,11 @@ private void smallBoardNQ(int ld, int rd, int col, int row, int free, int mask)
}
}

@SuppressWarnings("unchecked")
public <T extends Config> T config() {
return (T) config;
}

public final void save(String filepath) throws IOException {
if(isSaving)
return;
Expand Down

0 comments on commit 552f8b7

Please sign in to comment.