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


C++ QQueue::clear方法代码示例

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


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

示例1: 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;
}
开发者ID:kimmoli,项目名称:SailCast,代码行数:59,代码来源:screenprovider.cpp

示例2: 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);
}
开发者ID:almikh,项目名称:progressive-cut,代码行数:28,代码来源:graph.cpp

示例3: operator

bool TreeEnumerate::operator ()()
{
    QQueue<letter_node *> queue;
    queue.clear();

    filled_details=false;
    queue.enqueue((letter_node*)Tree->getFirstNode());
    bool stop=false;
    while ((!queue.isEmpty())  && !stop) {
        node * current_node=NULL;
        current_node=queue.dequeue();
        addLetterToQueue(queue,current_node);

        QList<result_node *>* current_result_children=current_node->getResultChildren();
        int num_children=current_result_children->count();
        for (int j=0;j<num_children;j++) {
            result_node *current_child=current_result_children->at(j);
            reached_node=current_child;
            resulting_category_idOFCurrentMatch=((result_node *)current_child)->get_resulting_category_id();
            bool isAccept=((result_node *)current_child)->is_accept_state();
            if ( isAccept && shouldcall_onmatch_ex() && !(on_match_helper())) {
                stop=true;
                break;
            } else {
                addLetterToQueue(queue,current_child);
            }
        }
    }
    return (!stop);
}
开发者ID:ZoeLeBlanc,项目名称:atmine,代码行数:30,代码来源:tree_enumerate.cpp

示例4: 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;
    }
}
开发者ID:dsc0003,项目名称:6DOFC,代码行数:59,代码来源:refinterface.cpp

示例5: setFrameBufferSize

void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) {
    //If the size changed, we need to delete our FBOs
    if (_frameBufferSize != frameBufferSize) {
        _frameBufferSize = frameBufferSize;
        _primaryFramebufferFull.reset();
        _primaryFramebufferDepthColor.reset();
        _primaryDepthTexture.reset();
        _primaryColorTexture.reset();
        _primaryNormalTexture.reset();
        _primarySpecularTexture.reset();
        _selfieFramebuffer.reset();
        _cachedFramebuffers.clear();
    }
}
开发者ID:samcake,项目名称:hifi,代码行数:14,代码来源:FramebufferCache.cpp

示例6: while

QSet<QPoint> RedEyeDetection::expandRedEye(const QImage &image,
					   const QPoint &center,
					   const QRect &area) const
{
    QSet<QPoint> visited, included;
    QQueue<QPoint> active;

    visited << center;
    included << center;

    active.enqueue(center);

    QPoint neighbors[8];

    while (!active.isEmpty()) {
	QPoint point = active.dequeue();

	neighbors[0] = point+QPoint(-1, -1);
	neighbors[1] = point+QPoint(0, -1);
	neighbors[2] = point+QPoint(+1, -1);
	neighbors[3] = point+QPoint(-1, 0);
	neighbors[4] = point+QPoint(+1, 0);
	neighbors[5] = point+QPoint(-1, +1);
	neighbors[6] = point+QPoint(0, +1);
	neighbors[7] = point+QPoint(+1, +1);

	for (int i=0; i<8; i++)
	{
	    if (!visited.contains(neighbors[i]))
	    {
		visited << neighbors[i];

		// Mark only red neighbors as active and included
		if (isRedEyePixel(image.pixel(neighbors[i]))) {
		    included << neighbors[i];
		    active.enqueue(neighbors[i]);

		    if (!area.contains(neighbors[i], true))
		    {
			included.clear();
			active.clear();
			break;
		    }

		}
	    }
	}
    }
    return included;
}
开发者ID:amtep,项目名称:quillimagefilters,代码行数:50,代码来源:redeyedetection.cpp

示例7: onDisconnected

// private slot triggered upon disconnection from the server
// - checks the cause of disconnection
// - aborts or continues processing
void QwwSmtpClientPrivate::onDisconnected() {
    setState(QwwSmtpClient::Disconnected);
    if (commandqueue.isEmpty()) {
        inProgress = false;
        emit q->done(true);
        return;
    }

    if (commandqueue.head().type == SMTPCommand::Disconnect) {
        inProgress = false;
        emit q->done(true);
        return;
    }

    emit q->commandFinished(commandqueue.head().id, true);
    commandqueue.clear();
    inProgress = false;
    emit q->done(false);
}
开发者ID:invalid404,项目名称:trojita,代码行数:22,代码来源:qwwsmtpclient.cpp

