コード例 #1
0
ファイル: sortedindex.cpp プロジェクト: dataseries/DataSeries
int main(int argc, char *argv[]) {
    SortedIndexModule<int64_t,Int64Field>::Index 
            index("sortedindex.ds", "NFS trace: common", "packet-at");

    // These are in the first extent
    doSearch(index, 1063931188266052000LL);
    doSearch(index, 1063931188271036000LL);
    doSearch(index, 1063931188607278000LL);
    // these are in middle extents
    doSearch(index, 1063931190602259000LL);
    doSearch(index, 1063931191880891000LL);
    doSearch(index, 1063931192724801000LL);
    // these are in the end extent
    doSearch(index, 1063931192803710000LL);
    doSearch(index, 1063931192806206000LL);
    // these don't exist
    doSearch(index, 1063931190284050000LL);
    doSearch(index, 1063931191880891001LL);

    // set up the same searches in a set
    std::vector<int64_t> set_values;
    set_values.resize(10);
    set_values[0] = 1063931188266052000LL;
    set_values[1] = 1063931188271036000LL;
    set_values[2] = 1063931188607278000LL;
    set_values[3] = 1063931190602259000LL;
    set_values[4] = 1063931191880891000LL;
    set_values[5] = 1063931192724801000LL;
    set_values[6] = 1063931192803710000LL;
    set_values[7] = 1063931192806206000LL;
    set_values[8] = 1063931190284050000LL;
    set_values[9] = 1063931191880891001LL;
    doSetSearch(index, set_values);

    // set up range searches
    // These are in the first extent
    doRangeSearch(index, 1063931188266052000LL, 1063931188266052000LL);
    doRangeSearch(index, 1063931188271035999LL, 1063931188271036001LL);
    doRangeSearch(index, 1063931188607278000LL, 1063931188607278001LL);
    // these are in middle extents
    doRangeSearch(index, 1063931190602258999LL, 1063931190602259000LL);
    doRangeSearch(index, 1063931191880891000LL, 1063931191880891000LL);
    doRangeSearch(index, 1063931192724801000LL, 1063931192724801000LL);
    // these are in the end extent
    doRangeSearch(index, 1063931192803710000LL, 1063931192803710000LL);
    doRangeSearch(index, 1063931192806206000LL, 1063931192806206000LL);
    // these don't exist
    doRangeSearch(index, 1063931190284050000LL, 1063931190284050000LL);
    doRangeSearch(index, 1063931191880891001LL, 1063931191880891001LL);

    // using an unsorted index is an error
    AssertBoostFnBefore(AssertBoostThrowExceptionFn);
    try {
        SortedIndexModule<int32_t,Int32Field>::Index uindex("unsortedindex.ds", "NFS trace: common", "source");
    } catch (AssertBoostException &e) {
        std::cout << "Error: " << e.msg.substr(e.msg.find("nfs.set6.20k.ds")) << "\n";
    }

    return 0;
}
コード例 #2
0
void UploadResumeThread::doRun()
{
	assert(m_pUpInfo);

	getWebCore()->resumeUpload(getItemId(), m_szKey.c_str(), *m_pUpInfo);

	const char* localFilePath = getUploadManager()->findUpload(m_szKey.c_str());
	gcString sLocalFP(localFilePath);

	if (localFilePath && validFile(localFilePath))
	{
		onCompleteStrEvent(sLocalFP);
		return;
	}

	//gona try and search for the file in the data/mods/id folder
	const char* appDataPath = getUserCore()->getAppDataPath();
	gcString searchPath("{0}{1}{2}", appDataPath, DIRS_STR, getItemId().getFolderPathExtension());
	gcString sNull("NULL");

	if (doSearch(searchPath.c_str()))
		return;

	if (getUserCore()->isAdmin())
	{
		searchPath = gcString("{0}{1}temp{1}", appDataPath, DIRS_STR);
		
		if (doSearch(searchPath.c_str()))
			return;
	}

	onCompleteStrEvent(sNull);
}
コード例 #3
0
void
searchThread(void *U, void *T, void *Q) {
  searcherState *state = (searcherState *)T;
  encodedQuery  *query = (encodedQuery *)Q;

  //  Finish building the query -- mask out repetitive junk
  //
  double startTime = getTime();

  if (config._maskDB)
    for (uint32 qi=0; qi<query->numberOfMers(); qi++)
      if ((query->getSkip(qi, false) == false) &&
          (config._maskDB->exists(query->getMer(qi, false))))
        query->setSkip(qi, false);

  if (config._onlyDB)
    for (uint32 qi=0; qi<query->numberOfMers(); qi++)
      if ((query->getSkip(qi, false) == false) &&
          (!config._onlyDB->exists(query->getMer(qi, false))))
        query->setSkip(qi, false);

  state->maskTime += getTime() - startTime;


  //  Do searches.
  //
  if (config._doForward)
    doSearch(state, query, false);
  if (config._doReverse)
    doSearch(state, query, true);
}
コード例 #4
0
/* QuickTextureOverlay3d::keyDown
 * Called when a key is pressed
 *******************************************************************/
