bool ClassBrowser::RecursiveSearch(const wxString& search, wxTreeCtrl* tree, const wxTreeItemId& parent, wxTreeItemId& result) { if (!parent.IsOk() || !tree) return false; // first check the parent item if (FoundMatch(search, tree, parent)) { result = parent; return true; } wxTreeItemIdValue cookie; wxTreeItemId child = tree->GetFirstChild(parent, cookie); if (!child.IsOk()) return RecursiveSearch(search, tree, FindNext(search, tree, parent), result); while (child.IsOk()) { if (FoundMatch(search, tree, child)) { result = child; return true; } if (tree->ItemHasChildren(child)) { if (RecursiveSearch(search, tree, child, result)) return true; } child = tree->GetNextChild(parent, cookie); } return RecursiveSearch(search, tree, FindNext(search, tree, parent), result); }
bool BoardEvaluator::RecursiveSearch( Colour colour, Direction *dir, unsigned int counter, Board &board) { if (board.Space(dir->X(), dir->Y()) == NULL) return false; Colour currentColour = (Colour)board.Space(dir->X(), dir->Y())->GetColour(); if (currentColour != colour) return false; if (counter == 0) return true; dir->Update(); // Check to see if the side of the board isnt reached. if ((dir->X() < 0) || (dir->X() >= WIDTH)) return false; if ((dir->Y() < 0) || (dir->Y() >= HEIGHT)) return false; counter--; return RecursiveSearch(colour, dir, counter, board); }
void RecursiveSearch(int Mastermol, int Currentmol, int ClusterList[]) { TargetBeadParent1 = Currentmol; for (molIndex2=0; molIndex2<MoleculeTotal; molIndex2++) { TargetBeadParent2 = molIndex2; //# get SelectedBeadTarget2 if (sqrt(RadiusSq) <= (R_x)) { success = AddToMaster(ClusterList,TargetBeadParent2,Mastermol); if (success) { molsAdded+=1; RecursiveSearch(Mastermol,TargetBeadParent2,ClusterList); } } } }
bool BoardEvaluator::IsFinished(Board &board, Colour *winningColour) { for (unsigned int i = 0; i < WIDTH; i++) { for (unsigned int j = 0; j < HEIGHT; j++) { Counter *counter = board.Space(i, j); if (counter != NULL) { // creating the dirctions to be searched in. North north(i, j); South south(i, j); East east(i, j); West west(i, j); NorthEast northEast(i, j); NorthWest northWest(i, j); SouthEast southEast(i, j); SouthWest southWest(i, j); bool retVal = false; Colour retCol = NULL_COLOUR; unsigned int conLength = CONNECT_LENGTH; Colour colour = (Colour)counter->GetColour(); if (RecursiveSearch(colour, &north, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &south, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &east, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &west, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &northEast, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &northWest, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &southEast, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &southWest, conLength - 1, board)) { retCol = colour; retVal = true; } if (retVal) { *winningColour = retCol; return true; } } } } return false; }