示例#1
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QLinkedList<QString> linkList;
    linkList.append("Bangaluru");
    linkList.append("Mumbai");
    linkList.append("Delhi");
    linkList.append("Gandhinagara");

    qDebug() << "1-Number of Items =" << linkList.count();

    QLinkedList<QString>::iterator j = qFind(linkList.begin(),linkList.end(),"Varanasi");
    linkList.insert(j,"Bhopal");

    QLinkedList<QString>::iterator i;
    for (i = linkList.begin(); i != linkList.end(); ++i)
         qDebug() << *i << endl;

    qDebug() << "2-Number of Items =" << linkList.count();

    return a.exec();
}
void SendDataThread::run()
{
	while(true)
	{
		QMutexLocker locker(&m_DataMutex);
		m_DataCondition.wait(&m_DataMutex);

		int count = m_DataList.count();
		for(int i = 0; i < count; ++i)
		{
			const QByteArray& data = m_DataList.first();
			if(!::sendData(m_Socket, data.data(), data.size()))
			{
				qDebug()<<"Send data to server error";
				return;
			}
			m_DataList.pop_front();
		}
	}
}
示例#3
0
文件: layer.cpp 项目: V17nika/QGIS
void Layer::joinConnectedFeatures()
{
  // go through all label texts
  int connectedFeaturesId = 0;
  Q_FOREACH ( const QString& labelText, mConnectedTexts )
  {
    if ( !mConnectedHashtable.contains( labelText ) )
      continue; // shouldn't happen

    connectedFeaturesId++;

    QLinkedList<FeaturePart*>* parts = mConnectedHashtable.value( labelText );

    // go one-by-one part, try to merge
    while ( !parts->isEmpty() && parts->count() > 1 )
    {
      // part we'll be checking against other in this round
      FeaturePart* partCheck = parts->takeFirst();

      FeaturePart* otherPart = _findConnectedPart( partCheck, parts );
      if ( otherPart )
      {
        // remove partCheck from r-tree
        double checkpartBMin[2], checkpartBMax[2];
        partCheck->getBoundingBox( checkpartBMin, checkpartBMax );

        double otherPartBMin[2], otherPartBMax[2];
        otherPart->getBoundingBox( otherPartBMin, otherPartBMax );

        // merge points from partCheck to p->item
        if ( otherPart->mergeWithFeaturePart( partCheck ) )
        {
          // remove the parts we are joining from the index
          mFeatureIndex->Remove( checkpartBMin, checkpartBMax, partCheck );
          mFeatureIndex->Remove( otherPartBMin, otherPartBMax, otherPart );

          // reinsert merged line to r-tree (probably not needed)
          otherPart->getBoundingBox( otherPartBMin, otherPartBMax );
          mFeatureIndex->Insert( otherPartBMin, otherPartBMax, otherPart );

          mConnectedFeaturesIds.insert( partCheck->featureId(), connectedFeaturesId );
          mConnectedFeaturesIds.insert( otherPart->featureId(), connectedFeaturesId );

          mFeatureParts.removeOne( partCheck );
          delete partCheck;
        }
      }
    }

    // we're done processing feature parts with this particular label text
    delete parts;
    mConnectedHashtable.remove( labelText );
  }

  // we're done processing connected features

  //should be empty, but clear to be safe
  qDeleteAll( mConnectedHashtable );
  mConnectedHashtable.clear();

  mConnectedTexts.clear();
}
void CmdCreateTransition::undo() {
	QLinkedList<Item*> items = mPetriNet->removeItem(mId);
	Q_ASSERT(items.count() == 1);
	qDeleteAll(items);
}