コード例 #1
0
ファイル: main.c プロジェクト: 18616378431/myCode
int main()
{
	HashList hl;
	char choose;

	InitHashList(hl);
	while((choose = Menu()) != 'd')
	{
		switch(choose)
		{
		case 'a'://插入数据
			InsertItem(hl);
			break;
		case 'b'://查询数据
			SearchItem(hl);
			break;
		case 'c'://删除数据
			DeleteItem(hl);
			break;
		default:
			puts("请输入a、b、c来进行选择操作");
			break;
		}
	}
	ClearHashList(hl);
	return 0;
}
コード例 #2
0
ファイル: treecanvas.cpp プロジェクト: akiernan/gecode
  void
  SearcherThread::run() {
    {
      if (!node->isOpen())
        return;
      t->mutex.lock();
      emit statusChanged(false);

      unsigned int kids = 
        node->getNumberOfChildNodes(*t->na, t->curBest, t->stats,
                                    t->c_d, t->a_d);
      if (kids == 0 || node->getStatus() == STOP) {
        t->mutex.unlock();
        updateCanvas();
        emit statusChanged(true);
        return;
      }

      std::stack<SearchItem> stck;
      stck.push(SearchItem(node,kids));
      t->stats.maxDepth =
        std::max(static_cast<long unsigned int>(t->stats.maxDepth), 
                 static_cast<long unsigned int>(depth+stck.size()));

      VisualNode* sol = NULL;
      int nodeCount = 0;
      t->stopSearchFlag = false;
      while (!stck.empty() && !t->stopSearchFlag) {
        if (t->refresh > 0 && nodeCount >= t->refresh) {
          node->dirtyUp(*t->na);
          updateCanvas();
          emit statusChanged(false);
          nodeCount = 0;
          if (t->refreshPause > 0)
            msleep(t->refreshPause);
        }
        SearchItem& si = stck.top();
        si.i++;
        if (si.i == si.noOfChildren) {
          stck.pop();
        } else {
          VisualNode* n = si.n->getChild(*t->na,si.i);
          if (n->isOpen()) {
            if (n->getStatus() == UNDETERMINED)
              nodeCount++;
            kids = n->getNumberOfChildNodes(*t->na, t->curBest, t->stats,
                                            t->c_d, t->a_d);
            if (kids == 0) {
              if (n->getStatus() == SOLVED) {
                assert(n->hasCopy());
                emit solution(n->getWorkingSpace());
                n->purge(*t->na);
                sol = n;
                if (!a)
                  break;
              }
            } else {
              if ( n->getStatus() != STOP )
                stck.push(SearchItem(n,kids));
              else if (!a)
                break;
              t->stats.maxDepth =
                std::max(static_cast<long unsigned int>(t->stats.maxDepth), 
                         static_cast<long unsigned int>(depth+stck.size()));
            }
          }
        }
      }
      node->dirtyUp(*t->na);
      t->stopSearchFlag = false;
      t->mutex.unlock();
      if (sol != NULL) {
        t->setCurrentNode(sol,false);
      } else {
        t->setCurrentNode(node,false);
      }
    }
    updateCanvas();
    emit statusChanged(true);
    if (t->finishedFlag)
      emit searchFinished();
  }