本文整理汇总了C++中QQueue::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ QQueue::empty方法的具体用法?C++ QQueue::empty怎么用?C++ QQueue::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQueue
的用法示例。
在下文中一共展示了QQueue::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bfs
// Returns true if there is a path from source 's'
// to sink 't' in residual graph.
int Graph::bfs(int s, int t) {
visited_.fill(false);
QQueue<int> q;
q << s;
parent_[s] = -1;
visited_[s] = true;
while (!q.empty()) {
int u = q.front();
q.pop_front();
for (auto& v : r_edges_[u].keys()) {
if (!visited_[v] && qAbs(r_edges_[u][v])>Float::epsilon()) {
q << v;
parent_[v] = u;
visited_[v] = true;
if (v == t) q.clear();
}
}
}
// if we reached sink in BFS starting from source, then return true, else false
return (visited_[t] == true);
}
示例2:
QHash<Cell*, QSet<char> > Grid::broadenDomains(Cell *unsetCell)
{
QQueue<Cell*> dirtyCells;
QHash<Cell*, QSet<char> > diff;
// initialize set of cells to check
auto depCells = unsetCell->dependentCells();
for( auto dep=depCells.constBegin(); dep!=depCells.constEnd(); ++dep ){
dirtyCells.enqueue(*dep);
}
diff.insert(unsetCell, QSet<char>());
while( !dirtyCells.empty() )
{
Cell* dirty = dirtyCells.dequeue();
// broaden domain and re-restrict to check for changes
const QSet<char> oldDomain = dirty->domain();
dirty->broadenDomain();
dirty->restrictDomain();
// if there are changes, enqueue dirty cell's dependents
if( dirty->domain() != oldDomain ){
diff.insert(dirty, QSet<char>());
auto depCells = dirty->dependentCells();
for( auto dep=depCells.constBegin(); dep!=depCells.constEnd(); ++dep ){
dirtyCells.enqueue(*dep);
}
}
}
unsetCell->restrictDomain();
return diff;
}
示例3: addMusics
void MusicPage::addMusics(int listId, QQueue<MusicInfo> musics)
{
MusicInfo musicInfo;
MusicList *musicList;
int row;
while (!musics.empty())
{
musicInfo = musics.front();
musics.pop_front();
musicList = (MusicList *)musicLists->widget(listId);
row = musicList->count();
QListWidgetItem *item = new QListWidgetItem(musicList);
item->setSizeHint(QSize(item->sizeHint().width(), 30));
musicList->insertItem(row, item);
MusicListItem *itemwidget = new MusicListItem(musicList);
itemwidget->setName(musicInfo.getName());
itemwidget->setArtist(musicInfo.getArtist());
musicList->setItemWidget(item, itemwidget);
/*
musicList->insertRow(row);
QTableWidgetItem *nameItem = new QTableWidgetItem(musicInfo.getName());
QTableWidgetItem *artiseItem = new QTableWidgetItem(musicInfo.getArtist());
nameItem->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
artiseItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
musicList->setItem(row, 0, nameItem);
musicList->setItem(row, 1, artiseItem);
musicList->setCurrentCell(row, 0);
*/
}
}
示例4: 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();
}
示例5: streamLoop
void streamLoop(qintptr socketDesc, QQueue<QByteArray> &queue, bool& streaming) {
QTcpSocket* socket = new QTcpSocket();
// TCP_NODELAY + disable Nagle's algorithm
socket->setSocketOption(QAbstractSocket::LowDelayOption, QVariant::fromValue(1));
// Internetwork control
socket->setSocketOption(QAbstractSocket::TypeOfServiceOption, QVariant::fromValue(192));
socket->setSocketDescriptor(socketDesc);
socket->readAll();
QByteArray ContentType = ("HTTP/1.1 200 OK\r\n" \
"Server: test\r\n" \
"Cache-Control: no-cache\r\n" \
"Cache-Control: private\r\n" \
"Connection: close\r\n"\
"Pragma: no-cache\r\n"\
"Content-Type: multipart/x-mixed-replace; boundary=--boundary\r\n\r\n");
socket->write(ContentType);
while((socket->state() != QAbstractSocket::ClosingState ||
socket->state() != QAbstractSocket::UnconnectedState) &&
socket->state() == QAbstractSocket::ConnectedState &&
streaming) {
if(queue.empty()) { // no new frame available
continue;
}
// make sure that the queue doesn't grow too big or
// the OOM killer will kick in
if(queue.length() > 20) {
queue.clear();
continue;
}
QByteArray boundary = ("--boundary\r\n" \
"Content-Type: image/jpeg\r\n" \
"Content-Length: ");
QByteArray img = queue.dequeue();
boundary.append(QString::number(img.length()));
boundary.append("\r\n\r\n");
socket->write(boundary);
socket->waitForBytesWritten();
boundary.clear();
socket->write(img);
socket->waitForBytesWritten();
img.clear();
}
socket->flush();
socket->abort();
socket->deleteLater();
streaming = false;
queue.clear();
return;
}
示例6: service
int BleRtmpSendThread::service(BleRtmpMuxer & muxer)
{
int ret = BLE_SUCESS;
if ((ret = sendVideoSh(muxer)) != BLE_SUCESS) {
return ret;
}
if ((ret = sendAudioSh(muxer)) != BLE_SUCESS) {
return ret;
}
while (!m_stop) {
QQueue<BleAVPacket *> pkts = BleAVQueue::instance()->dequeue();
if (pkts.isEmpty()) {
msleep(50);
continue;
}
BleAutoLocker(m_mutex);
while (!pkts.empty()) {
BleAVPacket *pkt = pkts.dequeue();
BleAutoFree(BleAVPacket, pkt);
MStream &data = pkt->data;
if (pkt->pktType == Packet_Type_Video) {
if (muxer.addH264(data, pkt->dts) != TRUE ) {
ret = BLE_RTMPSEND_ERROR;
break;
}
m_videoKbps += (data.size() + 11);
m_fps += 1;
} else if (pkt->pktType == Packet_Type_Audio) {
if (muxer.addAAC(data, pkt->dts) != TRUE ) {
ret = BLE_RTMPSEND_ERROR;
break;
}
m_audioKbps += (data.size() + 11);
}
m_sendDataCount += (data.size() + 11);
}
// if send failed, then pkts may has some pkt
// we should delete it.
for (int i = 0; i < pkts.size(); ++i) {
BleAVPacket *pkt = pkts.at(i);
BleFree(pkt);
}
}
return ret;
}
示例7: while
void
EffectNode::renderSubNodes( void )
{
QList<EffectNode*> effectsNodes = m_enf.getEffectNodeInstancesList();
QList<EffectNode*>::iterator effectsNodesIt = effectsNodes.begin();
QList<EffectNode*>::iterator effectsNodesEnd = effectsNodes.end();
QList<OutSlot<LightVideoFrame>*> intOuts = m_connectedInternalsStaticVideosOutputs.getObjectsReferencesList() ;
QList<OutSlot<LightVideoFrame>*>::iterator intOutsIt = intOuts.begin();
QList<OutSlot<LightVideoFrame>*>::iterator intOutsEnd = intOuts.end();
QQueue<EffectNode*> nodeQueue;
EffectNode* toQueueNode;
EffectNode* currentNode;
InSlot<LightVideoFrame>* currentIn;
for ( ; effectsNodesIt != effectsNodesEnd; ++effectsNodesIt )
{
if (
( (*effectsNodesIt)->getNBConnectedStaticsVideosInputs() == 0 ) &&
( (*effectsNodesIt)->getNBConnectedStaticsVideosOutputs() > 0 )
)
{
(*effectsNodesIt)->setVisited();
nodeQueue.enqueue( (*effectsNodesIt) );
}
}
for ( ; intOutsIt != intOutsEnd; ++intOutsIt )
{
currentIn = (*intOutsIt)->getInSlotPtr();
toQueueNode = currentIn->getPrivateFather();
if ((toQueueNode != this) && ( toQueueNode->wasItVisited() == false ))
{
toQueueNode->setVisited();
nodeQueue.enqueue( toQueueNode );
}
}
while ( nodeQueue.empty() == false )
{
currentNode = nodeQueue.dequeue();
QList<OutSlot<LightVideoFrame>*> outs = currentNode->getConnectedStaticsVideosOutputsList();
QList<OutSlot<LightVideoFrame>*>::iterator outsIt = outs.begin();
QList<OutSlot<LightVideoFrame>*>::iterator outsEnd = outs.end();
currentNode->render();
for ( ; outsIt != outsEnd; ++outsIt )
{
currentIn = (*outsIt)->getInSlotPtr();
toQueueNode = currentIn->getPrivateFather();
if ((toQueueNode != this) && ( toQueueNode->wasItVisited() == false ))
{
toQueueNode->setVisited();
nodeQueue.enqueue( toQueueNode );
}
}
}
}
示例8: addMusics
void MyPlayer::addMusics(QString name, QQueue<MusicInfo> q)
{
MusicInfo musicInfo;
while (!q.empty())
{
musicInfo = q.front();
q.pop_front();
list[name].push_back(QUrl::fromLocalFile(musicInfo.getDir()));
}
}
示例9: 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;
}
示例10: LevelOrder
void AVLTree::LevelOrder()
{
QSequentialAnimationGroup *group = new QSequentialAnimationGroup;
QQueue<TreeNode*> q;
q.push_back(root);
while (!q.empty())
{
TreeNode *node = q.front();
q.pop_front();
if (node == NULL) continue;
group->addAnimation(node->getPopAnim());
q.push_back(node->Lson);
q.push_back(node->Rson);
}
group->start(QAbstractAnimation::DeleteWhenStopped);
}
示例11: UpdateSubtreeExtents
void VisualSubtreeHighlighter::UpdateSubtreeExtents()
{
if(!m_node || !isVisible())
return;
prepareGeometryChange();
QRectF bb = m_node->boundingRect();
float xMin = bb.left() + m_node->x();
float xMax = bb.right() + m_node->x();
float yMin = bb.top() + m_node->y();
float yMax = bb.bottom() + m_node->y();
QQueue<VisualNode*> queue;
queue.enqueue(m_node);
while(!queue.empty())
{
VisualNode* node = queue.dequeue();
if(node->IsCollapsed() || node->IsLeaf())
{
QRectF bb = node->boundingRect();
if(bb.left() + node->x() < xMin)
xMin = bb.left() + node->x();
if(bb.right() + node->x() > xMax)
xMax = bb.right() + node->x();
if(bb.top() + node->y() < yMin)
yMin = bb.top() + node->y();
if(bb.bottom() + node->y() > yMax)
yMax = bb.bottom() + node->y();
}
else // not collapsed and not a leaf node
{
foreach(VisualNode* child, node->GetChildren())
queue.enqueue(child);
}
}
m_extents = QRectF(xMin - HIGHLIGHTER_OFFSET, yMin - HIGHLIGHTER_OFFSET, (xMax-xMin) + 2*HIGHLIGHTER_OFFSET, (yMax-yMin) + 2*HIGHLIGHTER_OFFSET);
update();
}
示例12: run
void BleEncoderThread::run()
{
BleImageProcessThread * imageProcessThread = dynamic_cast<BleImageProcessThread *> (m_imageProcessThread);
BleAssert(imageProcessThread);
while (!m_stop) {
QQueue<BleImage*> images = BleAVContext::instance()->captureThread->getQueue();
// if can't get image, then sleep 50 ms.
if (images.isEmpty()) {
msleep(5);
continue;
}
while (!images.empty()) {
BleImage * image = images.dequeue();
BleAutoFree(BleImage, image);
if (image->dataSize <= 0) continue;
IplImage* imgYUV = cvCreateImage(cvSize(image->width, image->height * 3 / 2), IPL_DEPTH_8U, 1);
IplImage *cvImage = cvCreateImageHeader(cvSize(image->width, image->height), IPL_DEPTH_8U, 3);
cvImage->imageData = image->data;
cvImage->imageDataOrigin = image->data;
cvCvtColor(cvImage, imgYUV, CV_BGR2YUV_I420);
m_x264Encoder->encode((uchar*)imgYUV->imageData, image->pts, image->opaque);
cvReleaseImageHeader(&cvImage);
cvReleaseImage(&imgYUV);
if (m_stop) break;
}
// do clean
for (int i = 0; i > images.size(); ++i) {
BleImage *img = images.at(i);
BleFree(img);
}
}
log_trace("BleEncoderThread exit normally.");
}
示例13: 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();
}
示例14: readData
void MusicWindow::readData()
{
if (!Data::connectData()) return;
this->setBackgroud(Data::getCurrentBackground());
this->bottomBar->setPlayMode(Data::getPlayMode());
this->bottomBar->setSoundLevel(Data::getSoundLevel());
QQueue <QString> qq = Data::getListList();
QString listName;
QQueue <MusicInfo> q;
while (!qq.empty())
{
listName = qq.front();
qq.pop_front();
musicPage->createList(listName);
q = Data::getMusicList(listName);
musicPage->addMusics(Data::getListId(listName), q);
player->addMusics(listName, q);
}
musicPage->setCurrentList(0);
}
示例15: addChildren
void DockWidget::addChildren(QObject *object)
{
if (!object->isWidgetType())
{
return;
}
QQueue<QObject*> install;
install.push_back(object);
while (!install.empty())
{
object = install.front();
install.pop_front();
object->installEventFilter(this);
for (auto &i : object->children())
{
if (i->isWidgetType())
{
install.push_back(i);
}
}
}
}