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


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

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


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

示例1: loadBanPairs

void BanPair::loadBanPairs() {
    AllBanSet.clear();
    SecondBanSet.clear();
    BanPairSet.clear();

    // special cases
    QStringList banlist = Config.value("Banlist/Pairs", "").toStringList();

    foreach (QString line, banlist) {
        QStringList names = line.split("+");
        if (names.isEmpty())
            continue;

        QString first = names.at(0).trimmed();
        if (names.length() == 2) {
            QString second = names.at(1).trimmed();
            if (first.isEmpty())
                SecondBanSet.insert(second);
            else {
                BanPair pair(first, second);
                BanPairSet.insert(pair);
            }
        }
        else if (names.length()==1) {
            AllBanSet.insert(first);
        }
    }
开发者ID:NSMX,项目名称:QSanguosha-Para,代码行数:27,代码来源:banpair.cpp

示例2: channels

void Fixture_Test::channels()
{
    Fixture fxi(this);
    QLCFixtureDef* fixtureDef = m_doc->fixtureDefCache()->fixtureDef("i-Pix", "BB4");
    QVERIFY(fixtureDef != NULL);
    QLCFixtureMode* fixtureMode = fixtureDef->modes().last();
    QVERIFY(fixtureMode != NULL);
    fxi.setFixtureDefinition(fixtureDef, fixtureMode);

    QCOMPARE(fxi.channel("red", Qt::CaseInsensitive), quint32(3));
    QCOMPARE(fxi.channel("red", Qt::CaseInsensitive, QLCChannel::Intensity), quint32(3));
    QCOMPARE(fxi.channel("brown", Qt::CaseInsensitive), QLCChannel::invalid());

    QSet <quint32> chs;
    chs << 3 << 4 << 21 << 22 << 12 << 13 << 30 << 31;
    QCOMPARE(chs, fxi.channels("red", Qt::CaseInsensitive));
    QCOMPARE(chs, fxi.channels("red", Qt::CaseInsensitive, QLCChannel::Intensity));
    chs.clear();
    chs << 5 << 6 << 23 << 24 << 14 << 15 << 32 << 33;
    QCOMPARE(chs, fxi.channels("green", Qt::CaseInsensitive));
    chs.clear();
    QCOMPARE(chs, fxi.channels("green"));
    chs.clear();
    chs << 7 << 8 << 16 << 17 << 25 << 26 << 34 << 35;
    QCOMPARE(chs, fxi.channels("blue", Qt::CaseInsensitive));
    chs.clear();
    QCOMPARE(chs, fxi.channels("green", Qt::CaseInsensitive, QLCChannel::Colour));
    chs.clear();
    QCOMPARE(fxi.channels("brown", Qt::CaseInsensitive, QLCChannel::Intensity), chs);
}
开发者ID:CCLinck21,项目名称:qlcplus,代码行数:30,代码来源:fixture_test.cpp

示例3: mouseReleased

void EditPolygonTool::mouseReleased(QGraphicsSceneMouseEvent *event)
{
    if (event->button() != Qt::LeftButton)
        return;

    switch (mMode) {
    case NoMode:
        if (mClickedHandle) {
            QSet<PointHandle*> selection = mSelectedHandles;
            const Qt::KeyboardModifiers modifiers = event->modifiers();
            if (modifiers & (Qt::ShiftModifier | Qt::ControlModifier)) {
                if (selection.contains(mClickedHandle))
                    selection.remove(mClickedHandle);
                else
                    selection.insert(mClickedHandle);
            } else {
                selection.clear();
                selection.insert(mClickedHandle);
            }
            setSelectedHandles(selection);
        } else if (mClickedObjectItem) {
            QSet<MapObjectItem*> selection = mapScene()->selectedObjectItems();
            const Qt::KeyboardModifiers modifiers = event->modifiers();
            if (modifiers & (Qt::ShiftModifier | Qt::ControlModifier)) {
                if (selection.contains(mClickedObjectItem))
                    selection.remove(mClickedObjectItem);
                else
                    selection.insert(mClickedObjectItem);
            } else {
                selection.clear();
                selection.insert(mClickedObjectItem);
            }
            mapScene()->setSelectedObjectItems(selection);
            updateHandles();
        } else if (!mSelectedHandles.isEmpty()) {
            // First clear the handle selection
            setSelectedHandles(QSet<PointHandle*>());
        } else {
            // If there is no handle selection, clear the object selection
            mapScene()->setSelectedObjectItems(QSet<MapObjectItem*>());
            updateHandles();
        }
        break;
    case Selecting:
        updateSelection(event);
        mapScene()->removeItem(mSelectionRectangle);
        mMode = NoMode;
        break;
    case Moving:
        finishMoving(event->scenePos());
        break;
    }

    mMousePressed = false;
    mClickedHandle = nullptr;
}
开发者ID:Shorttail,项目名称:tiled,代码行数:56,代码来源:editpolygontool.cpp

示例4: getSafestCell

Cell* Grid::getSafestCell() const
{
	QSet<Cell*> remainingCells;

	// find the most constrained cells (fewest options in domain)
	int minimumDomainSize = 100;
	for( auto cellIter=cells.begin(); cellIter!=cells.end(); ++cellIter )
	{
		Cell* cell = *cellIter;
		if( cell->value() != Cell::UNKNOWN )
			continue;

		if( cell->domain().size() < minimumDomainSize ){
			minimumDomainSize = cell->domain().size();
			remainingCells.clear();
		}
		if( cell->domain().size() == minimumDomainSize ){
			remainingCells.insert(cell);
		}
	}

	// if there are no cells return null, otherwise return a minimum cell
	if( remainingCells.size() == 0 )
		return nullptr;
	else
		return remainingCells.values()[0];
}
开发者ID:stevenvergenz,项目名称:c-voku,代码行数:27,代码来源:grid_csp.cpp

示例5: progressValueChanged

void tst_QFutureWatcher::progressValueChanged()
{
#ifdef PRINT
    qDebug() << "main thread" << QThread::currentThread();
#endif

    progressValues.clear();
    const int listSize = 20;
    QList<int> list = createList(listSize);

    QFutureWatcher<void> futureWatcher;
    ProgressObject progressObject;
    QObject::connect(&futureWatcher, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
#ifdef PRINT
    QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &progressObject, SLOT(printProgress(int)), Qt::DirectConnection );
#endif
    QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &progressObject, SLOT(registerProgress(int)));

    futureWatcher.setFuture(QtConcurrent::map(list, mapSleeper));

    QTestEventLoop::instance().enterLoop(5);
    QVERIFY(!QTestEventLoop::instance().timeout());
    futureWatcher.disconnect();
    QVERIFY(progressValues.contains(0));
    QVERIFY(progressValues.contains(listSize));
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:26,代码来源:tst_qfuturewatcher.cpp

示例6: paintEvent

void HalfEdgeWidget::paintEvent(QPaintEvent *event)
{
    if(m_edge != nullptr)
    {
        QPainter painter(this);
        painter.setRenderHint(QPainter::Antialiasing);

        QSet<Face*>* mySet = new QSet<Face*>;
        drawMesh(mySet, m_edge, painter);
        mySet->clear();
        delete mySet;
    }
}
开发者ID:gabrieljardim,项目名称:HalfEdge,代码行数:13,代码来源:halfedgewidget.cpp

示例7: channels

void Fixture_Test::channels()
{
    Fixture fxi(this);
    QLCFixtureDef* fixtureDef = m_doc->fixtureDefCache()->fixtureDef("i-Pix", "BB4");
    QVERIFY(fixtureDef != NULL);
    QLCFixtureMode* fixtureMode = fixtureDef->modes().last();
    QVERIFY(fixtureMode != NULL);
    fxi.setFixtureDefinition(fixtureDef, fixtureMode);

    QCOMPARE(fxi.channel(QLCChannel::Intensity, QLCChannel::Red), quint32(3));

    QSet <quint32> chs;
    chs << 3 << 4 << 21 << 22 << 12 << 13 << 30 << 31;
    QCOMPARE(chs, fxi.channels(QLCChannel::Intensity, QLCChannel::Red));
    chs.clear();
    chs << 5 << 6 << 23 << 24 << 14 << 15 << 32 << 33;
    QCOMPARE(chs, fxi.channels(QLCChannel::Intensity, QLCChannel::Green));
    chs.clear();
    chs << 7 << 8 << 16 << 17 << 25 << 26 << 34 << 35;
    QCOMPARE(chs, fxi.channels(QLCChannel::Intensity, QLCChannel::Blue));
    chs.clear();
    QCOMPARE(chs, fxi.channels(QLCChannel::Colour, QLCChannel::Blue));
}
开发者ID:PML369,项目名称:qlcplus,代码行数:23,代码来源:fixture_test.cpp

示例8: throttling

void tst_iteratekernel::throttling()
{
    const int totalIterations = 400;
    iterations = 0;

    threads.clear();

    ThrottleFor f(0, totalIterations);
    f.startBlocking();

    QCOMPARE((int)iterations, totalIterations);


    QCOMPARE(threads.count(), 1);
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例9: throttling

void tst_QtConcurrentIterateKernel::throttling()
{
    const int totalIterations = 400;
    iterations.store(0);

    threads.clear();

    ThrottleFor f(0, totalIterations);
    f.startBlocking();

    QCOMPARE(iterations.load(), totalIterations);


    QCOMPARE(threads.count(), 1);
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:15,代码来源:tst_qtconcurrentiteratekernel.cpp

示例10: crsSetForLayer

bool QgsConfigParser::crsSetForLayer( const QDomElement& layerElement, QSet<QString> &crsSet ) const
{
  if ( layerElement.isNull() )
  {
    return false;
  }

  crsSet.clear();

  QDomNodeList crsNodeList = layerElement.elementsByTagName( "CRS" );
  for ( int i = 0; i < crsNodeList.size(); ++i )
  {
    crsSet.insert( crsNodeList.at( i ).toElement().text() );
  }

  return true;
}
开发者ID:veikoviil,项目名称:Quantum-GIS,代码行数:17,代码来源:qgsconfigparser.cpp

示例11: mouseReleased

void ObjectSelectionTool::mouseReleased(QGraphicsSceneMouseEvent *event)
{
    if (event->button() != Qt::LeftButton)
        return;

    switch (mMode) {
    case NoMode:
        if (mClickedObjectItem) {
            QSet<MapObjectItem*> selection = mapScene()->selectedObjectItems();
            const Qt::KeyboardModifiers modifiers = event->modifiers();
            if (modifiers & (Qt::ShiftModifier | Qt::ControlModifier)) {
                if (selection.contains(mClickedObjectItem))
                    selection.remove(mClickedObjectItem);
                else
                    selection.insert(mClickedObjectItem);
            } else {
                selection.clear();
                selection.insert(mClickedObjectItem);
            }
            mapScene()->setSelectedObjectItems(selection);
        } else {
            mapScene()->setSelectedObjectItems(QSet<MapObjectItem*>());
        }
        break;
    case Selecting:
        updateSelection(event->scenePos(), event->modifiers());
        mapScene()->removeItem(mSelectionRectangle);
        mMode = NoMode;
        break;
    case Moving:
        finishMoving(event->scenePos());
        break;
    case Rotating:
        finishRotating(event->scenePos());
        break;
    }

    mMousePressed = false;
    mClickedObjectItem = 0;
    mClickedCornerHandle = 0;
}
开发者ID:bradley45,项目名称:tiled,代码行数:41,代码来源:objectselectiontool.cpp

示例12: neighborhoodTest

void WrapHexGridTest::neighborhoodTest()
{
    // generated by tools/scripts/hexgridder.py
    // 00  01  02  03  04  05
    //   06  07  08  09  10  11
    //     12  13  14  15  16  17
    //       18  19  20  21  22  23
    //         24  25  26  27  28  29
    //           30  31  32  33  34  35
    WrapHexGrid<int> grid( QVector<int>() << 6 );
    QVector< QPair<int, int> > neighborhood;
    QSet<int> testNeighborhoodIndices;
    QSet<int> trueNeighborhoodIndices;
    QTextStream cout( stdout );

    testNeighborhoodIndices.clear();
    neighborhood = grid.neighborhood( 2, 0 );
    for( int i=0; i<neighborhood.size(); i++ )
        testNeighborhoodIndices.insert( neighborhood[i].first );
    trueNeighborhoodIndices
                  << 24 << 25 << 26
               << 35 << 30 << 31 << 32
            <<  4 <<  5 <<  0 <<  1 <<  2
               << 10 << 11 << 06 << 07
                  << 16 << 17 << 12;

    cout << "testNeighborhood: ";
    foreach( int index, testNeighborhoodIndices )
        cout << index << " ";
    cout << endl;

    cout << "trueNeighborhood: ";
    foreach( int index, trueNeighborhoodIndices )
        cout << index << " ";
    cout << endl;

    QVERIFY2(testNeighborhoodIndices == trueNeighborhoodIndices, "Failure");

}
开发者ID:alex09x,项目名称:somtk,代码行数:39,代码来源:tst_wraphexgridtest.cpp

示例13: reserve

void tst_QSet::reserve()
{
    QSet<int> set;
    int n = set.capacity();
    QVERIFY(n == 0);

    set.reserve(1000);
    QVERIFY(set.capacity() >= 1000);

    for (int i = 0; i < 500; ++i)
        set.insert(i);

    QVERIFY(set.capacity() >= 1000);

    for (int j = 0; j < 500; ++j)
        set.remove(j);

    QVERIFY(set.capacity() >= 1000);

    set.clear();
    QVERIFY(set.capacity() == 0);
}
开发者ID:,项目名称:,代码行数:22,代码来源:

示例14: crsSetForLayer

bool QgsConfigParser::crsSetForLayer( const QDomElement& layerElement, QSet<int>& crsSet ) const
{
  if ( layerElement.isNull() )
  {
    return false;
  }

  crsSet.clear();
  bool intConversionOk;

  QDomNodeList crsNodeList = layerElement.elementsByTagName( "CRS" );
  for ( int i = 0; i < crsNodeList.size(); ++i )
  {
    int epsg = crsNodeList.at( i ).toElement().text().remove( 0, 5 ).toInt( &intConversionOk );
    if ( intConversionOk )
    {
      crsSet.insert( epsg );
    }
  }

  return true;
}
开发者ID:mmubangizi,项目名称:qgis,代码行数:22,代码来源:qgsconfigparser.cpp

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


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