bool pEditor::search() { SendScintilla( SCI_SETSEARCHFLAGS, mSearchState.flags ); int pos = simpleSearch(); // See if it was found. If not and wraparound is wanted, try again. if ( pos == -1 && mSearchState.wrap ) { if ( mSearchState.forward ) { mSearchState.startpos = 0; mSearchState.endpos = SendScintilla( SCI_GETLENGTH ); } else { mSearchState.startpos = SendScintilla( SCI_GETLENGTH ); mSearchState.endpos = 0; } pos = simpleSearch(); } if ( pos == -1 ) { mSearchState.inProgress = false; return false; } // It was found. long targstart = SendScintilla( SCI_GETTARGETSTART ); long targend = SendScintilla( SCI_GETTARGETEND ); // Ensure the text found is visible if required. if ( mSearchState.show ) { int startLine = SendScintilla( SCI_LINEFROMPOSITION, targstart ); int endLine = SendScintilla( SCI_LINEFROMPOSITION, targend ); for ( int i = startLine; i <= endLine; ++i ) { SendScintilla( SCI_ENSUREVISIBLEENFORCEPOLICY, i ); } } // Now set the selection. SendScintilla( SCI_SETSEL, targstart, targend ); // Finally adjust the start position so that we don't find the same one // again. if ( mSearchState.forward ) { mSearchState.startpos = targend; } else if ( ( mSearchState.startpos = targstart -1 ) < 0 ) { mSearchState.startpos = 0; } mSearchState.inProgress = true; return true; }
int32_t SSearchTest::monkeyTestCase(UCollator *coll, const UnicodeString &testCase, const UnicodeString &pattern, const UnicodeString &altPattern, const char *name, const char *strength, uint32_t seed) { UErrorCode status = U_ZERO_ERROR; int32_t actualStart = -1, actualEnd = -1; //int32_t expectedStart = prefix.length(), expectedEnd = prefix.length() + altPattern.length(); int32_t expectedStart = -1, expectedEnd = -1; int32_t notFoundCount = 0; LocalUStringSearchPointer uss(usearch_openFromCollator(pattern.getBuffer(), pattern.length(), testCase.getBuffer(), testCase.length(), coll, NULL, // the break iterator &status)); // **** TODO: find *all* matches, not just first one **** simpleSearch(coll, testCase, 0, pattern, expectedStart, expectedEnd); usearch_search(uss.getAlias(), 0, &actualStart, &actualEnd, &status); if (expectedStart >= 0 && (actualStart != expectedStart || actualEnd != expectedEnd)) { errln("Search for <pattern> in <%s> failed: expected [%d, %d], got [%d, %d]\n" " strength=%s seed=%d", name, expectedStart, expectedEnd, actualStart, actualEnd, strength, seed); } if (expectedStart == -1 && actualStart == -1) { notFoundCount += 1; } // **** TODO: find *all* matches, not just first one **** simpleSearch(coll, testCase, 0, altPattern, expectedStart, expectedEnd); usearch_setPattern(uss.getAlias(), altPattern.getBuffer(), altPattern.length(), &status); usearch_search(uss.getAlias(), 0, &actualStart, &actualEnd, &status); if (expectedStart >= 0 && (actualStart != expectedStart || actualEnd != expectedEnd)) { errln("Search for <alt_pattern> in <%s> failed: expected [%d, %d], got [%d, %d]\n" " strength=%s seed=%d", name, expectedStart, expectedEnd, actualStart, actualEnd, strength, seed); } if (expectedStart == -1 && actualStart == -1) { notFoundCount += 1; } return notFoundCount; }
void printArtPoints() { //Remove duplicates if any and print //Create a duplicate free array int local_artPoints[artIndex-1]; int local_artsize = 0; int i, j; int artvertex; for(i = 0; i < artIndex-1; i++) { if(!(simpleSearch(artPoints[i], local_artPoints, local_artsize))) { local_artPoints[local_artsize] = artPoints[i]; local_artsize++; } } qsort (local_artPoints, local_artsize, sizeof(int), compare); printf("Articulation points\n"); printf("----------------------------------------------------------\n"); for(i = 0; i < local_artsize; i++) { printf("%d ", local_artPoints[i]); fprintf(Aa, "%d ", local_artPoints[i]); } printf("\n"); fprintf(Aa, "\n"); //printf("----------------------------------------------------------\n"); }
void GameList::ShowContextMenu(const QPoint& pos) { QMenu headerMenu; QAction* filterTag = headerMenu.addAction(tr("Find tag...")); headerMenu.addSeparator(); QAction* hide = headerMenu.addAction(tr("Hide Column")); headerMenu.addSeparator(); QAction* resizeAll = headerMenu.addAction(tr("Resize visible Columns")); QAction* showAll = headerMenu.addAction(tr("Show all Columns")); QAction* selectedItem = headerMenu.exec(mapToGlobal(pos)); int column = columnAt(pos.x()); if (selectedItem == filterTag) { simpleSearch(column); } else if(selectedItem == hide) { if(column > 0) { hideColumn(column); } } else if(selectedItem == showAll) { for(int i = 0; i < model()->columnCount(); ++i) { showColumn(i); } } else if (selectedItem == resizeAll) { resizeColumnsToContents(); } }
void storeBiconnVerts(int left, int right) { int i; int l = 0; int size= right - left; biconnComps[bcI] = (int*)malloc(sizeof(int)*2*size); //Allocating the maximum possible memory for this for(i = left; i < right; i++) { //Check if the node is already present. If not add at the node to the biconn vertices list if(!(simpleSearch(edgeStack[i]->tail, biconnComps[bcI], l))) { biconnComps[bcI][l] = edgeStack[i]->tail; l++; } if(!(simpleSearch(edgeStack[i]->head, biconnComps[bcI], l))) { biconnComps[bcI][l] = edgeStack[i]->head; l++; } } bcLength[bcI] = l; bcI++; }