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


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

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


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

示例1: intersect_int

void tst_QSet::intersect_int()
{
    QFETCH(int, lhsSize);
    QFETCH(int, rhsSize);
    QFETCH(int, intersectSize);

    // E.g. when lhsSize = 1000, rhsSize = 1000000 and intersectSize = 500:
    // lhsSize = { 0, 1, ... 1000 }
    // rhsSize = { 500, 501, ... 1000500 }

    QSet<int> lhs;
    for (int i = 0; i < lhsSize; ++i)
        lhs.insert(i);

    QSet<int> rhs;
    const int start = lhsSize - intersectSize;
    for (int i = start; i < start + rhsSize; ++i)
        rhs.insert(i);

    QBENCHMARK {
        lhs.intersect(rhs);
    }

    QVERIFY(lhs.size() == intersectSize);
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例2: cloneScreens

void Generator::cloneScreens(KScreen::OutputList &connectedOutputs)
{
    ASSERT_OUTPUTS(connectedOutputs);
    if (connectedOutputs.isEmpty()) {
        return;
    }

    QSet<QSize> commonSizes;
    const QSize maxScreenSize  = m_currentConfig->screen()->maxSize();

    QList<QSet<QSize>> modes;
    Q_FOREACH(const KScreen::OutputPtr &output, connectedOutputs) {
        QSet<QSize> modeSizes;
        Q_FOREACH(const KScreen::ModePtr &mode, output->modes()) {
            const QSize size = mode->size();
            if (size.width() > maxScreenSize.width() || size.height() > maxScreenSize.height()) {
                continue;
            }
            modeSizes.insert(mode->size());
        }

        //If we have nothing to compare against
        if (commonSizes.isEmpty()) {
            commonSizes = modeSizes;
            continue;
        }

        commonSizes.intersect(modeSizes);
    }
开发者ID:davidedmundson,项目名称:test,代码行数:29,代码来源:generator.cpp

示例3: foreach

void FixCadGeometry::fixNonManifold2()
{
  cout << "fixing non-manifold edges\n  (pass 2) ..." << endl;
  QVector<bool> copy_face(m_Grid->GetNumberOfCells(), true);
  for (vtkIdType id_cell = 0; id_cell < m_Grid->GetNumberOfCells(); ++id_cell) {
    vtkIdType N_pts, *pts;
    m_Grid->GetCellPoints(id_cell, N_pts, pts);
    if (N_pts < 3) {
      copy_face[id_cell] = false;
      break;
    }
    QVector<QSet<vtkIdType> > n2c(N_pts);
    for (int i = 0; i < N_pts; ++i) {
      for (int j = 0; j < m_Part.n2cGSize(pts[i]); ++j) {
        n2c[i].insert(m_Part.n2cGG(pts[i], j));
      }
    }
    QSet<vtkIdType> faces = n2c[0];
    for (int i = 1; i < N_pts; ++i) {
      faces = faces.intersect(n2c[i]);
    }
    if (faces.size() > 1) {
      vtkIdType id_del = id_cell;
      foreach (vtkIdType id, faces) {
        id_del = min(id_del, id);
      }
      copy_face[id_del] = false;
    }
开发者ID:ttjj,项目名称:engrid,代码行数:28,代码来源:fixcadgeometry.cpp

示例4: fillNeighborStructures

void MeshGenerator::fillNeighborStructures()
{
    QList<QSet<int> > vertexElements;
    vertexElements.reserve(nodeList.count());
    for (int i = 0; i < nodeList.count(); i++)
        vertexElements.push_back(QSet<int>());

    for (int i = 0; i < elementList.count(); i++)
        if (elementList[i].isUsed)
            for (int elemNode = 0; elemNode < (elementList[i].isTriangle() ? 3 : 4); elemNode++)
                vertexElements[elementList[i].node[elemNode]].insert(i);

    for (int i = 0; i < edgeList.count(); i++)
    {
        if (edgeList[i].isUsed && edgeList[i].marker != -1)
        {
            QSet<int> neighbours = vertexElements[edgeList[i].node[0]];
            neighbours.intersect(vertexElements[edgeList[i].node[1]]);
            assert((neighbours.size() > 0) && (neighbours.size() <= 2));
            edgeList[i].neighElem[0] = neighbours.values()[0];
            if (neighbours.size() == 2)
                edgeList[i].neighElem[1] = neighbours.values()[1];
        }
    }
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例5: query

void WordMatchSearchImpl::query(const QString &req, QVector<Service::Item *> *res) const
{
	QSet<Service::Item*>* resSet = nullptr;
	QStringList words = req.split(' ', QString::SkipEmptyParts);

	// Quit if there are no words in query
	if (words.empty())
		return;

	for (QString &w : words)
	{
		InvertedIndex::const_iterator lb, ub;
		lb =  std::lower_bound (_invertedIndex.cbegin(), _invertedIndex.cend(), w, CaseInsensitiveCompare());
		ub =  std::upper_bound (_invertedIndex.cbegin(), _invertedIndex.cend(), w, CaseInsensitiveComparePrefix());
		QSet<Service::Item*> tmpSet;
		while (lb!=ub)
			tmpSet.unite(lb++->second);
		if (resSet == nullptr)
			resSet = new QSet<Service::Item*>(tmpSet);
		else
			resSet->intersect(tmpSet);
	}
	if (resSet != nullptr) {
		for (Service::Item *s : *resSet)
			res->append(s);
		delete resSet;
	}
}
开发者ID:KPWhiver,项目名称:albert,代码行数:28,代码来源:indexservice.cpp

示例6:

QList<const UserBaseInformations*> FreeUser::Search(QMap<QString,AUser*>::const_iterator begin,QMap<QString,AUser*>::const_iterator end, const UserBaseInformations &inf) const
{
    QSet<const UserBaseInformations*> nameSet;
    QSet<const UserBaseInformations*> emailSet;
    QSet<const UserBaseInformations*> resultSet;
    bool set = false;

    if(inf.GetName() != "")
    {

        for(QMap<QString,AUser*>::const_iterator it = begin;it != end ;it++)
        {
            if((*it)->Profile->GetName() == inf.GetName())
                nameSet.insert((*it)->Profile);
        }

        if(!set)
        {
            set = true;
            resultSet = nameSet;
        }
    }

    if(inf.GetEmail() != "")
    {
        for(QMap<QString,AUser*>::const_iterator it = begin;it != end ;it++)
        {
            if((*it)->Profile->GetEmail() == inf.GetEmail())
                emailSet.insert((*it)->Profile);
        }

        if(!set)
        {
            set = true;
            resultSet = emailSet;
        }
    }

    if(inf.GetName()!="")
        resultSet.intersect(nameSet);
    if(inf.GetEmail()!= "")
        resultSet.intersect(emailSet);

    //rimuovo se presente me stesso
    resultSet.remove(this->Profile);
    return QList<const UserBaseInformations*>::fromSet(resultSet);
}
开发者ID:drigoni,项目名称:LinQedIn,代码行数:47,代码来源:freeuser.cpp

示例7: combineExtentAndCrsOfGroupChildren

void QgsServerProjectParser::combineExtentAndCrsOfGroupChildren( QDomElement& groupElem, QDomDocument& doc, bool considerMapExtent ) const
{
  QgsRectangle combinedBBox;
  QSet<QString> combinedCRSSet;
  bool firstBBox = true;
  bool firstCRSSet = true;

  QDomNodeList layerChildren = groupElem.childNodes();
  for ( int j = 0; j < layerChildren.size(); ++j )
  {
    QDomElement childElem = layerChildren.at( j ).toElement();

    if ( childElem.tagName() != "Layer" )
      continue;

    QgsRectangle bbox = layerBoundingBoxInProjectCrs( childElem, doc );
    if ( !bbox.isEmpty() )
    {
      if ( firstBBox )
      {
        combinedBBox = bbox;
        firstBBox = false;
      }
      else
      {
        combinedBBox.combineExtentWith( bbox );
      }
    }

    //combine crs set
    QSet<QString> crsSet;
    if ( crsSetForLayer( childElem, crsSet ) )
    {
      if ( firstCRSSet )
      {
        combinedCRSSet = crsSet;
        firstCRSSet = false;
      }
      else
      {
        combinedCRSSet.intersect( crsSet );
      }
    }
  }

  QgsConfigParserUtils::appendCrsElementsToLayer( groupElem, doc, combinedCRSSet.toList(), supportedOutputCrsList() );

  QgsCoordinateReferenceSystem groupCRS = projectCrs();
  if ( considerMapExtent )
  {
    QgsRectangle mapRect = mapRectangle();
    if ( !mapRect.isEmpty() )
    {
      combinedBBox = mapRect;
    }
  }
  QgsConfigParserUtils::appendLayerBoundingBoxes( groupElem, doc, combinedBBox, groupCRS, combinedCRSSet.toList(), supportedOutputCrsList() );
}
开发者ID:V17nika,项目名称:QGIS,代码行数:58,代码来源:qgsserverprojectparser.cpp

示例8: runNfa

bool Nfa::runNfa(QString string)
{
  QSet<Node*>* set = new QSet<Node*>();
  set->insert(q0);
  /* Sending -1 to traverse implies sequential execution */
  QSet<Node*>* endingStates = traverse(set, &string, -1);
  endingStates->intersect(*f);
  bool intersects = endingStates->count() > 0;
  delete endingStates; // Remove memory allocated for finalStates.
  
  return intersects;
}
开发者ID:narayana1208,项目名称:nfa_evaluator,代码行数:12,代码来源:nfa.cpp

示例9: 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

示例10: combineExtentAndCrsOfGroupChildren

void QgsProjectParser::combineExtentAndCrsOfGroupChildren( QDomElement& groupElem, QDomDocument& doc ) const
{
  QgsRectangle combinedBBox;
  QSet<QString> combinedCRSSet;
  bool firstBBox = true;
  bool firstCRSSet = true;

  QDomNodeList layerChildren = groupElem.childNodes();
  for ( int j = 0; j < layerChildren.size(); ++j )
  {
    QDomElement childElem = layerChildren.at( j ).toElement();

    if ( childElem.tagName() != "Layer" )
      continue;

    QgsRectangle bbox = layerBoundingBoxInProjectCRS( childElem );
    if ( !bbox.isEmpty() )
    {
      if ( firstBBox )
      {
        combinedBBox = bbox;
        firstBBox = false;
      }
      else
      {
        combinedBBox.combineExtentWith( &bbox );
      }
    }

    //combine crs set
    QSet<QString> crsSet;
    if ( crsSetForLayer( childElem, crsSet ) )
    {
      if ( firstCRSSet )
      {
        combinedCRSSet = crsSet;
        firstCRSSet = false;
      }
      else
      {
        combinedCRSSet.intersect( crsSet );
      }
    }
  }

  appendCRSElementsToLayer( groupElem, doc, combinedCRSSet.toList() );

  const QgsCoordinateReferenceSystem& groupCRS = projectCRS();
  appendLayerBoundingBoxes( groupElem, doc, combinedBBox, groupCRS );
}
开发者ID:CzendaZdenda,项目名称:qgis,代码行数:50,代码来源:qgsprojectparser.cpp

示例11: intersect_complexType

void tst_QSet::intersect_complexType()
{
    QFETCH(int, lhsSize);
    QFETCH(int, rhsSize);
    QFETCH(int, intersectSize);

    QSet<ComplexType> lhs;
    for (int i = 0; i < lhsSize; ++i)
        lhs.insert(ComplexType(i));

    QSet<ComplexType> rhs;
    const int start = lhsSize - intersectSize;
    for (int i = start; i < start + rhsSize; ++i)
        rhs.insert(ComplexType(i));

    QBENCHMARK {
        lhs.intersect(rhs);
    }
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例12: printCalendarList

bool KonsoleKalendar::printCalendarList()
{
    Akonadi::CollectionFetchJob *job = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(),
            Akonadi::CollectionFetchJob::Recursive);
    QStringList mimeTypes = QStringList() << QStringLiteral("text/calendar")
                            << KCalCore::Event::eventMimeType()
                            << KCalCore::Todo::todoMimeType()
                            << KCalCore::Journal::journalMimeType();
    job->fetchScope().setContentMimeTypes(mimeTypes);
    QEventLoop loop;
    QObject::connect(job, &Akonadi::CollectionFetchJob::result, &loop, &QEventLoop::quit);
    job->start();
    loop.exec();

    if (job->error() != 0) {
        return false;
    }

    Akonadi::Collection::List collections = job->collections();

    if (collections.isEmpty()) {
        cout << i18n("There are no calendars available.").toLocal8Bit().data() << endl;
    } else {
        cout << "--------------------------" << endl;
        QSet<QString> mimeTypeSet = mimeTypes.toSet();
        foreach (const Akonadi::Collection &collection, collections) {
            if (!mimeTypeSet.intersect(collection.contentMimeTypes().toSet()).isEmpty()) {
                QString colId = QString::number(collection.id()).leftJustified(6, QLatin1Char(' '));
                colId += QLatin1String("- ");

                bool readOnly = !(collection.rights() & Akonadi::Collection::CanCreateItem ||
                                  collection.rights() & Akonadi::Collection::CanChangeItem ||
                                  collection.rights() & Akonadi::Collection::CanDeleteItem);

                QString readOnlyString = readOnly ? i18n("(Read only)") + QLatin1Char(' ') : QString();

                cout << colId.toLocal8Bit().data() << readOnlyString.toLocal8Bit().constData() << collection.displayName().toLocal8Bit().data() << endl;
            }
        }
    }

    return true;
}
开发者ID:KDE,项目名称:kdepim,代码行数:43,代码来源:konsolekalendar.cpp

示例13: filterAcceptsRow

bool CollectionFilterModel::filterAcceptsRow(int row, const QModelIndex &parent) const
{
    bool accepted = true;

    const QModelIndex index = sourceModel()->index(row, 0, parent);
    const Akonadi::Collection collection = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
    if (!collection.isValid()) {
        return false;
    }

    if (!mContentMimeTypes.isEmpty()) {
        QSet<QString> contentMimeTypes = collection.contentMimeTypes().toSet();
        accepted = accepted && !(contentMimeTypes.intersect(mContentMimeTypes).isEmpty());
    }

    if (mRights != Akonadi::Collection::ReadOnly) {
        accepted = accepted && (collection.rights() & mRights);
    }

    return accepted;
}
开发者ID:quazgar,项目名称:kdepimlibs,代码行数:21,代码来源:collectionfiltermodel.cpp

示例14: runTestsForFiles

void TestProject::runTestsForFiles(const FileNameList &files, CustomRunConfiguration *configuration) const
{
  Q_ASSERT (configuration != NULL);
  Q_ASSERT (!gtestIncludeFiles_.isEmpty ());
  QSet<FileName> testFiles = getDependentFiles (gtestIncludeFiles_).toSet ();
  QSet<FileName> dependentFiles = getDependentFiles (files).toSet ();
  testFiles.intersect (dependentFiles);
  if (testFiles.isEmpty ())
  {
    return;
  }

  QStringList testCases = getTestCases (testFiles);
  if (testCases.isEmpty ())
  {
    return;
  }
  QString arguments = gtestFilter.arg(testCases.join (gtestFilterSeparator));
  configuration->setArguments (arguments);
  runTests (configuration);
}
开发者ID:AlexLeSang,项目名称:qtc-gtest,代码行数:21,代码来源:TestProject.cpp

示例15: recalculate

bool Drive::recalculate(QList<Tag *> tags) {
    if(this->results_.size() > 0) {
        beginRemoveRows(QModelIndex(), 0, this->results_.size()-1);
        this->results_ = QFileInfoList();
        endRemoveRows();
    }

    QFileInfoList newResults;
    if(tags.size() == 0) {
        this->parent_->setExpressionLabel(tr("All Files"));
        newResults = this->directory_->entryInfoList(QDir::Files);
    } else {
        QString expressionLabel = "";
        QSet<QString> fileNames = tags[0]->allFiles();
        for (int i = 0; i < tags.size(); i += TAG_TREE_COLUMNS) {
            expressionLabel.append(tags[i]->data(0).toString());
            fileNames = fileNames.intersect(tags[i]->allFiles());

             if  (i < tags.size() - TAG_TREE_COLUMNS)
                 expressionLabel.append(tr(" &#x2229; "));
        }
        this->parent_->setExpressionLabel(expressionLabel);

        for(auto i = fileNames.begin(); i != fileNames.end(); ++i) {
            newResults.append(QFileInfo(*i));
        }
    }

    if(newResults.size() > 0) {
        beginInsertRows(QModelIndex(), 0, newResults.size()-1);
        this->results_ = newResults;
        endInsertRows();
    }

    this->sort(this->sortColumn_,this->sortOrder_);
    emit(doneCalculating());
    return true;
}
开发者ID:Keller-Laminar,项目名称:HDDOrganizer,代码行数:38,代码来源:drive.cpp


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