本文整理汇总了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;
}
示例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!");
}
示例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";
//.........这里部分代码省略.........