- private void setNextBacktrackPoint(IntChoiceFromSet icsCG) {
-
- HashSet<IntChoiceFromSet> backtrackCGs = new HashSet<>(cgMap.values());
- if (!isFirstResetDone) {
- // Reset the last CG of every LinkedList in the map and set done everything else
- for (Integer stateId : cgMap.keySet()) {
- setBacktrackCG(stateId);
- }
- isFirstResetDone = true;
- } else {
- // Check if we still have backtrack points for the last state after the last backtrack
- if (backtrackMap.containsKey(lastCGStateId)) {
- setBacktrackCG(lastCGStateId);
- } else {
- // We try to reset new CGs (if we do have) when we are running out of active CGs
- if (!backtrackStateQ.isEmpty()) {
- // Reset the next CG with the latest state
- int hiStateId = backtrackStateQ.peek();
- setBacktrackCG(hiStateId);
- }
- }
- }
- // Clear unused CGs
- for(BacktrackPoint backtrackPoint : backtrackPointList) {
- IntChoiceFromSet cg = backtrackPoint.getBacktrackCG();
- if (!backtrackCGs.contains(cg)) {
- cg.setDone();
- }
- }
- backtrackPointList.clear();
- }
-