001package algs13.xbacktrack.xframework; 002 003/** 004 * A interface defining a backtracking problem to be solved with the backtracking 005 * framework. 006 * 007 * @param <T> The type of the choices made in the backtracking problem. 008 */ 009public interface XBacktrackProblem<T> { 010 /** 011 * Initialize the problem. The initialize method must call the track method on the 012 * driver to track the starting state. 013 * 014 * @param driver The driver orchestrating the search for the solution. 015 */ 016 void initialize(MyBacktrackDriver<T> driver); 017 018 /** 019 * Determine if the backtracking driver can advance in searching for a solution 020 * from the state represented by previous choice. If it can, this method must 021 * either call the track method on the driver to track the next choice, or 022 * it must call the driver's setDone() method. 023 * 024 * @param state The previous choice 025 * @return true if the current state consists of a valid partial solution, 026 * or the current state represents a complete solution (i.e. the 027 * last choice required to solve the problem has been made). 028 */ 029 boolean advance(T state); 030}