示例8: Solver

RefInterface::RefInterface()
{
    solver = new Solver();

    msg.clear();

    radioNum = 0;
    antennaNum = 0;
    count = 1;
    errorCountR0 = 0;
    errorCountR1 = 0;
    errorCountR2 = 0;
    errorCountR3 = 0;
    thresholdErrorCountR0 = 0;
    thresholdErrorCountR1 = 0;
    thresholdErrorCountR2 = 0;
    thresholdErrorCountR3 = 0;


    readConfigFile();

    //initialize radio (USB and dest address)
    if (rcmIfInit(rcmIfUsb, radioPort.data()) != OK)
    {
        qDebug()<<"Initialization failed";
        exit(0);
    }

    radioCom = radioFd;
    qDebug()<<"radioCom"<<radioCom;
    if (rcmIfInit(rcmIfUsb, radioPort1.data()) != OK)
    {
        qDebug()<<"Initialization failed";
        exit(0);
    }
    radioCom1 = radioFd;
    qDebug()<<"radioCom1"<<radioCom1;
    stopped = false;
}
开发者ID:dsc0003,项目名称:6DOFC,代码行数:39,代码来源:refinterface.cpp

示例9: dynUpdateTopolSort


//.........这里部分代码省略.........

	// The nodes of the affected region
	QList<ListDigraph::Node> ar = topolOrdering.mid(arbegin, arend - arbegin + 1);
	QList<bool> visited;
	visited.reserve(ar.size());
	QQueue<ListDigraph::Node> q;
	ListDigraph::Node curnode;
	ListDigraph::Node tmpnode;
	int tmpidx;
	//QList<int> deltaBIdx;

	// #####################  DEBUG  ###########################################

	/*
	out << "ar:" << endl;
	for (int l = 0; l < ar.size(); l++) {
		out << pm->ops[ar[l]]->ID << " ";
	}
	out << endl;
	 */

	// #########################################################################

	// Find nodes which are contained in ar and are reachable from arstartnode
	//out << "Finding deltaF..." << endl;
	QList<ListDigraph::Node> deltaF;

	deltaF.reserve(ar.size());

	for (int l = 0; l < ar.size(); l++) {
		visited.append(false);
	}

	q.clear();
	q.enqueue(arstartnode);

	deltaF.append(arstartnode);
	while (q.size() != 0) {
		curnode = q.dequeue();

		// Check the successors of the current node
		for (ListDigraph::OutArcIt oait(this->graph, curnode); oait != INVALID; ++oait) {
			tmpnode = this->graph.target(oait);

			tmpidx = ar.indexOf(tmpnode);

			if (tmpidx >= 0 && !visited[tmpidx]) { // This successor is within the affected region
				q.enqueue(tmpnode);
				visited[tmpidx] = true;

				// Add the node to the deltaF
				deltaF.append(tmpnode);

			}

		}
	}

	//out << "Found deltaF." << endl;

	//######################  DEBUG  ###########################################
	/*
	out << "deltaF:" << endl;
	for (int l = 0; l < deltaF.size(); l++) {
		out << pm->ops[deltaF[l]]->ID << " ";
	}
开发者ID:DrSobik,项目名称:IPPS,代码行数:67,代码来源:ProcessModel.cpp

示例10:

FramebufferCache::~FramebufferCache() {
    _cachedFramebuffers.clear();
}
开发者ID:samcake,项目名称:hifi,代码行数:3,代码来源:FramebufferCache.cpp

示例11: enqueuePackets

void ChildFFMpegLoader::enqueuePackets(QQueue<FFMpeg::AVPacketDataWrap> &packets) {
	_queue += std_::move(packets);
	packets.clear();
}
开发者ID:banditkroot,项目名称:tdesktop,代码行数:4,代码来源:media_child_ffmpeg_loader.cpp

示例12: operator

bool TreeSearch::operator()() {
    QQueue<letter_node *> queue;
    QQueue<letter_node *> queue_emptyCharacters;
    queue.clear();
    filled_details = false;
    queue.enqueue((letter_node *)Tree->getFirstNode());
    bool stop = false;
    int nodes_per_level = 1;
    bool wait_for_dequeue = false;
    position = info.start;

    while ((!queue.isEmpty() || !queue_emptyCharacters.isEmpty())  && !stop) {
        node *current_node = NULL;

        if (wait_for_dequeue) {
            if (!queue_emptyCharacters.isEmpty()) {
                current_node = queue_emptyCharacters.dequeue();
            } else {
                wait_for_dequeue = false;
                position++;
            }
        }

        if (current_node == NULL) {
            current_node = queue.dequeue();
            nodes_per_level--;

            if (nodes_per_level == 0) {
                wait_for_dequeue = true;
                nodes_per_level = queue.count();
            }
        }

        QChar future_letter;

        if (position == info.text->length()) {
            future_letter = '\0';
        } else if (position > info.text->length()) {
            future_letter = '\0';
            position = info.text->length();
            //break;
        } else {
            future_letter = info.text->at(position);

            while (position < info.text->length() && isDiacritic(future_letter)) {
                position++;

                if (position == info.text->length()) {
                    future_letter = '\0';
                } else {
                    future_letter = info.text->at(position);
                }
            }
        }

        bool added_to_main_queue = addLetterToQueue(queue, queue_emptyCharacters, current_node, future_letter);

        if (added_to_main_queue && wait_for_dequeue) {
            nodes_per_level++;
        }

        QList<result_node *> *current_result_children = current_node->getResultChildren();
        int num_children = current_result_children->count();

        for (int j = 0; j < num_children; j++) {
            result_node *current_child = current_result_children->at(j);
            reached_node = current_child;
            resulting_category_idOFCurrentMatch = ((result_node *)current_child)->get_resulting_category_id();
            bool isAccept = ((result_node *)current_child)->is_accept_state();

            if (isAccept && shouldcall_onmatch_ex(position) &&
                !(on_match_helper())) {
                stop = true;
                break;
            } else {
                bool added_to_main_queue = addLetterToQueue(queue, queue_emptyCharacters, current_child, future_letter);

                if (added_to_main_queue && wait_for_dequeue) {
                    nodes_per_level++;
                }
            }
        }
    }

    return (!stop);
}
开发者ID:tanab,项目名称:atmine,代码行数:86,代码来源:tree_search.cpp

示例13: convertTable

bool Converter::convertTable(const QDomElement &element)
{
    /**
     * Find out dimension of the table
     */

    int rowCounter = 0;
    int columnCounter = 0;

    QQueue<QDomNode> nodeQueue;
    enqueueNodeList(nodeQueue, element.childNodes());
    while (!nodeQueue.isEmpty())
    {
        QDomElement el = nodeQueue.dequeue().toElement();
        if (el.isNull())
            continue;

        if (el.tagName() == QLatin1String("table-row"))
        {
            rowCounter++;

            int counter = 0;
            QDomElement columnElement = el.firstChildElement();
            while (!columnElement.isNull())
            {
                if (columnElement.tagName() == QLatin1String("table-cell"))
                {
                    counter++;
                }
                columnElement = columnElement.nextSiblingElement();
            }

            columnCounter = qMax(columnCounter, counter);
        }
        else if (el.tagName() == QLatin1String("table-header-rows"))
        {
            enqueueNodeList(nodeQueue, el.childNodes());
        }
    }

    /**
     * Create table
     */
    QTextTable *table = m_Cursor->insertTable(rowCounter, columnCounter);
    firstTime=false;
    m_Cursor->movePosition(QTextCursor::End);

    /**
     * Fill table
     */
    nodeQueue.clear();
    enqueueNodeList(nodeQueue, element.childNodes());

    QTextTableFormat tableFormat;

    rowCounter = 0;
    while (!nodeQueue.isEmpty())
    {
        QDomElement el = nodeQueue.dequeue().toElement();
        if (el.isNull())
            continue;

        if (el.tagName() == QLatin1String("table-row"))
        {
            int columnCounter = 0;
            QDomElement columnElement = el.firstChildElement();
            while (!columnElement.isNull())
            {
                if (columnElement.tagName() == QLatin1String("table-cell"))
                {
                    const StyleFormatProperty property = m_StyleInformation->styleProperty(columnElement.attribute("style-name"));

                    QTextBlockFormat format;
                    property.applyTableCell(&format);

                    QDomElement paragraphElement = columnElement.firstChildElement();
                    while (!paragraphElement.isNull())
                    {
                        if (paragraphElement.tagName() == QLatin1String("p"))
                        {
                            QTextTableCell cell = table->cellAt(rowCounter, columnCounter);
                            // Insert a frame into the cell and work on that, so we can handle
                            // different parts of the cell having different block formatting
                            QTextCursor cellCursor = cell.lastCursorPosition();
                            QTextFrameFormat frameFormat;
                            //frameFormat.setMargin(1); // TODO: this shouldn't be hard coded
                            //todo: too much is created here - why?
                            QTextFrame *frame = cellCursor.insertFrame(frameFormat);
                            QTextCursor frameCursor = frame->firstCursorPosition();
                            frameCursor.setBlockFormat(format);

                            if (!convertParagraph(&frameCursor, paragraphElement, format))
                                return false;
                        }
                        else if (paragraphElement.tagName() == QLatin1String("list"))
                        {
                            QTextTableCell cell = table->cellAt(rowCounter, columnCounter);
                            // insert a list into the cell
                            QTextCursor cellCursor = cell.lastCursorPosition();
                            if (!convertList(&cellCursor, paragraphElement))
//.........这里部分代码省略.........
开发者ID:madnight,项目名称:chessx,代码行数:101,代码来源:converter.cpp

示例14: on_Machine

/*Write paskage to TOO*/
void ftdiChip::on_Machine()
{
static QQueue<QByteArray> templistCMD;
static quint16 retAnswer;
static int CurrentValue,ValueMax;
switch(stat)
    {
    case stOpen:
        if(!listCMD.isEmpty()){
            if(Open()==retOk){
                stat=stCounter;
                disconnect(this,SIGNAL(signalStart()),this,SIGNAL(signalStep()));
                setParametersUSB(parameter.retSpeed(),parameter.retDataBit(),parameter.retStopBit(),parameter.retParity());
                timerRead->setInterval(parameter.retTimeDelay());
                templistCMD = listCMD;
                CurrentValue = 0;
                ValueMax = 3*templistCMD.count();
                emit signalProgressRange(0,ValueMax);
                emit signalStep();
                }else {
                emit signalMessageError(tr("<CENTER><b>Not found KIT USN_RS485!</CENTER></b>"));
                emit signalStop();
                }
            }
        listCMD.clear();
        return;
    case stCounter:
        if(!templistCMD.isEmpty()){
            emit signalProgressValue(++CurrentValue,true);
            stat=stWrite;
            }else{
            stat=stClose;
            }
        emit signalStep();
        return;
    case stWrite:
        {
        QByteArray cmd(templistCMD.dequeue());//long Time;
        quint16 result = Bit8Write(cmd,1);
        emit signalSendMessage(false,cmd,Qt::green);
        if(result!=retOk){
            templistCMD.clear();stat=stCounter;emit signalStep();}
        stat=stRead;
        timerRead->start();
        emit signalProgressValue(++CurrentValue,true);
        }
        return;
    case stRead:
        {
        QByteArray resBuff;
        quint16 retRead =Read(resBuff);
        emit signalSendMessage(true,resBuff,Qt::darkBlue);
        retAnswer = CheckingReceivedPacket(resBuff);
        if(retAnswer&ANWR_PROTOCOL::retGet){
          return; // next package
          }
        if((retAnswer&(~(ANWR_PROTOCOL::retOK)))
             &&
           (retRead&(ftdiChip::retErr|ftdiChip::retBusyDevice))){// stop sending
          templistCMD.clear();
          }
        stat=stCounter;
        timerRead->stop();
        emit signalProgressValue(++CurrentValue,true);
        emit signalStep();
        }
        return;
    case stClose:
        Close();
        connect(this,SIGNAL(signalStart()),this,SIGNAL(signalStep()),Qt::DirectConnection);
    default:
        emit signalEnd(true);
        stat = stOpen;
        timerRead->stop();
        emit signalProgressValue(0,false);
        if(retAnswer&(ANWR_PROTOCOL::retOK)) // it is not error
          emit signalStatusOk(tr("Data is written successfully!"));
        if(retAnswer&ANWR_PROTOCOL::retError) // it is error
          emit signalStatusError(tr("Error response!"),false);
        if(retAnswer&ANWR_PROTOCOL::retNoAnsError) // it is error
          emit signalStatusError(tr("Device does not answer!"),false);
        if(retAnswer&ANWR_PROTOCOL::retIncorData)
          emit signalStatusError(tr("Data is incorrect!"),false);
        emit signalStep();
        return;        
  }
}
开发者ID:tuzhikov,项目名称:testCountDown,代码行数:88,代码来源:ftdichip.cpp

示例15:

GuiInterface::GuiInterface()
{
    //clear msg queue in constructor
    msg.clear();
    stoppedConsumer = false;
}
开发者ID:dsc0003,项目名称:6DOFC,代码行数:6,代码来源:refinterface.cpp


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