This commit is contained in:
@@ -4,12 +4,22 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
//TODO: doc
|
/**
|
||||||
|
* Une pile, qui réprésente les états d'un MultiDoku,
|
||||||
|
* utile pour les Solvers.
|
||||||
|
*/
|
||||||
public class StateManager {
|
public class StateManager {
|
||||||
|
|
||||||
private final Stack<Map<Cell, Integer>> states;
|
/**
|
||||||
|
* Le MultiDoku auquel il est associé.
|
||||||
|
*/
|
||||||
private final MultiDoku doku;
|
private final MultiDoku doku;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* La pile des états du MultiDoku associé.
|
||||||
|
*/
|
||||||
|
private final Stack<Map<Cell, Integer>> states;
|
||||||
|
|
||||||
public StateManager(MultiDoku doku) {
|
public StateManager(MultiDoku doku) {
|
||||||
this.states = new Stack<>();
|
this.states = new Stack<>();
|
||||||
this.doku = doku;
|
this.doku = doku;
|
||||||
@@ -21,12 +31,12 @@ public class StateManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void popState() {
|
public void popState() {
|
||||||
assert (states.size() > 0);
|
assert (!states.isEmpty());
|
||||||
restoreState(states.pop());
|
restoreState(states.pop());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Cell, Integer> popAndGetState() {
|
public Map<Cell, Integer> popAndGetState() {
|
||||||
assert (states.size() > 0);
|
assert (!states.isEmpty());
|
||||||
var currentState = saveState();
|
var currentState = saveState();
|
||||||
restoreState(states.pop());
|
restoreState(states.pop());
|
||||||
return currentState;
|
return currentState;
|
||||||
|
|||||||
Reference in New Issue
Block a user