Logo Search packages:      
Sourcecode: vdr-plugin-sudoku version File versions  Download package

bool Algorithm::find_valid_sibling (  )  [private]

Find the next valid sibling of the last leaf, return true if a valid sibling was found.

Definition at line 92 of file backtrack.cpp.

References BackTrack::Solution::is_last_at(), BackTrack::Solution::is_valid_at(), and BackTrack::Solution::set_next_at().

Referenced by find_solution().

{
  // If the current node is not valid pass through all siblings until either
  // a valid sibling is found or the last sibling is reached.
  for (;;)
  {
    ++iter;
    if (max_iter != 0 && iter > max_iter)
      return false;
    if (solution.is_valid_at(level))
      return true;
    if (solution.is_last_at(level))
      return false;
    solution.set_next_at(level);
  }
}


Generated by  Doxygen 1.6.0   Back to index