void QgsComposition::sortZList() { if ( mItemZList.size() < 2 ) { return; } QLinkedList<QgsComposerItem*>::const_iterator lIt = mItemZList.constBegin(); QLinkedList<QgsComposerItem*> sortedList; for ( ; lIt != mItemZList.constEnd(); ++lIt ) { QLinkedList<QgsComposerItem*>::iterator insertIt = sortedList.begin(); for ( ; insertIt != sortedList.end(); ++insertIt ) { if (( *lIt )->zValue() < ( *insertIt )->zValue() ) { break; } } sortedList.insert( insertIt, ( *lIt ) ); } mItemZList = sortedList; }
void modifyOrder(QLinkedList<BidOrAsk> &queue, BidOrAsk &bidOrAsk) { auto r = std::find(queue.begin(), queue.end(), bidOrAsk); if (r != queue.end()) { BidOrAsk original = *r; Q_ASSERT (original.id() == bidOrAsk.id()); if (original.price() != bidOrAsk.price() || original.volume() > bidOrAsk.volume()) { // remove and re-add to loose position queue.erase(r); original.setPrice(bidOrAsk.price()); original.setVolume(bidOrAsk.volume()); // since this simulation happens long past, // we can't use the current time. original.setTime(bidOrAsk.time()); original.setDate(bidOrAsk.date()); queue.insert(std::lower_bound(queue.begin(), queue.end(), bidOrAsk), bidOrAsk); } else { // if only the volume has decreased, it // doesn't loose its position. original.setVolume(bidOrAsk.volume()); } } }
int main () { QLinkedList<int> myints; cout << "0. size: " << (int) myints.size() << endl; assert(myints.size() == 0); for (int i=0; i<10; i++) myints.push_back(i); cout << "1. size: " << (int) myints.size() << endl; assert(myints.size() == 10); myints.insert (myints.begin(),10); cout << "2. size: " << (int) myints.size() << endl; assert(myints.size() == 11); myints.pop_back(); cout << "3. size: " << (int) myints.size() << endl; assert(myints.size() == 10); return 0; }
void DeviceVerifyPlanner::doNotVerifyBootBlock(QLinkedList<Device::MemoryRange>& verifyList) { Device::MemoryRange firstHalf; QLinkedList<Device::MemoryRange>::iterator it = verifyList.begin(); while(it != verifyList.end()) { // S E // S | E // S | E // S | | E // // | S E // S E | if(!((it->start <= device->startBootloader && it->end <= device->startBootloader) || (it->start >= device->endBootloader && it->end >= device->endBootloader))) { // This transaction would verify over bootloader memory, which may fail if // we haven't (or can't) read the device out. if(it->start == device->startBootloader && it->end == device->endBootloader) { it = verifyList.erase(it); continue; } if(it->start == device->startBootloader) { it->start = device->endBootloader; } else if(it->end == device->endBootloader) { it->end = device->startBootloader; } else { firstHalf.start = device->endBootloader; firstHalf.end = it->end; it->end = device->startBootloader; if(firstHalf.start < firstHalf.end) { verifyList.insert(it, firstHalf); } } } it++; } }
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(); }