com.github.k0zka.finder4j.backtrack.termination.FirstSolutionTerminationStrategy Maven / Gradle / Ivy
package com.github.k0zka.finder4j.backtrack.termination;
import com.github.k0zka.finder4j.backtrack.SolutionListener;
import com.github.k0zka.finder4j.backtrack.State;
import com.github.k0zka.finder4j.backtrack.Step;
import com.github.k0zka.finder4j.backtrack.TerminationStrategy;
/**
* Terminate the search after the first solution is received.
*
* @param
* @param
*/
public class FirstSolutionTerminationStrategy>
implements TerminationStrategy, SolutionListener {
private X state = null;
public X getSolution() {
return state;
}
public void onSolution(final X state) {
this.state = state;
}
public boolean stop(final X state) {
return this.state != null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy