本文整理汇总了C++中QQueue::append方法的典型用法代码示例。如果您正苦于以下问题:C++ QQueue::append方法的具体用法?C++ QQueue::append怎么用?C++ QQueue::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQueue
的用法示例。
在下文中一共展示了QQueue::append方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeAnimation
void BFS::initializeAnimation(){
setMenu(false);
int r=255, g=255, b=0;
int color_step= 25;
m_operations.push_back([=,this](){ getNode(_currentNode)->setColor(QColor(r, g, b));colorNode(_currentNode); });
r-=color_step;
g-=color_step;
QQueue<int> queue;
queue.append(_currentNode);
getNode(_currentNode)->setVisited(true);
while(!queue.empty()){
int curr = queue.at(0);
queue.pop_front();
NodeList list = getNeighbours(curr);
for (auto iter : list){
if(!getNode(iter)->visited()){
getNode(iter)->setVisited(true);
m_operations.push_back([=,this](){getEdge(curr, iter)->setColor(QColor(r,g,b)); colorEdge(curr, iter); emit highlightLine(10);});
m_operations.push_back([=,this](){getNode(iter)->setColor(QColor(r,g,b)); colorNode(iter);});
queue.append(iter);
}
}
r-=color_step;
g-=color_step;
}
m_animationInitialized= true;
m_currentStepInAnimation= 0;
m_numberOfStepsInAnimation= m_operations.size();
}
示例2: while
QList<vertice> Grafo::Dijkstra(vertice *ini, vertice* fin)
{
for(int i = 0; i < this->vertices.size();i++)
{
this->vertices.at(i)->costoHastaAhora = INT_MAX;
this->vertices.at(i)->predecesor = NULL;
}
int indexOrigen = this->EncontrarIndexVertice(ini);
int indexMeta = this->EncontrarIndexVertice(fin);
int indexMinimoCola, indexMinimoVertices;
this->vertices.at(indexOrigen)->costoHastaAhora = 0;
QQueue<vertice*> cola;
vertice *u;
float peso;
cola.append(this->vertices.at(indexOrigen));
while(!cola.empty())
{
indexMinimoCola = this->indexElementoMenor(cola);
u = cola.at(indexMinimoCola);
indexMinimoVertices = this->EncontrarIndexVertice(u);
cola.removeAll(u);
this->vertices.at(indexMinimoVertices)->visitado = true;
for(int j = 0; j < this->vertices.at(indexMinimoVertices)->adyacentes.size(); j++)
{
if(!this->vertices.at(indexMinimoVertices)->adyacentes.at(j)->visitado)
{
peso = this->vertices.at(indexMinimoVertices)->configuracion.Distanica(&this->vertices.at(indexMinimoVertices)->adyacentes.at(j)->configuracion);
if(this->vertices.at(indexMinimoVertices)->adyacentes.at(j)->costoHastaAhora >
this->vertices.at(indexMinimoVertices)->costoHastaAhora + peso)
{
this->vertices.at(indexMinimoVertices)->adyacentes.at(j)->costoHastaAhora = this->vertices.at(indexMinimoVertices)->costoHastaAhora + peso;
this->vertices.at(indexMinimoVertices)->adyacentes.at(j)->predecesor = this->vertices.at(indexMinimoVertices);
cola.append(this->vertices.at(indexMinimoVertices)->adyacentes.at(j));
}
}
}
//SE debe remover de la cola el elemento
}
QList<vertice> ruta;
vertice *actual = this->vertices.at(indexMeta);
while(actual != NULL)
{
ruta.push_front(*actual);
actual = actual->predecesor;
}
return ruta;
}
示例3: run
void RefInterface::run()
{
while(!stopped)
{
//qDebug("Reference thread run");
mutex.lock();
range();
emit getIMUData();
if(!msg.isEmpty())
{
msg.clear();
}
switch(count)
{
case 1: solver->find_intersection_points_nlls3d(x0 ,y0, z0, r0, x1, y1, z1, r1, x2
, y2, z2, r2, 0.0, 0.0, 0.5, px, py, pz );
count = count + 1;
break;
case 2: solver->find_intersection_points_nlls3d(x1 ,y1, z1, r1, x2, y2, z2, r2, x3
, y3, z3, r3, 0.0, 0.0, 0.5, px, py, pz );
count = count + 1;
break;
case 3: solver->find_intersection_points_nlls3d(x2 ,y2, z2, r2, x3, y3, z3, r3, x0
, y0, z0, r0, 0.0, 0.0, 0.5, px, py, pz );
count = count + 1;
break;
case 4: solver->find_intersection_points_nlls3d(x3 ,y3, z3, r3, x3, y0, z0, r0, x1
, y1, z1, r1, 0.0, 0.0, 0.5, px, py, pz );
count = 1;
break;
default:
break;
}
//Here I set the buffer struct to the position returned from solver
oldx = px;
oldy = py;
oldz = pz;
buffer.x = px;
buffer.y = py;
buffer.z = pz;
//append the buffer to the queue
msg.append(buffer);
//unlock the mutex so the consumer can have access to buffer
mutex.unlock();
//set stopped to true, so consumer has a turn
stopped = false;
}
}
示例4: 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();
}
示例5: queueTrkMessage
void TrkWriteQueue::queueTrkMessage(unsigned char code, TrkCallback callback,
const QByteArray &data, const QVariant &cookie,
bool invokeOnNAK)
{
const unsigned char token = code == TRK_WRITE_QUEUE_NOOP_CODE ?
(unsigned char)(0) : nextTrkWriteToken();
SharedPointerTrkMessage msg(new TrkMessage(code, token, callback));
msg->data = data;
msg->cookie = cookie;
msg->invokeOnNAK = invokeOnNAK;
trkWriteQueue.append(msg);
}
示例6: nodevisited
QList<ListDigraph::Node> ProcessModel::reachableFrom(const QList<ListDigraph::Node>& s) {
ListDigraph::NodeMap<bool > nodevisited(graph, false);
QList<ListDigraph::Node> res;
QQueue<ListDigraph::Node> q;
ListDigraph::Node curnode;
ListDigraph::Node targetnode;
q.reserve(countNodes(graph));
res.reserve(countNodes(graph));
for (int i = 0; i < s.size(); i++) {
if (s[i] != INVALID) {
q.append(s[i]);
}
}
while (!q.empty()) {
curnode = q.dequeue();
if (!nodevisited[curnode]) {
nodevisited[curnode] = true;
res.append(curnode);
// Check the successors
for (ListDigraph::OutArcIt oait(graph, curnode); oait != INVALID; ++oait) {
targetnode = graph.target(oait);
if (!nodevisited[targetnode]) {
q.enqueue(targetnode);
}
}
}
}
return res;
}
示例7: 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();
}
示例8: queueTrkInitialPing
void TrkWriteQueue::queueTrkInitialPing()
{
const SharedPointerTrkMessage msg(new TrkMessage(0, 0)); // Ping, reset sequence count
trkWriteQueue.append(msg);
}
示例9: getPolyHull
polyHull* LappedUtils::getPolyHull(QImage* blob,int iterations)
{
QImage img = *blob;
int w = img.width();
int h = img.height();
uchar* imgdata = img.bits();
QQueue<vert2d*>* vQu = new QQueue<vert2d*>();
QList<vert2d*>* vLi = new QList<vert2d*>();//just for debugging/drawing
QList<edge2d*>* eLi = new QList<edge2d*>();
QHash<QPair<vert2d*,vert2d*>,edge2d*>* edgesMade = new QHash<QPair<vert2d*,vert2d*>,edge2d*>();
QHash<QPair<int,int>,vert2d*>* vertsMade = new QHash<QPair<int,int>,vert2d*>();
vert2d* vseed;
for(int x=1;x<w-1;x++)
{bool br=false;
for(int y=1;y<h-1;y++)
{
if(imgdata[4*(y*w+x)]<255 && (imgdata[4*((y+1)*w+x)]==255 || imgdata[4*((y-1)*w+x)]==255 || imgdata[4*(y*w+(x+1))]==255 || imgdata[4*(y*w+(x-1))]==255))
{
vseed = new vert2d(x,y);
vQu->append(vseed);
vLi->append(vseed);
vertsMade->insert(qMakePair(x,y),vseed);
br=true;
break;
}
}if(br)break;
}
while(!vQu->empty())
{
vert2d* v = vQu->dequeue();
//cout<<"dequeued ("<<v->x<<","<<v->y<<")"<<endl;
for(int x2=v->x-1;x2<=v->x+1;x2++)
{
for(int y2=v->y-1;y2<=v->y+1;y2++)
{
if(x2==v->x && y2==v->y){continue;}
if(imgdata[4*(y2*w+x2)]<255 && (imgdata[4*((y2+1)*w+x2)]==255 || imgdata[4*((y2-1)*w+x2)]==255 || imgdata[4*(y2*w+(x2+1))]==255 || imgdata[4*(y2*w+(x2-1))]==255))
{
vert2d* v2;
if(!vertsMade->contains(qMakePair(x2,y2)))
{
v2 = new vert2d(x2,y2);
vQu->append(v2);
vLi->append(v2);
vertsMade->insert(qMakePair(x2,y2),v2);
}
else
{
v2 = vertsMade->value(qMakePair(x2,y2));
}
if(!edgesMade->contains(qMakePair(v,v2)))
{
edge2d* e = new edge2d(v,v2);
edgesMade->insert(qMakePair(v,v2),e);
edgesMade->insert(qMakePair(v2,v),e);
eLi->append(e); //cout<<"157- "; printEdge(e);
v->addEdge(e);
v2->addEdge(e);
}
}
}
}
}
//first, remove all collinear points
vert2d* vs;
vert2d* ve;
vert2d* vnew;
vs=vseed;
//cout<<"vs: ";vs->print();
if(vs->e1->v1==vs)
ve = (vs->e1)->v2;
else
ve = (vs->e1)->v1;
//cout<<"ve: ";ve->print();
vnew=ve->otherAdjVert(vs);
//cout<<"new: ";vnew->print();
do
{
while(ccw(vs,ve,vnew)==0)
{
edge2d* e = new edge2d(vs,vnew);
edgesMade->insert(qMakePair(vs,vnew),e);
edgesMade->insert(qMakePair(vnew,vs),e);
eLi->append(e); //cout<<"192- "; printEdge(e);
edge2d* e1 = edgesMade->value(qMakePair(vs,ve));
//cout<<"e1: ";printEdge(e1);
edge2d* e2 = edgesMade->value(qMakePair(ve,vnew));
//cout<<"e2: ";printEdge(e2);
//.........这里部分代码省略.........