void SeparateNodesExecutor::execute_server() { int count, id; *stream >>count; Data::Graph* currentGraph = Manager::GraphManager::getInstance()->getActiveGraph(); QMap<qlonglong, osg::ref_ptr<Data::Node> >* nodes = currentGraph -> getMetaNodes(); QLinkedList<osg::ref_ptr<Data::Node> >* selectedNodes = new QLinkedList<osg::ref_ptr<Data::Node> >(); for ( int i = 0; i < count; i++ ) { *stream >> id; if ( nodes->contains( id ) ) { selectedNodes->append( *nodes->find( id ) ); } } Server* server = Server::getInstance(); currentGraph->separateNodes( selectedNodes ); server->sendSeparateNodes( selectedNodes ); if ( ( ( QOSG::CoreWindow* )server->getCoreWindowReference() )->playing() ) { server->getLayoutThread()->play(); } return; }
qint64 SetSrcAction::skip(QLinkedList<Action*> &list, QLinkedList<Action*>::iterator &it) { bool metSD = false; qint64 skipCost = cost; delete this; it = list.erase(it); while (it != list.end() && (*it)->type() != ActionType::SetSrc) if ((*it)->type() == ActionType::SetDest) if (metSD) { --it; skipCost += (*it)->actionCost(); delete *it; it = list.erase(it); ++it; } else { metSD = true; ++it; } else { skipCost += (*it)->actionCost(); delete *it; it = list.erase(it); } return skipCost; }
int main () { QLinkedList<QString> list; list << "A" << "B" << "C" << "D" << "E" << "F"; assert(list.takeFirst() == "A"); assert(list.size() == 5); return 0; }
const QLinkedList< QPair<QVariant,QString> > NfcTarget::getContentList() { QLinkedList< QPair<QVariant,QString> > ll; for(int i=0;i<_targetContent.size();i++) { ll.append ( QPair<QVariant,QString> ( _targetContent.at(i)->getId(), _targetContent.at(i)->getType() ) ); } return ll; }
int main () { QLinkedList<QString> list; list << "sun" << "cloud" << "sun" << "rain"; list.removeAll("sun"); assert(list.size() == 2); // list: ["cloud", "rain"] return 0; }
int main () { QLinkedList<QString> list; list << "sun" << "cloud" << "sun" << "rain"; list.removeOne("sun"); assert(list.front() == "cloud"); // list: ["cloud", ,"sun", "rain"] return 0; }
QLinkedList<QED2KHandle> QED2KSession::getTransfers() const { std::vector<libed2k::transfer_handle> handles = m_session->get_transfers(); QLinkedList<QED2KHandle> transfers; for (std::vector<libed2k::transfer_handle>::iterator i = handles.begin(); i != handles.end(); ++i) transfers.push_back(QED2KHandle(*i)); return transfers; }
int main () { QLinkedList<QString> list; list.prepend("one"); list.prepend("two"); list.prepend("three"); assert(list.first() == "three"); // list: ["three", "two", "one"] return 0; }
int main () { QLinkedList<QString> list; list << "A" << "B" << "C" << "B" << "A"; assert(list.contains("B")); assert(list.contains("A")); assert(list.contains("C")); //assert(list.indexOf("X") == -1); // returns -1 return 0; }
bool QED2KSession::hasActiveTransfers() const { QLinkedList<QED2KHandle> torrents = getActiveTransfers(); QLinkedList<QED2KHandle>::iterator torrentIT; for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { const QED2KHandle h(*torrentIT); if (h.is_valid() && !h.is_seed() && !h.is_paused() ) return true; } return false; }
QStringList NfcTarget::getContentListStrings() { QStringList cl; QLinkedList< QPair<QVariant,QString> > ll = this->getContentList(); QLinkedList< QPair<QVariant,QString> >::iterator it; for ( it = ll.begin(); it!= ll.end(); ++it ) { cl << QString::number ( ( *it ).first.toInt() ) + QString ( ": " ) + ( *it ).second + QString ( "\n" ); } return cl; }
void Layer::joinConnectedFeatures() { // go through all label texts QString labelText; while ( !connectedTexts->isEmpty() ) { labelText = connectedTexts->takeFirst(); //std::cerr << "JOIN: " << labelText << std::endl; QHash< QString, QLinkedList<FeaturePart*>* >::const_iterator partsPtr = connectedHashtable->find( labelText ); if ( partsPtr == connectedHashtable->constEnd() ) continue; // shouldn't happen QLinkedList<FeaturePart*>* parts = *partsPtr; // go one-by-one part, try to merge while ( !parts->isEmpty() ) { // part we'll be checking against other in this round FeaturePart* partCheck = parts->takeFirst(); FeaturePart* otherPart = _findConnectedPart( partCheck, parts ); if ( otherPart ) { //std::cerr << "- connected " << partCheck << " with " << otherPart << std::endl; // remove partCheck from r-tree double bmin[2], bmax[2]; partCheck->getBoundingBox( bmin, bmax ); rtree->Remove( bmin, bmax, partCheck ); featureParts->removeOne( partCheck ); otherPart->getBoundingBox( bmin, bmax ); // merge points from partCheck to p->item if ( otherPart->mergeWithFeaturePart( partCheck ) ) { // reinsert p->item to r-tree (probably not needed) rtree->Remove( bmin, bmax, otherPart ); otherPart->getBoundingBox( bmin, bmax ); rtree->Insert( bmin, bmax, otherPart ); } } } // we're done processing feature parts with this particular label text delete parts; } // we're done processing connected fetures delete connectedHashtable; connectedHashtable = NULL; delete connectedTexts; connectedTexts = NULL; }
void write_grid_occupant_order(World* g, std::ostream& s) { QLinkedList<int> order; for (int i = 0; i < g->rows * g->cols; i++) { Occupant* occ = g->occupant_grid[i]; while (occ) { order.push_back(occ->id); occ = occ->next; } } s << order; }
int main () { int myints[] = {75,23,65,42,13}; QLinkedList<int> myQLinkedList (myints,myints+5); QLinkedList<int>::iterator it; it = myQLinkedList.end(); it--; assert(*it != 13); cout << endl; return 0; }
bool VaApiPostProcessor::process(const VideoFrame &in, QLinkedList<VideoFrame> &queue) { if (!d->pipeline) return false; auto surface = VaApiSurfacePool::getSurface(in.mpi()); if (!surface) return false; mp_image *out1 = nullptr, *out2 = nullptr; out1 = d->pipeline->render(in, d->setupDeint(in.mpi()->fields, true)); if (d->deint.doubler && d->deint.method != DeintMethod::None) out2 = d->pipeline->render(in, d->setupDeint(in.mpi()->fields, false)); if (out1) queue.push_back(VideoFrame(true, out1, nextPTS(), in.field() & ~VideoFrame::Interlaced)); if (out2) queue.push_back(VideoFrame(true, out2, nextPTS(), in.field() & ~VideoFrame::Interlaced)); return out1 || out2; }
/*! * Memory ranges used by the bootloader firmware are excluded from the verify list. * * If the Write Config option is disabled, the FLASH Erase Block containing config * words is excluded from the verify list. (only for devices that store config bits in * FLASH memory). */ void DeviceVerifyPlanner::planFlashVerify(QLinkedList<Device::MemoryRange>& verifyList, int start, int end) { Device::MemoryRange block; block.start = start; block.end = end; verifyList.clear(); verifyList.append(block); if(!writeConfig) { doNotVerifyConfigPage(verifyList); } doNotVerifyBootBlock(verifyList); }
void MainWindow::bubbleLine() { QLinkedList<QVector3D> ap; QVector<QVector3D> mp; linebs.setPoint(pt); linebs.toleranceFitting(15.0); linebs.bubbleCurves(mp); for(int k=0; k<mp.size(); k++) ap.push_back(mp[k]); this->glf->setPoint(ap); }
void PicasawebWindow::slotGetAlbumsListSucceeded() { if (m_talker && m_talker->m_albumsList) { QLinkedList <PicasaWebAlbum> *list = m_talker->m_albumsList; m_albumsListComboBox->clear(); QLinkedList<PicasaWebAlbum>::iterator it = list->begin(); int index = 0; while(it != list->end()) { PicasaWebAlbum pwa=*it; QString name = pwa.title; m_albumsListComboBox->insertItem(index++, name); it++; } } }
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++; } }
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()); } } }
void MainWindow::ordinaryLine() { QLinkedList<QVector3D> ap; // qDebug()<<"contour.size:"<<contour.size(); // for(int i=0; i<contour.size(); i++) // { QVector<QVector3D> mp; // qDebug()<<"contour size: "<<i<<contour[i].size(); linebs.setPoint(pt); linebs.toleranceFitting(15.0); qDebug()<<"contour size: "<<contour.size(); linebs.ordinaryCurves(mp); qDebug()<<"contour size: "<<mp.size(); for(int k=0; k<mp.size(); k++) ap.push_back(mp[k]); //} this->glf->setPoint(ap); }
void push(mp_image *mpi) { mpi->colorspace = in->format().colorspace(); mpi->levels = in->format().range(); mpi->display_w = in->format().displaySize().width(); mpi->display_h = in->format().displaySize().height(); mpi->pts = p->nextPTS(); queue->push_back(VideoFrame(true, mpi, in->field())); ++pushed; }
QLinkedList<Okular::ObjectRect*> DviGenerator::generateDviLinks( const dviPageInfo *pageInfo ) { QLinkedList<Okular::ObjectRect*> dviLinks; int pageWidth = pageInfo->width, pageHeight = pageInfo->height; foreach( const Hyperlink &dviLink, pageInfo->hyperLinkList ) { QRect boxArea = dviLink.box; double nl = (double)boxArea.left() / pageWidth, nt = (double)boxArea.top() / pageHeight, nr = (double)boxArea.right() / pageWidth, nb = (double)boxArea.bottom() / pageHeight; QString linkText = dviLink.linkText; if ( linkText.startsWith("#") ) linkText = linkText.mid( 1 ); Anchor anch = m_dviRenderer->findAnchor( linkText ); Okular::Action *okuLink = 0; /* distinguish between local (-> anchor) and remote links */ if (anch.isValid()) { /* internal link */ Okular::DocumentViewport vp; fillViewportFromAnchor( vp, anch, pageWidth, pageHeight ); okuLink = new Okular::GotoAction( "", vp ); } else { okuLink = new Okular::BrowseAction( dviLink.linkText ); } if ( okuLink ) { Okular::ObjectRect *orlink = new Okular::ObjectRect( nl, nt, nr, nb, false, Okular::ObjectRect::Action, okuLink ); dviLinks.push_front( orlink ); } } return dviLinks; }
QLinkedList<const GEOSGeometry *>* pal::Util::unmulti( const GEOSGeometry *the_geom ) { QLinkedList<const GEOSGeometry*> *queue = new QLinkedList<const GEOSGeometry*>; QLinkedList<const GEOSGeometry*> *final_queue = new QLinkedList<const GEOSGeometry*>; const GEOSGeometry *geom; queue->append( the_geom ); int nGeom; int i; GEOSContextHandle_t geosctxt = geosContext(); while ( !queue->isEmpty() ) { geom = queue->takeFirst(); int type = GEOSGeomTypeId_r( geosctxt, geom ); switch ( type ) { case GEOS_MULTIPOINT: case GEOS_MULTILINESTRING: case GEOS_MULTIPOLYGON: nGeom = GEOSGetNumGeometries_r( geosctxt, geom ); for ( i = 0; i < nGeom; i++ ) { queue->append( GEOSGetGeometryN_r( geosctxt, geom, i ) ); } break; case GEOS_POINT: case GEOS_LINESTRING: case GEOS_POLYGON: final_queue->append( geom ); break; default: QgsDebugMsg( QString( "unexpected geometry type:%1" ).arg( type ) ); delete final_queue; delete queue; return nullptr; } } delete queue; return final_queue; }
QLinkedList<Interval> rootDividing(double start, double end, double eps) { QLinkedList<Interval> result; if (start >= end) { return result; } double x1 = start; double x2 = start + eps < end ? start + eps : end; while (x2 <= end) { if (FuncClass::func(x1) * FuncClass::func(x2) < 0) result.push_back(Interval(x1, x2)); x1 = x2; x2 += eps; } return result; }
//static QLinkedList<QFileInfo> CoverArtUtils::findPossibleCoversInFolder(const QString& folder) { // Search for image files in the track directory. QRegExp coverArtFilenames(supportedCoverArtExtensionsRegex(), Qt::CaseInsensitive); QDirIterator it(folder, QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); QFile currentFile; QFileInfo currentFileInfo; QLinkedList<QFileInfo> possibleCovers; while (it.hasNext()) { it.next(); currentFileInfo = it.fileInfo(); if (currentFileInfo.isFile() && coverArtFilenames.indexIn(currentFileInfo.fileName()) != -1) { possibleCovers.append(currentFileInfo); } } return possibleCovers; }
void Odf::saveConditions(const Conditions *conditions, KoGenStyle ¤tCellStyle, ValueConverter *converter) { //todo fix me with kspread old format!!! if (conditions->isEmpty()) return; QLinkedList<Conditional> list = conditions->conditionList(); QLinkedList<Conditional>::const_iterator it; int i = 0; for (it = list.begin(); it != list.end(); ++it, ++i) { Conditional conditional = *it; //<style:map style:condition="cell-content()=45" style:apply-style-name="Default" style:base-cell-address="Sheet1.E10"/> QMap<QString, QString> map; map.insert("style:condition", saveConditionValue(conditional, converter)); map.insert("style:apply-style-name", conditional.styleName); if (!conditional.baseCellAddress.isEmpty()) map.insert("style:base-cell-address", conditional.baseCellAddress); currentCellStyle.addStyleMap(map); } }
void PluckerGenerator::generatePixmap( Okular::PixmapRequest * request ) { const QSizeF size = mPages[ request->pageNumber() ]->size(); QPixmap *pixmap = new QPixmap( request->width(), request->height() ); pixmap->fill( Qt::white ); QPainter p; p.begin( pixmap ); qreal width = request->width(); qreal height = request->height(); p.scale( width / (qreal)size.width(), height / (qreal)size.height() ); mPages[ request->pageNumber() ]->drawContents( &p ); p.end(); request->page()->setPixmap( request->id(), pixmap ); if ( !mLinkAdded.contains( request->pageNumber() ) ) { QLinkedList<Okular::ObjectRect*> objects; for ( int i = 0; i < mLinks.count(); ++i ) { if ( mLinks[ i ].page == request->pageNumber() ) { QTextDocument *document = mPages[ request->pageNumber() ]; QRectF rect; calculateBoundingRect( document, mLinks[ i ].start, mLinks[ i ].end, rect ); objects.append( new Okular::ObjectRect( rect.left(), rect.top(), rect.right(), rect.bottom(), false, Okular::ObjectRect::Action, mLinks[ i ].link ) ); } } if ( !objects.isEmpty() ) request->page()->setObjectRects( objects ); mLinkAdded.insert( request->pageNumber() ); } signalPixmapRequestDone( request ); }
void AssignLayers::run(Graph &graph) { emit setStatusMsg("Assigning layers..."); // copy the nodes to a linked list QLinkedList<AbstractNode*> vertices; for(AbstractNode* v : graph.getNodes()) { vertices.append(v); } QSet<AbstractNode*> U; QSet<AbstractNode*> Z; QList<QList<AbstractNode*>> layers; //add the first layer int currentLayer = 0; layers.append(QList<AbstractNode*>()); while(!vertices.isEmpty()) { AbstractNode* selected = nullptr; for(AbstractNode* v : vertices) { if(Z.contains(v->getPredecessors().toSet())) { selected = v; break; } } if(selected != nullptr) { selected->setLayer(currentLayer); layers.last().append(selected); U.insert(selected); vertices.removeOne(selected); } else { currentLayer++; layers.append(QList<AbstractNode*>()); Z.unite(U); } } graph.setLayers(layers); graph.repaintLayers(); emit setStatusMsg("Assigning layers... Done!"); }
void MainWindow::reloadDeviceList(const char *cmddevice) { int dev = -1; QLinkedList<DeviceItem *> list = pPlatform->getDeviceList(); QLinkedList<DeviceItem *>::iterator i; for (i = list.begin(); i != list.end(); ++i) { if (!(*i)->getPath().isEmpty()) if (deviceComboBox->findText((*i)->getDisplayString()) == -1) addMenuItem((*i)->getDisplayString()); if (cmddevice != NULL) if ((*i)->getPath().compare(cmddevice) == 0) dev = deviceComboBox->findText((*i)->getDisplayString(), 0); } if (dev != -1) deviceComboBox->setCurrentIndex(dev); }