本文整理汇总了C++中QQueue::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QQueue::count方法的具体用法?C++ QQueue::count怎么用?C++ QQueue::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQueue
的用法示例。
在下文中一共展示了QQueue::count方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printQueue
void AbstractLexer::printQueue(const QQueue<TOKEN>& q) const
{
QStringList res;
foreach(const TOKEN& t, q)
{
if(m_longOperators.values().contains(t.type)) res += m_longOperators.key(t.type);
else if(m_operators.values().contains(t.type)) res += m_operators.key(t.type);
else res+= (t.val + ';' + QString::number(t.type) + error());
}
qDebug() << q.count() << ":::" << "(" << res.join(QStringLiteral("|")) << ")";
}
示例2: isBusy
bool SBusController::isBusy( const QString & bus )
{
const QStringList & keys = active_buses->keys();
if( keys.contains(bus) )
return true;
if( !queued_buses->contains(bus) )
return false;
QQueue<SBusController*> *list = queued_buses->value(bus);
for( int i=0 ; i<list->count() ; i++ )
if( !list->at(i)->passUpAndWait() )
return true;
return false;
}
示例3: finish
void SBusController::finish( const QString & bus )
{
if( bus.isEmpty() )
return;
SBusController *core = (*active_buses)[bus];
if( core != this )
{
qCritical() << QString("SBusController::finish : This SBusController Object can't remove \"%1\" from SBusController.").arg(bus);
return ;
}
active_buses->remove(bus);
/*! ---------- Dequeue first not pass up process ------------ */
SBusController *item = 0;
if( !queued_buses->contains(bus) )
return;
QQueue<SBusController*> *queue = queued_buses->value(bus);
if( queue == 0 )
return;
for( int i=0 ; i<queue->count() ; i++ )
{
if( !queue->at(i)->passUpAndWait() )
{
item = queue->takeAt( i );
break;
}
}
if( item == 0 )
return;
/*! --------------------------------------------------------- */
if( queued_buses->value(bus)->isEmpty() )
delete queued_buses->take( bus );
active_buses->insert( bus , item );
emit item->go();
}
示例4: 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);
}
示例5: 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;
}
}
示例6: setPassUpAndWait
void SBusController::setPassUpAndWait( bool state )
{
if( p->pass_up_and_wait == state )
return;
p->pass_up_and_wait = state;
if( state )
{
/*! ----------------- Find Active Buses ---------------- */
QStringList keys = active_buses->keys();
for( int i=0 ; i<keys.count() ; i++ )
{
const QString & bus = keys.at(i);
if( !active_buses->contains(bus) )
continue;
SBusController *controller = active_buses->value( bus );
if( controller == this )
{
finish( bus );
getAccess( bus );
}
}
}
else
{
/*! ----------------- Find Disabled Buses ---------------- */
QStringList keys = queued_buses->keys();
for( int i=0 ; i<keys.count() ; i++ )
{
const QString & bus = keys.at(i);
if( active_buses->contains(bus) )
continue;
/*! ---------- Find First Deactived Processes to Active --------- */
if( !queued_buses->contains(bus) )
continue;
QQueue<SBusController*> *queue = queued_buses->value(bus);
if( queue == 0 )
continue;
for( int j=0 ; j<queue->count() ; j++ )
{
if( queue->at(j) != this )
continue;
queue->removeAt( j );
if( queue->isEmpty() )
delete queued_buses->take( bus );
active_buses->insert( bus , this );
emit go();
break;
}
}
}
}