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


C++ QLinkedList::removeOne方法代码示例

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


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

示例1: main

int main ()
{
    QLinkedList<QString> list;
    list << "sun" << "cloud" << "sun" << "rain";
    list.removeOne("sun");
    assert(list.front() == "cloud");
    // list: ["cloud", ,"sun", "rain"]
  return 0;
}
开发者ID:xsery,项目名称:benchmarks-esbmc-qt,代码行数:9,代码来源:main.cpp

示例2: run

void AssignLayers::run(Graph &graph)
{
    emit setStatusMsg("Assigning layers...");

    // copy the nodes to a linked list
    QLinkedList<AbstractNode*> vertices;
    for(AbstractNode* v : graph.getNodes()) {
        vertices.append(v);
    }

    QSet<AbstractNode*> U;
    QSet<AbstractNode*> Z;
    QList<QList<AbstractNode*>> layers;

    //add the first layer
    int currentLayer = 0;
    layers.append(QList<AbstractNode*>());
    while(!vertices.isEmpty()) {
        AbstractNode* selected = nullptr;
        for(AbstractNode* v : vertices) {
            if(Z.contains(v->getPredecessors().toSet())) {
                selected = v;
                break;
            }
        }

        if(selected != nullptr) {
            selected->setLayer(currentLayer);
            layers.last().append(selected);
            U.insert(selected);
            vertices.removeOne(selected);
        } else {
            currentLayer++;
            layers.append(QList<AbstractNode*>());
            Z.unite(U);
        }
    }

    graph.setLayers(layers);
    graph.repaintLayers();
    emit setStatusMsg("Assigning layers... Done!");
}
开发者ID:Oyuret,项目名称:layers,代码行数:42,代码来源:assignlayers.cpp

示例3: main

int main(int argc, char **argv)
{
    int itemCount = 0;
    bool ok = false;

    if (argc > 1) {
        itemCount = QString(argv[1]).toInt(&ok);
        if (!ok) {
            qWarning() << "\nError! Enter a valid number.";
            qDebug() << "\nUsage:\n\t" << *argv << "<number of items for testing>\n";
            return 1;
        }
    } else {
        qDebug() << "\nUsage:\n\t" << *argv << "<number of items for testing>\n";
        return 1;
    }

    QMap<int, QString> map;
    QHash<int, QString> hash;
    QLinkedList<QString> linkList;

    OrderedMap<int, QString> om;

    QTime timer;

    qDebug() << "Timing insertion of" << itemCount << "items...\n";

    timer.start();
    for (int i=0; i<itemCount; i++) {
        map.insert(i, QString::number(i));
    }
    qDebug() << "Map :" << timer.elapsed() << "msecs";

    timer.start();
    for (int i=0; i<itemCount; i++) {
        hash.insert(i, QString::number(i));
    }
    qDebug() << "Hash :" << timer.elapsed() << "msecs";

    timer.start();
    for (int i=0; i<itemCount; i++) {
        linkList.append(QString::number(i));
    }
    qDebug() << "Link list :" << timer.elapsed() << "msecs";

    timer.start();
    for (int i=0; i<itemCount; i++) {
        om.insert(i, QString::number(i));
    }
    qDebug() << "Ordered ma :" << timer.elapsed() << "msecs";
    qDebug() << "\n";

    qDebug() << "Timing iteration over" << itemCount << "items...\n";

    int dummy = 0;
    timer.start();
    foreach (const QString& val, map.values()) {
        dummy += val.size();
    }
    qDebug() << "Map :" << timer.elapsed() << "msecs";

    dummy = 0;
    timer.start();
    foreach (const QString& val, hash.values()) {
        dummy += val.size();
    }
    qDebug() << "Hash :" << timer.elapsed() << "msecs";

    dummy = 0;
    timer.start();
    foreach (const QString& val, linkList) {
        dummy += val.size();
    }
    qDebug() << "Linked list :" << timer.elapsed() << "msecs";

    dummy = 0;
    timer.start();
    foreach (const QString& val, om.values()) {
        dummy += val.size();
    }
    qDebug() << "Ordered map :" << timer.elapsed() << "msecs";
    qDebug() << "\n";

    qDebug() << "Timing removal of random item from" << itemCount << "items...\n";

    int rand = qrand() % itemCount;
    timer.start();
    map.remove(rand);
    qDebug() << "Map :" << timer.elapsed() << "msecs";

    rand = qrand() % itemCount;
    timer.start();
    hash.remove(rand);
    qDebug() << "Hash :" << timer.elapsed() << "msecs";

    rand = qrand() % itemCount;
    timer.start();
    linkList.removeOne(QString::number(rand));
    qDebug() << "Link list :" << timer.elapsed() << "msecs";

//.........这里部分代码省略.........
开发者ID:FlavioFalcao,项目名称:qt-ordered-map,代码行数:101,代码来源:main.cpp


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