当前位置: 首页>>代码示例>>C++>>正文


C++ QSet::empty方法代码示例

本文整理汇总了C++中QSet::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ QSet::empty方法的具体用法?C++ QSet::empty怎么用?C++ QSet::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSet的用法示例。


在下文中一共展示了QSet::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: foreach

 //come throw all rules
 foreach (ComputationalRules rule,rules)
 {
     if(!X1.empty())
     {
         if (Q1 == *findInSubsets(Qm,rule.to).begin())
         {
             X1.insert(rule.from);
         }
         else
         {
             X2.insert(rule.from);
         }
     }
     else //for first create new Q1
     {
         QSet < QSet<QString> > tmp = findInSubsets(Qm,rule.to);
         if(tmp.empty())
         {
             qFatal("Fatal error: in function bool FiniteAutomata::canDivide(FiniteAutomata FA ,QString symbol, QSet<QSet<QString> > Qm, QSet<QString> X, QSet<QString> &X1, QSet<QString> &X2)");
             exit(1);
         }
         Q1 = *findInSubsets(Qm,rule.to).begin();
         X1.insert(rule.from);
     }
 }
开发者ID:,项目名称:,代码行数:26,代码来源:

示例2: threads

/*
  Select all messages from a set of threads (passed as a set of mail.thread_id).
  Return the number of selected messages.
*/
int
mail_listview::select_threads(const QSet<uint>& threads)
{
  if (threads.empty())
    return 0;

  int cnt=0;

  QStandardItem* item = model()->first_top_level_item();
  QItemSelectionModel* sel = this->selectionModel();

  while (item) {
    QVariant v = item->data(mail_item_model::mail_msg_role);
    mail_msg* msg = v.value<mail_msg*>();
    QModelIndex index = item->index();
    if (threads.contains(msg->thread_id())) {
      DBG_PRINTF(4, "selecting index for mail_id=%d", msg->get_id());
      sel->select(index, QItemSelectionModel::Select|QItemSelectionModel::Rows);
      cnt++;
    }
    // next item
    QModelIndex index_below  = indexBelow(index);
    if (index_below.isValid()) {
      item = model()->itemFromIndex(index_below);
    }
    else
      item=NULL;
  }
  return cnt;
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例3: waitForDone

void MThreadPool::waitForDone(void)
{
    QMutexLocker locker(&m_priv->m_lock);
    while (true)
    {
        while (!m_priv->m_delete_threads.empty())
        {
            m_priv->m_delete_threads.back()->wait();
            delete m_priv->m_delete_threads.back();
            m_priv->m_delete_threads.pop_back();
        }

        if (m_priv->m_running && !m_priv->m_run_queues.empty())
        {
            m_priv->m_wait.wait(locker.mutex());
            continue;
        }

        QSet<MPoolThread*> working = m_priv->m_running_threads;
        working = working.subtract(m_priv->m_avail_threads);
        if (working.empty())
            break;
        m_priv->m_wait.wait(locker.mutex());
    }
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例4: initPossibleEdges

bool NodeElement::initPossibleEdges()
{
	if (!mPossibleEdges.isEmpty()) {
		return true;
	}

	const QStringList portTypes = mGraphicalAssistApi.editorManagerInterface().portTypes(id().type());
	for (const QString &elementName : mGraphicalAssistApi.editorManagerInterface().elements(id().editor()
			, id().diagram())) {
		int ne = mGraphicalAssistApi.editorManagerInterface().isNodeOrEdge(id().editor(), elementName);
		if (ne == -1) {
			const QList<StringPossibleEdge> list = mGraphicalAssistApi.editorManagerInterface()
					.possibleEdges(id().editor(), elementName);
			for (const StringPossibleEdge &pEdge : list) {
				if (portTypes.contains(pEdge.first.first)
						|| (portTypes.contains(pEdge.first.second) && !pEdge.second.first))
				{
					PossibleEdgeType edge(pEdge.second.first, Id(id().editor(), id().diagram(), pEdge.second.second));
					const QSet<ElementPair> elementPairs = elementsForPossibleEdge(pEdge);
					if (elementPairs.empty()) {
						continue;
					}

					for (const ElementPair &elementPair : elementPairs) {
						mPossibleEdges.insert(qMakePair(elementPair, edge));
					}

					mPossibleEdgeTypes.insert(edge);
				}
			}
		}
	}

	return !mPossibleEdges.isEmpty();
}
开发者ID:Antropovi,项目名称:qreal,代码行数:35,代码来源:nodeElement.cpp

示例5: changeRoute

void FlyAI::changeRoute()
{
    QSet<MoveDirection> moveDirections;
    m_gameDataProvider->getMovesFromPoint(m_state.m_pos, moveDirections);
    m_choosenMove = MoveDirection::MdUnknown;
    if (moveDirections.empty())
    {
        qDebug() << "No move directions. Dying";
        emit maxFlyingDistanceReached(); // todo: create correct signal
        return;
    }

    int choosenIndex = int(frand() * (double)(moveDirections.count()));
    auto dirIt = moveDirections.begin();
    while(choosenIndex > 0)
    {
        dirIt ++;
        --choosenIndex;
    }
    m_choosenMove = *dirIt;

    m_targetSpot = m_gameDataProvider->getPointByDirection(m_state.m_pos, m_choosenMove);

    std::shared_ptr<QPointF> part = m_gameDataProvider->getFreeLandingPoint(m_targetSpot);
    if (!part)
    {
        qDebug() << "No moves. Dying";
        emit maxFlyingDistanceReached(); // todo: create correct signal
        return;
    }
    m_targetSpotPart = *part;
    emit thinkTimeout(); // todo: create correct signal
}
开发者ID:StanislavKraev,项目名称:fliezzz,代码行数:33,代码来源:flyai.cpp

示例6: diseaseAppearsIn

//dodawanie kostki, ewentualnie wybuch; zwraca liczbę wybuchów
int CDisease::diseaseAppearsIn(CCity * source, int count)
{
    if (cubesInGame.size() + count > maxNumberOfCubes) {
        QMessageBox::critical(nullptr, "Game over!", DiseaseType_SL[color] + " cubes are exhausted");
        return 0;
    }
    QSet<CCity*> processed = { source };
    QSet<CCity*> toProcess;
    int outbreaks = 0;
    if (source->cubesOf(color) + count <= 3) { //nie będzie outbreaka
        for (int i = 0; i < count; ++i)
            addSingleCube(source);
    }
    else {  //outbreak
        for (int i = source->cubesOf(color); i < 3; ++i)
            addSingleCube(source);
        ++outbreaks;
        for (CCity *neighbour : source->neighbours())
            toProcess += neighbour;
        while (!toProcess.empty()) {
            CCity *actual = *toProcess.begin();
            toProcess -= actual;
            processed += actual;
            if (actual->cubesOf(color) == 3) {
                ++outbreaks;
                for (CCity *neighbour : actual->neighbours())
                    if (!processed.contains(neighbour))
                        toProcess += neighbour;
            }
            else
                addSingleCube(actual);
        }
    }
    return outbreaks;
}
开发者ID:kajak4u,项目名称:Pandemic,代码行数:36,代码来源:CDisease.cpp

示例7: CHECK

QList<Task*> DefaultConvertFileTask::onSubTaskFinished(Task *subTask) {
    QList<Task*> result;
    CHECK(!subTask->hasError() && !subTask->isCanceled(), result);
    CHECK(!hasError() && !isCanceled(), result);

    if (saveTask == subTask) {
        return result;
    }
    SAFE_POINT_EXT(loadTask == subTask, setError("Unknown subtask"), result);

    bool mainThread = false;
    Document *srcDoc = loadTask->getDocument(mainThread);
    SAFE_POINT_EXT(NULL != srcDoc, setError("NULL document"), result);

    DocumentFormatRegistry *dfr = AppContext::getDocumentFormatRegistry();
    DocumentFormat *df = dfr->getFormatById(targetFormat);
    SAFE_POINT_EXT(NULL != df, setError("NULL document format"), result);

    QSet<GObjectType> selectedFormatObjectsTypes = df->getSupportedObjectTypes();
    QSet<GObjectType> inputFormatObjectTypes;
    QListIterator<GObject*> objectsIterator(srcDoc->getObjects());
    while (objectsIterator.hasNext()) {
        GObject *obj = objectsIterator.next();
        inputFormatObjectTypes << obj->getGObjectType();
    }
    inputFormatObjectTypes.intersect(selectedFormatObjectsTypes);
    if (inputFormatObjectTypes.empty()) {
        setError(tr("The formats are not compatible: %1 and %2").arg(srcDoc->getDocumentFormatId()).arg(targetFormat));
        return result;
    }

    QString ext = targetFormat;
    if (!df->getSupportedDocumentFileExtensions().isEmpty()) {
        ext = df->getSupportedDocumentFileExtensions().first();
    }

    if (targetUrl.isEmpty()) {
        QString fileName = srcDoc->getName() + "." + ext;
        targetUrl = GUrlUtils::rollFileName(workingDir + fileName, QSet<QString>());
    } else {
        if (QFileInfo(targetFormat).suffix() != ext) {
            targetUrl += "." + ext;
        }
        targetUrl = GUrlUtils::rollFileName(targetUrl, QSet<QString>());
    }

    IOAdapterFactory *iof = AppContext::getIOAdapterRegistry()->getIOAdapterFactoryById(IOAdapterUtils::url2io(srcDoc->getURL()));
    Document *dstDoc = srcDoc->getSimpleCopy(df, iof, srcDoc->getURL());

    saveTask = new SaveDocumentTask(dstDoc, iof, targetUrl);
    result << saveTask;
    return result;
}
开发者ID:ggrekhov,项目名称:ugene,代码行数:53,代码来源:ConvertFileTask.cpp

示例8:

bool Utils::Misc::isPreviewable(const QString &extension)
{
    static QSet<QString> multimedia_extensions;
    if (multimedia_extensions.empty()) {
        multimedia_extensions.insert("3GP");
        multimedia_extensions.insert("AAC");
        multimedia_extensions.insert("AC3");
        multimedia_extensions.insert("AIF");
        multimedia_extensions.insert("AIFC");
        multimedia_extensions.insert("AIFF");
        multimedia_extensions.insert("ASF");
        multimedia_extensions.insert("AU");
        multimedia_extensions.insert("AVI");
        multimedia_extensions.insert("FLAC");
        multimedia_extensions.insert("FLV");
        multimedia_extensions.insert("M3U");
        multimedia_extensions.insert("M4A");
        multimedia_extensions.insert("M4P");
        multimedia_extensions.insert("M4V");
        multimedia_extensions.insert("MID");
        multimedia_extensions.insert("MKV");
        multimedia_extensions.insert("MOV");
        multimedia_extensions.insert("MP2");
        multimedia_extensions.insert("MP3");
        multimedia_extensions.insert("MP4");
        multimedia_extensions.insert("MPC");
        multimedia_extensions.insert("MPE");
        multimedia_extensions.insert("MPEG");
        multimedia_extensions.insert("MPG");
        multimedia_extensions.insert("MPP");
        multimedia_extensions.insert("OGG");
        multimedia_extensions.insert("OGM");
        multimedia_extensions.insert("OGV");
        multimedia_extensions.insert("QT");
        multimedia_extensions.insert("RA");
        multimedia_extensions.insert("RAM");
        multimedia_extensions.insert("RM");
        multimedia_extensions.insert("RMV");
        multimedia_extensions.insert("RMVB");
        multimedia_extensions.insert("SWA");
        multimedia_extensions.insert("SWF");
        multimedia_extensions.insert("VOB");
        multimedia_extensions.insert("WAV");
        multimedia_extensions.insert("WMA");
        multimedia_extensions.insert("WMV");
    }

    if (extension.isEmpty())
        return false;

    return multimedia_extensions.contains(extension.toUpper());
}
开发者ID:aj-m,项目名称:qBittorrent,代码行数:52,代码来源:misc.cpp

示例9: dispatchEvent

void ctkEventBusImpl::dispatchEvent(const ctkEvent& event, bool isAsync)
{
  QString topic = event.topic();

  QSet<ctkEventHandlerWrapper*> eventHandlers = this->handlers(topic);
  if (eventHandlers.empty()) return;

  QSetIterator<ctkEventHandlerWrapper*> iter(eventHandlers);
  while (iter.hasNext())
  {
    iter.next()->handleEvent(event);
  }
}
开发者ID:trabs,项目名称:CTK,代码行数:13,代码来源:ctkEventBusImpl.cpp

示例10: if

QSet<QString> ctkLDAPExpr::getMatchedObjectClasses() const
{
  QSet<QString> objClasses;
  if (d->m_operator == EQ) 
  {
    if (d->m_attrName.compare(PluginConstants::OBJECTCLASS, Qt::CaseInsensitive) &&
      d->m_attrValue.indexOf(WILDCARD) < 0) 
    {
      objClasses.insert( d->m_attrValue );
    }
  }
  else if (d->m_operator == AND) 
  {
    for (int i = 0; i < d->m_args.size( ); i++) {
      QSet<QString> r = d->m_args[i].getMatchedObjectClasses();
      if ( !r.empty() ) {
        if (objClasses.empty()) {
          objClasses = r;
        } else {
          // if AND op and classes in several operands,
          // then only the intersection is possible.
          objClasses = r;
        }
      }
    }
  } else if (d->m_operator == OR) {
    for (int i = 0; i < d->m_args.length( ); i++) {
      QSet<QString> r = d->m_args[i].getMatchedObjectClasses();
      if ( !r.empty() ) {
        objClasses += r;
      } else {
        objClasses.clear();
        break;
      }
    }
  }
  return objClasses;
}
开发者ID:sixthfore,项目名称:CTK,代码行数:38,代码来源:ctkLDAPExpr.cpp

示例11: pushToRegistryIfNeeded

/*!
    \internal
    This internal function supports the edge case where the \l Registry
    is connected after \l Source objects are added to this \l Node, or
    the connection to the \l Registry is lost. When connected/reconnected, this
    function synchronizes local \l Source objects with the \l Registry.
*/
void QRemoteObjectRegistry::pushToRegistryIfNeeded()
{
    if (!isReplicaValid())
        return;
    const QSet<QString> myLocs = QSet<QString>::fromList(hostedSources.keys());
    if (myLocs.empty())
        return;
    const QSet<QString> registryLocs = QSet<QString>::fromList(sourceLocations().keys());
    foreach (const QString &loc, myLocs & registryLocs) {
        qCWarning(QT_REMOTEOBJECT) << "Node warning: Ignoring Source" << loc << "as another source ("
                                   << sourceLocations()[loc] << ") has already registered that name.";
        hostedSources.remove(loc);
        return;
    }
开发者ID:LangeSebastian,项目名称:playground-qtremoteobjects,代码行数:21,代码来源:qremoteobjectregistry.cpp

示例12: sourceLayer

void QgsComposerAttributeTableV2::setDisplayAttributes( const QSet<int>& attr, bool refresh )
{
  QgsVectorLayer* source = sourceLayer();
  if ( !source )
  {
    return;
  }

  //rebuild columns list, taking only attributes with index in supplied QSet
  qDeleteAll( mColumns );
  mColumns.clear();

  const QgsFields& fields = source->pendingFields();

  if ( !attr.empty() )
  {
    QSet<int>::const_iterator attIt = attr.constBegin();
    for ( ; attIt != attr.constEnd(); ++attIt )
    {
      int attrIdx = ( *attIt );
      if ( !fields.exists( attrIdx ) )
      {
        continue;
      }
      QString currentAlias = source->attributeDisplayName( attrIdx );
      QgsComposerTableColumn* col = new QgsComposerTableColumn;
      col->setAttribute( fields[attrIdx].name() );
      col->setHeading( currentAlias );
      mColumns.append( col );
    }
  }
  else
  {
    //resetting, so add all attributes to columns
    for ( int idx = 0; idx < fields.count(); ++idx )
    {
      QString currentAlias = source->attributeDisplayName( idx );
      QgsComposerTableColumn* col = new QgsComposerTableColumn;
      col->setAttribute( fields[idx].name() );
      col->setHeading( currentAlias );
      mColumns.append( col );
    }
  }

  if ( refresh )
  {
    refreshAttributes();
  }
}
开发者ID:AaronGaim,项目名称:QGIS,代码行数:49,代码来源:qgscomposerattributetablev2.cpp

示例13:

QHash<Cell*, QSet<char> > Grid::fixArcConsistency(Cell* dirtyCell)
{
	QHash<Cell*, QSet<char> > changes;
	QQueue<Cell*> dirtyCells;

	// initialize the set of cells to check
	// if no dirty cell specified, assume all are dirty
	if( dirtyCell != nullptr ){
		auto depCells = dirtyCell->dependentCells();
		for( auto dep=depCells.constBegin(); dep!=depCells.constEnd(); ++dep )
		{
			dirtyCells.enqueue(*dep);
		}
	}
	else {
		for( int i=0; i<cells.count(); i++ ){
			dirtyCells.enqueue( cells.at(i) );
		}
	}

	// loop until there are no more dirty cells
	while( !dirtyCells.empty() )
	{
		// update domain of dirty cell
		Cell* cell = dirtyCells.dequeue();
		QSet<char> cellChanges = cell->restrictDomain();

		// if the domain changes
		if( !cellChanges.empty() )
		{
			// add changes to the running diff
			changes[cell] += cellChanges;

			// add dependents to queue
			auto depCells = cell->dependentCells();
			for( auto dep=depCells.constBegin(); dep!=depCells.constEnd(); ++dep )
			{
				dirtyCells.enqueue(*dep);
			}
		}
		// else nothing to be done
	}
	return changes;
}
开发者ID:stevenvergenz,项目名称:c-voku,代码行数:44,代码来源:grid_csp.cpp

示例14: size

void tst_QSet::size()
{
    QSet<int> set;
    QVERIFY(set.size() == 0);
    QVERIFY(set.isEmpty());
    QVERIFY(set.count() == set.size());
    QVERIFY(set.isEmpty() == set.empty());

    set.insert(1);
    QVERIFY(set.size() == 1);
    QVERIFY(!set.isEmpty());
    QVERIFY(set.count() == set.size());
    QVERIFY(set.isEmpty() == set.empty());

    set.insert(1);
    QVERIFY(set.size() == 1);
    QVERIFY(!set.isEmpty());
    QVERIFY(set.count() == set.size());
    QVERIFY(set.isEmpty() == set.empty());

    set.insert(2);
    QVERIFY(set.size() == 2);
    QVERIFY(!set.isEmpty());
    QVERIFY(set.count() == set.size());
    QVERIFY(set.isEmpty() == set.empty());

    set.remove(1);
    QVERIFY(set.size() == 1);
    QVERIFY(!set.isEmpty());
    QVERIFY(set.count() == set.size());
    QVERIFY(set.isEmpty() == set.empty());

    set.remove(1);
    QVERIFY(set.size() == 1);
    QVERIFY(!set.isEmpty());
    QVERIFY(set.count() == set.size());
    QVERIFY(set.isEmpty() == set.empty());

    set.remove(2);
    QVERIFY(set.size() == 0);
    QVERIFY(set.isEmpty());
    QVERIFY(set.count() == set.size());
    QVERIFY(set.isEmpty() == set.empty());
}
开发者ID:,项目名称:,代码行数:44,代码来源:

示例15: diseaseAppearsIn

//dodawanie kostki, ewentualnie wybuch; zwraca liczbê wybuchów
void Disease::diseaseAppearsIn(City *source, int count)
{
	if (markersLeft - count < 0)
	{
		Board::WinOrLoose(LOST_CUBES);
	}
	
	QSet<City*> processed = { source };
	QSet<City*> toProcess;
	if (source->DiseaseCounter(diseaseID) + count <= 3)
	{ //nie bêdzie outbreaka
		for (int i = 0; i < count; ++i)
		{
			addSingleCube(source);
		}
	}
	else
	{  //outbreak
		for (int i = source->DiseaseCounter(diseaseID); i<3; ++i)
			addSingleCube(source);
		Board::Outbreak();
		for (City *neighbour : source->Neighbours())
			toProcess += neighbour;
		while (!toProcess.empty())
		{
			City *actual = *toProcess.begin();
			toProcess -= actual;
			processed += actual;
			if (actual->DiseaseCounter(diseaseID) == 3)
			{
				Board::Outbreak(); //mozna zlapac tutaj i dodac info, ktore poleca wyzej
				for (City *neighbour : actual->Neighbours())
					if (!processed.contains(neighbour))
						toProcess += neighbour;
			}
			else
				addSingleCube(actual);
		}
	}
	return;
}
开发者ID:kajak4u,项目名称:Pandemic,代码行数:42,代码来源:Disease.cpp


注:本文中的QSet::empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。