void QuickTextureOverlay3d::keyDown(string key)
{
	// Up texture
	if ((key == "right" || key == "mwheeldown") && current_index < textures.size() - 1)
	{
		current_index++;
		search = "";
		applyTexture();
	}

	// Down texture
	else if ((key == "left" || key == "mwheelup") && current_index > 0)
	{
		current_index--;
		search = "";
		applyTexture();
	}

	// Character (search)
	else if (key.length() == 1)
	{
		search += key;
		doSearch();
	}
}
コード例 #5
0
void showMenu(){

   printf("     ___   ___      _____ ___ ___ ___       \n");
   printf("     /_\\ \\ / / |    |_   _| _ \\ __| __|  \n");
   printf("    / _ \\ - /| |__    | | |   / _|| _|     \n");
   printf("   /_/ \\_\\_/ |____|   |_| |_|_\\___|___|  \n");
   printf("                     By: Raven G. Duran     \n");
    printf("\n\n");
    printf("(1) Insert a Node\n");
    printf("(2) Delete a Node\n");
    printf("(3) Search a Node\n");
    printf("(4) Print In Order\n");
    printf("(5) Exit\n");

    int choice;
    printf("\n\nChoice: ");
    scanf("%d",&choice);

    switch(choice){
       case 1 : doInsert();   break;
       case 2 : doDelete();   break;
       case 3 : doSearch();   break;
       case 4 : doInOrder();   break;
       default  : exit(0);
    }
}
コード例 #6
0
//-----------<Get number of working thread>--------------
STDMETHODIMP CTextSearch::SetThreadNum(LONG Num)
{
	if (!Allocated)
	{
		Allocated = true;
		for (long i = 0; i < Num; i++)
		{
			
			std::thread childThread([&]()
			{
				doSearch();
			});
			std::lock_guard<std::mutex> l(ioLock);
			std::cout << "\n  Text search thread " << childThread .get_id() <<" was created"<< std::endl;
			if (threadPool.find(childThread.get_id()) == threadPool.end()) {
				threadPool[childThread.get_id()] = Active;
			}
			inputQueue.enQ(FileSearchEnd);
			childThread.detach();
		}
		
	}
	else 
	{
		std::lock_guard<std::mutex> l(ioLock);
		std::cout << "\n  Can't set number of threads again!" << std::endl;
	}
	return S_OK;
}
コード例 #7
0
// Called in the worker thread's context
void FullSearchOperation::start( SearchData& searchData )
{
    // Clear the shared data
    searchData.clear();

    doSearch( searchData, 0 );
}
コード例 #8
0
void TextShow::startSearch(int parag, int index)
{
    QString to_find_string = srchdialog->getText();
    if (doSearch(to_find_string, srchdialog->case_sensitive(), (!srchdialog->get_direction()), &parag, &index)){
        setSelection(parag, index, parag, index + to_find_string.length());
        setCursorPosition(parag, index + to_find_string.length());
        ensureCursorVisible();
        return;
    }
    if (!srchdialog->isVisible()){
        QApplication::beep();
        return;
    }
    QStringList btns;
    btns.append(i18n("&Yes"));
    btns.append(i18n("&No"));

    QObjectList *l = srchdialog->queryList("QPushButton");
    QObjectListIt it( *l );
    if (it.current() == 0){
        delete l;
        QApplication::beep();
        return;
    }
    QPushButton *btnOK = static_cast<QPushButton*>(it.current());
    delete l;
    QRect rc = btnOK->rect();
    rc.moveTopLeft(btnOK->mapToGlobal(rc.topLeft()));
    BalloonMsg *msg = new BalloonMsg(!srchdialog->get_direction() ?
                                     i18n("End of document reached.\nContinue from the beginning?") :
                                     i18n("Beginning of document reached.\nContinue from the end?"),
                                     rc, btns, this);
    connect(msg, SIGNAL(action(int)), this, SLOT(searchAgain(int)));
    msg->show();
}
コード例 #9
0
ファイル: ditch-backup.c プロジェクト: laysent/onlineJudge
int main(int argc, char *argv[]) {

  int start, end, capacity, i, j, result = 0;

  FILE *fin = fopen("ditch.in", "r");
  FILE *fout = fopen("ditch.out", "w");
  assert(fin); assert(fout);

  for(i = 0; i < M; i++) for(j = 0; j < M; j++) map[i][j] = 0;

  fscanf(fin, "%d %d", &edge, &vertex);
  for(i = 0; i < edge; i++) {
    fscanf(fin, "%d %d %d", &start, &end, &capacity);
    if (end == 1) continue;
    map[start][end] += capacity;
  }

  result += doSearch(1, vertex);
  fprintf(fout, "%d\n", result);

  fclose(fin);
  fclose(fout);

  return 0;
}
コード例 #10
0
ファイル: katesearch.cpp プロジェクト: Fat-Zer/tdelibs
void KateSearch::findAgain()
{
  if(  s_pattern.isEmpty() ) {
    find();
    return;
  }

  if ( doSearch(  s_pattern ) ) {
    exposeFound( s.cursor, s.matchedLength );
  } else if( !s.flags.finished ) {
    if( askContinue() ) {
      wrapSearch();
      findAgain();
    } else {
      if (arbitraryHLExample) m_arbitraryHLList->clear();
    }
  } else {
    if (arbitraryHLExample) m_arbitraryHLList->clear();
    if ( s.showNotFound )
      KMessageBox::sorry( view(),
        i18n("Search string '%1' not found!")
             .arg( KStringHandler::csqueeze(  s_pattern ) ),
        i18n("Find"));
  }
}
コード例 #11
0
void QgsAttributeTableDialog::search()
{

  QString fieldName = mColumnBox->currentText();
  const QgsFieldMap& flds = mLayer->pendingFields();
  int fldIndex = mLayer->fieldNameIndex( fieldName );
  QVariant::Type fldType = flds[fldIndex].type();
  bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double );
  QString sensString = "ILIKE";
  if ( cbxCaseSensitive->isChecked() )
  {
    sensString = "LIKE";
  }

  QSettings settings;
  QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString();

  QString str;
  if ( mQuery->displayText() == nullValue )
  {
    str = QString( "%1 IS NULL" ).arg( QgsSearchTreeNode::quotedColumnRef( fieldName ) );
  }
  else
  {
    str = QString( "%1 %2 '%3'" )
          .arg( QgsSearchTreeNode::quotedColumnRef( fieldName ) )
          .arg( numeric ? "=" : sensString )
          .arg( numeric
                ? mQuery->displayText().replace( "'", "''" )
                :
                "%" + mQuery->displayText().replace( "'", "''" ) + "%" ); // escape quotes
  }

  doSearch( str );
}
コード例 #12
0
ファイル: Search.cpp プロジェクト: jskinn/decision-algorithms
/**
 * Recursively search the decision tree over the acting agents.
 *
 * TODO: I want a custom priority queue here, which can be quickly reset and copied
 */
