本文整理汇总了C++中QQueue::takeFirst方法的典型用法代码示例。如果您正苦于以下问题:C++ QQueue::takeFirst方法的具体用法?C++ QQueue::takeFirst怎么用?C++ QQueue::takeFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQueue
的用法示例。
在下文中一共展示了QQueue::takeFirst方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: breadthSearch
void Algorithms::breadthSearch(Vertex * firstVertex, GraphSearchWorker *worker)
{
if(firstVertex == nullptr || worker == nullptr) {
return;
}
QQueue<Edge *> edgeQueue;
QSet<int> visitedVertexId;
Edge * tmpEdge;
worker->firstVertex(firstVertex);
visitedVertexId.insert(firstVertex->id());
// firstVertex->setBitToken(0, true);
for(Edge *edge : firstVertex->outEdges()) {
// qDebug() << "111";
edgeQueue.append(edge);
}
while( !edgeQueue.empty() ) {
tmpEdge = edgeQueue.takeFirst();
// qDebug() << tmpEdge->vertex()->id();
if(visitedVertexId.contains(tmpEdge->targetVertex()->id())) {
// qDebug() << "if" << tmpEdge->vertex()->id() << edgeQueue.empty();
// if(tmpEdge->vertex()->bitToken(0) == true) {
continue;
}
worker->nextVertexEdge(tmpEdge);
if(worker->isEnd()) {
break;
}
visitedVertexId.insert(tmpEdge->targetVertex()->id());
for(Edge * edge : tmpEdge->targetVertex()->outEdges()) {
edgeQueue.append(edge);
}
}
worker->searchEnded();
}
示例2: scanProject
void ModelIndexer::scanProject(ProjectExplorer::Project *project)
{
if (!project->rootProjectNode())
return;
// TODO harmonize following code with findFirstModel()?
const Utils::FileNameList files = project->files(ProjectExplorer::Project::SourceFiles);
QQueue<QueuedFile> filesQueue;
QSet<QueuedFile> filesSet;
for (const Utils::FileName &file : files) {
QFileInfo fileInfo = file.toFileInfo();
Utils::MimeType mimeType = Utils::mimeTypeForFile(fileInfo);
if (mimeType.name() == QLatin1String(Constants::MIME_TYPE_MODEL)) {
QueuedFile queuedFile(file.toString(), project, fileInfo.lastModified());
filesQueue.append(queuedFile);
filesSet.insert(queuedFile);
}
}
QString defaultModelFile = findFirstModel(project->rootProjectNode());
bool filesAreQueued = false;
{
QMutexLocker locker(&d->indexerMutex);
// remove deleted files from queue
for (int i = 0; i < d->filesQueue.size();) {
if (d->filesQueue.at(i).project() == project) {
if (filesSet.contains(d->filesQueue.at(i))) {
++i;
} else {
d->queuedFilesSet.remove(d->filesQueue.at(i));
d->filesQueue.removeAt(i);
}
}
}
// remove deleted files from indexed models
foreach (const QString &file, d->indexedModels.keys()) {
if (!filesSet.contains(QueuedFile(file, project)))
removeModelFile(file, project);
}
// remove deleted files from indexed diagrams
foreach (const QString &file, d->indexedDiagramReferences.keys()) {
if (!filesSet.contains(QueuedFile(file, project)))
removeDiagramReferenceFile(file, project);
}
// queue files
while (!filesQueue.isEmpty()) {
QueuedFile queuedFile = filesQueue.takeFirst();
if (!d->queuedFilesSet.contains(queuedFile)) {
QMT_CHECK(!d->filesQueue.contains(queuedFile));
d->filesQueue.append(queuedFile);
d->queuedFilesSet.insert(queuedFile);
filesAreQueued = true;
}
}
// auto-open model file only if project is already configured
if (!defaultModelFile.isEmpty() && !project->targets().isEmpty()) {
d->defaultModelFiles.insert(QueuedFile(defaultModelFile, project, QDateTime()));
}
}
if (filesAreQueued)
emit filesQueued();
}