float doSearch(
		WorldStateInterface* progressiveWorldState,
		std::priority_queue<AgentStateInterface*> agentQueue,
		int depth) {

	if (depth <= 0) {
		// TODO: evaluate the state
		return 0;
	}

	WorldStateInterface::SnapshotInterface* snapshot = progressiveWorldState->takeSnapshot();

	AgentStateInterface* actingAgent = agentQueue.top();
	agentQueue.pop();
	std::list<ActionInterface*> actions = actingAgent->getPossibleActions();
	float best = 0, score = 0;

	for (std::list<ActionInterface*>::iterator iter = actions.begin(); iter != actions.end(); ++iter) {
		(*iter)->doAction();
		score = doSearch(progressiveWorldState, agentQueue, depth - 1);
		progressiveWorldState->restoreShapshot(snapshot);

		if (score > best) {
			best = score;
		}
	}

	return best;
}
コード例 #13
0
void QgsAttributeTableDialog::on_mAdvancedSearchButton_clicked()
{
  QgsSearchQueryBuilder dlg( mLayer, this );
  dlg.setSearchString( mQuery->displayText() );

  if ( dlg.exec() == QDialog::Accepted )
    doSearch( dlg.searchString() );
}
コード例 #14
0
ファイル: dirbrowser.cpp プロジェクト: akira215/upplay
void DirBrowser::onSearchTextChanged(const QString& text)
{
    if (!ui->propsCMB->isEnabled()) {
        if (!text.isEmpty()) {
            doSearch(text, false);
        }
    }
}
コード例 #15
0
void KEdit::search_slot()
{

    int line, col;

    if(!srchdialog)
        return;

    QString to_find_string = srchdialog->getText();
    getCursorPosition(&line, &col);

    // srchdialog->get_direction() is true if searching backward

    if(last_search != NONE && srchdialog->get_direction())
    {
        col = col - pattern.length() - 1;
    }

again:
    int result = doSearch(to_find_string, srchdialog->case_sensitive(), false, (!srchdialog->get_direction()), line, col);

    if(!result)
    {
        if(!srchdialog->get_direction())
        { // forward search

            int query = KMessageBox::questionYesNo(srchdialog, i18n("End of document reached.\n"
                                                                    "Continue from the beginning?"),
                                                   i18n("Find"), KStdGuiItem::cont(), i18n("Stop"));
            if(query == KMessageBox::Yes)
            {
                line = 0;
                col = 0;
                goto again;
            }
        }
        else
        { // backward search

            int query = KMessageBox::questionYesNo(srchdialog, i18n("Beginning of document reached.\n"
                                                                    "Continue from the end?"),
                                                   i18n("Find"), KStdGuiItem::cont(), i18n("Stop"));
            if(query == KMessageBox::Yes)
            {
                QString string = textLine(numLines() - 1);
                line = numLines() - 1;
                col = string.length();
                last_search = BACKWARD;
                goto again;
            }
        }
    }
    else
    {
        emit CursorPositionChanged();
    }
}
コード例 #16
0
ファイル: searchtask.cpp プロジェクト: KDE/kdepim-runtime
void SearchTask::onSelectDone(KJob *job)
{
    if (job->error()) {
        searchFinished(QVector<qint64>());
        cancelTask(job->errorText());
        return;
    }

    doSearch(qobject_cast<KIMAP::SelectJob *>(job)->session());
}
コード例 #17
0
ファイル: fuzzySearch.c プロジェクト: DocExplore/DocExplore
DLLEXP
char * fuzzySearch(UDF_INIT *initid, UDF_ARGS *args, char* result,	unsigned long *length, char *is_null, char *error)
{
	double dist = doSearch(
		(char *)(args->args[0]), args->lengths[0],
		(char *)(args->args[1]), args->lengths[1],
		(long)(*args->args[2]), (int *)(initid->ptr));
	sprintf(result, "%.2f", dist);
	*length = strlen(result);
	return result;
}
コード例 #18
0
void ApplicationControl::search(QString request)
{
    switch (state)
    {
    case ApplicationState::NORMAL:
        if (request != "") {
            state = ApplicationState::SEARCH;
            doSearch(request);
        }
        break;
    case ApplicationState::SEARCH:
        if (request == "") {
            state = ApplicationState::NORMAL;
            leaveSearch();
        } else {
            doSearch(request);
        }
        break;
    }
}
コード例 #19
0
void ContactScreen::keyPressEvent(int keyCode) {
	switch(keyCode) {
		case MAK_SOFTRIGHT:
		case MAK_BACK:
			editBoxSearch->setSelected(false);
			editBoxSearch->disableListener();
			previous->show();
			break;
		case MAK_SOFTLEFT:
			doSearch();
			break;
		case MAK_FIRE:
			if (index >= 0) {
				((TradeFriendDetailScreen*)previous)->contactSelected(contacts[contactListBox->getSelectedIndex()]->getNumber());
			}
			break;
		case MAK_UP:
			if (editBoxSearch->isSelected() && contacts.size() > 0) {
				editBoxSearch->setSelected(false);
				listBox->setSelectedIndex(2);
				contactListBox->setSelectedIndex(contactListBox->getChildren().size() - 1);
				index = contactListBox->getSelectedIndex();
			}
			else if (contactListBox->getSelectedIndex() == 0 && contacts.size() > 0) {
				listBox->setSelectedIndex(1);
				contactListBox->getChildren()[contactListBox->getSelectedIndex()]->setSelected(false);
				editBoxSearch->setSelected(true);
				index = -1;
			}
			else if (contacts.size() > 0) {
				contactListBox->selectPreviousItem(true);
				index = contactListBox->getSelectedIndex();
			}
			break;
		case MAK_DOWN:
			if (editBoxSearch->isSelected() && contacts.size() > 0) {
				editBoxSearch->setSelected(false);
				listBox->setSelectedIndex(2);
				contactListBox->setSelectedIndex(0);
				index = contactListBox->getSelectedIndex();
			}
			else if (contactListBox->getSelectedIndex() == (contacts.size() - 1)) {
				listBox->setSelectedIndex(1);
				contactListBox->getChildren()[contactListBox->getSelectedIndex()]->setSelected(false);
				editBoxSearch->setSelected(true);
				index = -1;
			}
			else if (contacts.size() > 0) {
				contactListBox->selectNextItem(true);
				index = contactListBox->getSelectedIndex();
			}
			break;
	}
}
コード例 #20
0
ファイル: searchbox.cpp プロジェクト: Mr-Kumar-Abhishek/qt
//! [1]
SearchBox::SearchBox(QWidget *parent): QLineEdit(parent)
{
    completer = new GSuggestCompletion(this);

    connect(this, SIGNAL(returnPressed()),this, SLOT(doSearch()));

    setWindowTitle("Search with Google");

    adjustSize();
    resize(400, height());
    setFocus();
}
コード例 #21
0
// Called in the worker thread's context
void UpdateSearchOperation::start( SearchData& searchData )
{
    qint64 initial_line = initialPosition_;

    if ( initial_line >= 1 ) {
        // We need to re-search the last line because it might have
        // been updated (if it was not LF-terminated)
        --initial_line;
        // In case the last line matched, we don't want it to match twice.
        searchData.deleteMatch( initial_line );
    }

    doSearch( searchData, initial_line );
}
コード例 #22
0
ファイル: searchtask.cpp プロジェクト: KDE/kdepim-runtime
void SearchTask::doStart(KIMAP::Session *session)
{
    qCDebug(IMAPRESOURCE_LOG) << collection().remoteId();

    const QString mailbox = mailBoxForCollection(collection());
    if (session->selectedMailBox() == mailbox) {
        doSearch(session);
        return;
    }

    KIMAP::SelectJob *select = new KIMAP::SelectJob(session);
    select->setMailBox(mailbox);
    connect(select, &KJob::finished,
            this, &SearchTask::onSelectDone);
    select->start();
}
コード例 #23
0
ファイル: search_state.cpp プロジェクト: hellige/ccs-cpp
const CcsProperty *SearchState::findProperty(const std::string &propertyName)
const {
    const CcsProperty *prop = doSearch(propertyName);
    if (logAccesses) {
        std::ostringstream msg;
        if (prop) {
            msg << "Found property: " << propertyName
                << " = " << prop->strValue() << "\n";
        } else {
            msg << "Property not found: " << propertyName << "\n";
        }
        msg << "    in context: [" << *this << "]";
        log.info(msg.str());
    }
    return prop;
}
コード例 #24
0
ファイル: katesearch.cpp プロジェクト: Fat-Zer/tdelibs
void KateSearch::promptReplace()
{
  if ( doSearch(  s_pattern ) ) {
    exposeFound( s.cursor, s.matchedLength );
    replacePrompt->show();
    replacePrompt->setFocus ();
  } else if( !s.flags.finished && askContinue() ) {
    wrapSearch();
    promptReplace();
  } else {
    if (arbitraryHLExample) m_arbitraryHLList->clear();
    replacePrompt->hide();
    KMessageBox::information( view(),
        i18n("%n replacement made.","%n replacements made.",replaces),
        i18n("Replace") );
  }
}
コード例 #25
0
ファイル: gutenbrowser.cpp プロジェクト: opieproject/opie
void Gutenbrowser::search_slot( ) {
    int line, col;
    if (!searchDlg /*&& !loadCheck */)
        return;

    Lview->getCursorPosition(&line,&col);
    QString to_find_string=searchDlg->get_text();

    if ( last_search != 0 && searchDlg->get_direction() )
        col = col  - pattern.length() - 1 ;

  again:
    int  result = doSearch( to_find_string , TRUE, searchDlg->forward_search(),
                            line, col);
    if(result == 0) {
        if(!searchDlg->get_direction()) {
            // forward search
            int query = QMessageBox::information( searchDlg, "Find",
                                                  "End of document reached.\n"
                                                  "Continue from the "
                                                  "beginning?", "Yes", "No", "",
                                                  0, 1);
            if (query == 0){
								line = 0;
								col = 0;
								goto again;
            }
        } else {
            //backward search
            int query = QMessageBox::information( searchDlg, "Find",
                                                  "End of document reached.\n"
                                                  "Continue from the "
                                                  "beginning?", "Yes", "No", "",
                                                  0, 1);
            if (query == 0){
                QString string = Lview->textLine( Lview->numLines() - 1 );
                line = Lview->numLines() - 1;
                lineCheck = line;
                col  = string.length();
                last_search = -1; //BACKWARD;
                goto again;
            }
        }
    }
}
コード例 #26
0
void SinglePageWidget::init(int flags, const QList<QWidget *> &leftXtra, const QList<QWidget *> &rightXtra)
{
    if (0!=btnFlags) {
        return;
    }
    btnFlags=flags;
    QList<QWidget *> left=leftXtra;
    QList<QWidget *> right=rightXtra;

    if (!right.isEmpty() && (flags&(AppendToPlayQueue|ReplacePlayQueue))) {
        right << new SpacerWidget(this);
    }

    if (flags&ReplacePlayQueue) {
        view->addAction(StdActions::self()->replacePlayQueueAction);
    }

    if (flags&AppendToPlayQueue) {
        ToolButton *addToPlayQueue=new ToolButton(this);
        addToPlayQueue->setDefaultAction(StdActions::self()->appendToPlayQueueAction);
        right.append(addToPlayQueue);
        view->addAction(StdActions::self()->addToPlayQueueMenuAction);
    }

    if (flags&ReplacePlayQueue) {
        ToolButton *replacePlayQueue=new ToolButton(this);
        replacePlayQueue->setDefaultAction(StdActions::self()->replacePlayQueueAction);
        right.append(replacePlayQueue);
    }

    if (flags&Refresh) {
        ToolButton *refreshButton=new ToolButton(this);
        refreshAction=new Action(Icons::self()->reloadIcon, i18n("Refresh"), this);
        refreshButton->setDefaultAction(refreshAction);
        connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh()));
        left.append(refreshButton);
    }

    connect(this, SIGNAL(searchItems()), this, SLOT(doSearch()));

    if (!left.isEmpty()) {
        QHBoxLayout *ll=new QHBoxLayout();
        foreach (QWidget *b, left) {
            ll->addWidget(b);
        }
コード例 #27
0
 int doSearch(int A[], int l, int r, int t) {
     //equals
     if (r < l) {
         return -1;
     }
     //left < right 1 2 3 4 5
     if (A[l] <= A[r]) {
         //smaller than left or greater than right, return -1
         if (t < A[l] || t > A[r]) {
             return -1;
         }
         //in the middle
         else {
             int mid = l + (r - l) / 2;
             if (A[mid] == t) {
                 return mid;
             }
             else if (A[mid] > t) {
                 return doSearch(A, l, mid - 1, t);
             }
             else {
                 return doSearch(A, mid + 1, r, t);
             }
         }
     }
     //left > right 4 5 6 1 2
     else {
         int mid = l + (r - l) / 2;
         if (A[mid] == t) {
             return mid;
         }
         //4,5,6,7,8,1,2,3
         if (A[mid] >= A[l]) {
             if (t > A[mid] || t < A[l]) {
                 return doSearch(A, mid + 1, r, t);
             }
             else {
                 return doSearch(A, l, mid - 1, t);
             }
         }
         //5 0 1 2 3
         else {
             if (t < A[mid] || t >= A[l]) {
                 return doSearch(A, l, mid - 1, t);
             }
             else {
                 return doSearch(A, mid + 1, r, t);
             }
         }
     }
     return -1;
 }
コード例 #28
0
ファイル: searchtext.cpp プロジェクト: grio/leechcraft
SearchText::SearchText (const QString& text, QWidget *parent)
    : QDialog (parent)
    , Text_ (text)
{
    Ui_.setupUi (this);
    Ui_.Label_->setText (tr ("Search %1 with:").arg (text));

    QStringList categories = Core::Instance ().GetProxy ()->GetSearchCategories ();
    Q_FOREACH (QString cat, categories)
        new QTreeWidgetItem (Ui_.Tree_, QStringList (cat));

    on_MarkAll__released ();

    connect (this,
             SIGNAL (accepted ()),
             this,
             SLOT (doSearch ()));
}
コード例 #29
0
IRCViewBox::IRCViewBox(QWidget* parent, Server* newServer)
: QVBox(parent)
{
    m_ircView = new IRCView(this, newServer);
    m_searchBar = new SearchBar(this);
    m_searchBar->hide();
    m_matchedOnce = false;

    connect(m_searchBar, SIGNAL(signalSearchChanged(const QString&)),
        this, SLOT(slotSearchChanged(const QString&)));
    connect(m_searchBar, SIGNAL(signalSearchNext()),
        this, SLOT(slotSearchNext()));
    connect(m_searchBar, SIGNAL(signalSearchPrevious()),
            this, SLOT(slotSearchPrevious()));
    connect(m_ircView, SIGNAL(doSearch()),
        SLOT(slotSearch()));
    connect(m_searchBar, SIGNAL(hidden()), m_ircView, SIGNAL(gotFocus()));
}
コード例 #30
0
ファイル: katesearch.cpp プロジェクト: Fat-Zer/tdelibs
void KateSearch::replaceAll()
{
  doc()->editStart ();

  while( doSearch(  s_pattern ) )
    replaceOne();

  doc()->editEnd ();

  if( !s.flags.finished ) {
    if( askContinue() ) {
      wrapSearch();
      replaceAll();
    }
  } else {
    KMessageBox::information( view(),
        i18n("%n replacement made.","%n replacements made.",replaces),
        i18n("Replace") );
  }
}