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


C++ QList::reserve方法代码示例

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


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

示例1: loadSurveyChunk

/**
 * @brief cwRegionLoadTask::loadSurveyChunk
 * @param protoChunk
 * @param chunk
 */
void cwRegionLoadTask::loadSurveyChunk(const CavewhereProto::SurveyChunk& protoChunk, cwSurveyChunk *chunk)
{
    QList<cwStation> stations;
    stations.reserve(protoChunk.stations_size());
    for(int i = 0 ; i < protoChunk.stations_size(); i++) {
        cwStation station = loadStation(protoChunk.stations(i));
        stations.append(station);
    }

    QList<cwShot> shots;
    shots.reserve(protoChunk.shots_size());
    for(int i = 0; i < protoChunk.shots_size(); i++) {
        cwShot shot = loadShot(protoChunk.shots(i));
        shots.append(shot);
    }

    if(stations.count() - 1 != shots.count()) {
        qDebug() << "Shot, station count mismatch, survey chunk invalid:" << stations.count() << shots.count();
        return;
    }

    for(int i = 0; i < stations.count() - 1; i++) {
        cwStation fromStation = stations[i];
        cwStation toStation = stations[i + 1];
        cwShot shot = shots[i];

        chunk->appendShot(fromStation, toStation, shot);
    }
}
开发者ID:Cavewhere,项目名称:cavewhere,代码行数:34,代码来源:cwRegionLoadTask.cpp

示例2: loadScrap

/**
 * @brief cwRegionLoadTask::loadScrap
 * @param protoScrap
 * @param scrap
 */
void cwRegionLoadTask::loadScrap(const CavewhereProto::Scrap& protoScrap, cwScrap *scrap)
{
    QVector<QPointF> outlinePoint;
    outlinePoint.resize(protoScrap.outlinepoints_size());
    for(int i = 0; i < protoScrap.outlinepoints_size(); i++) {
        outlinePoint[i] = loadPointF(protoScrap.outlinepoints(i));
    }
    scrap->setPoints(outlinePoint);

    QList<cwNoteStation> stations;
    stations.reserve(protoScrap.notestations_size());
    for(int i = 0; i < protoScrap.notestations_size(); i++) {
        stations.append(loadNoteStation(protoScrap.notestations(i)));
    }
    scrap->setStations(stations);

    QList<cwLead> leads;
    leads.reserve(protoScrap.leads_size());
    for(int i = 0; i < protoScrap.leads_size(); i++) {
        leads.append(loadLead(protoScrap.leads(i)));
    }
    scrap->setLeads(leads);

    loadNoteTranformation(protoScrap.notetransformation(), scrap->noteTransformation());
    scrap->setCalculateNoteTransform(protoScrap.calculatenotetransform());
    scrap->setTriangulationData(loadTriangulatedData(protoScrap.triangledata()));
    scrap->setType((cwScrap::ScrapType)protoScrap.type());
}
开发者ID:Cavewhere,项目名称:cavewhere,代码行数:33,代码来源:cwRegionLoadTask.cpp

示例3: separableFilter

void Document::separableFilter(const QVector<qreal> &filter)
{
    if (std::min(m_selection.height(), m_selection.width()) < filter.size()) {
        qWarning() << "Too large filter!";
    }
    if (filter.size() < 2) {
        qWarning() << "Filter size must be at least 2";
    }
    qDebug() << "separableFilter(" << filter << ")";

    int n = filter.size() - 1;

    QList<ConcurrentLinearFilter> jobs;
    jobs.reserve(m_selection.height());
    for (int line = m_selection.top(); line <= m_selection.bottom(); ++line) {
        QVector<QRgb> head(n);
        for (int i = 0; i < n; ++i)
            head[i] = m_image.pixel(abs(m_selection.x() - n + i), line);

        QVector<QRgb> tail(n);
        for (int i = 0; i < n; ++i) {
            int x = m_selection.right() + 1 + i;
            if (x >= m_image.width())
                x = 2 * m_image.width() - x - 1;
            tail[i] = m_image.pixel(x, line);
        }

        jobs.append(ConcurrentLinearFilter(filter, head, tail, m_selection.width(), sizeof(QRgb),
                                           m_image.scanLine(line) + m_selection.left() * sizeof(QRgb)));
    }
    QtConcurrent::blockingMap(jobs, ConcurrentLinearFilter::process);

    jobs.clear();
    jobs.reserve(m_selection.width());
    for (int column = m_selection.left(); column <= m_selection.right(); ++column) {
        QVector<QRgb> head(n);
        for (int i = 0; i < n; ++i)
            head[i] = m_image.pixel(column, abs(m_selection.top() - n + i));

        QVector<QRgb> tail(n);
        for (int i = 0; i < n; ++i) {
            int y = m_selection.bottom() + 1 + i;
            if (y >= m_image.height())
                y = 2 * m_image.height() - y - 1;
            tail[i] = m_image.pixel(column, y);
        }

        jobs.append(ConcurrentLinearFilter(filter, head, tail, m_selection.height(), m_image.bytesPerLine(),
                                           m_image.scanLine(m_selection.top()) + column * sizeof(QRgb)));
    }
    QtConcurrent::blockingMap(jobs, ConcurrentLinearFilter::process);

    setModified(true);
    emit repaint(m_selection);
}
开发者ID:govorovsky,项目名称:cmc-eye,代码行数:55,代码来源:document.cpp

示例4: mapToReversedLists

//! populate two lists (ks, vs) from map - in reverse order
template <class Key, class T> void mapToReversedLists( const QMap< Key, T >& map, QList<Key>& ks, QList<T>& vs )
{
  ks.reserve( map.size() );
  vs.reserve( map.size() );
  typename QMap<Key, T>::const_iterator i = map.constEnd();
  while ( i-- != map.constBegin() )
  {
    ks.append( i.key() );
    vs.append( i.value() );
  }
}
开发者ID:Benardi-atmadja,项目名称:QGIS,代码行数:12,代码来源:qgsvectorlayereditbuffer.cpp

示例5: exportContacts

QString SeasideCache::exportContacts()
{
    QVersitContactExporter exporter;

    QList<QContact> contacts;
    contacts.reserve(instance->m_people.count());

    QList<QContactLocalId> contactsToFetch;
    contactsToFetch.reserve(instance->m_people.count());

    const QContactLocalId selfId = instance->m_manager.selfContactId();

    typedef QHash<QContactLocalId, SeasideCacheItem>::iterator iterator;
    for (iterator it = instance->m_people.begin(); it != instance->m_people.end(); ++it) {
        if (it.key() == selfId) {
            continue;
        } else if (it->hasCompleteContact) {
            contacts.append(it->contact);
        } else {
            contactsToFetch.append(it.key());
        }
    }

    if (!contactsToFetch.isEmpty()) {
        QList<QContact> fetchedContacts = instance->m_manager.contacts(contactsToFetch);
        contacts.append(fetchedContacts);
    }

    if (!exporter.exportContacts(contacts)) {
        qWarning() << Q_FUNC_INFO << "Failed to export contacts: " << exporter.errorMap();
        return QString();
    }

    QFile vcard(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)
              + QDir::separator()
              + QDateTime::currentDateTime().toString("ss_mm_hh_dd_mm_yyyy")
              + ".vcf");

    if (!vcard.open(QIODevice::WriteOnly)) {
        qWarning() << "Cannot open " << vcard.fileName();
        return QString();
    }

    QVersitWriter writer(&vcard);
    if (!writer.startWriting(exporter.documents())) {
        qWarning() << Q_FUNC_INFO << "Can't start writing vcards " << writer.error();
        return QString();
    }

    // TODO: thread
    writer.waitForFinished();
    return vcard.fileName();
}
开发者ID:VDVsx,项目名称:nemo-qml-plugins,代码行数:53,代码来源:seasidecache.cpp

示例6: addChildren

void GeoTreeModel::addChildren(GeoObjectListItem* sfcList,
                               GeoLib::SurfaceVec const& surface_vec,
                               size_t start_index,
                               size_t end_index)
{
	const std::vector<GeoLib::Surface*>* surfaces = surface_vec.getVector();

	const std::vector<GeoLib::Point*> &nodesVec(*((*surfaces)[start_index]->getPointVec()));
	for (size_t i = start_index; i < end_index; i++)
	{
		QList<QVariant> surface;
		surface.reserve(4);
		surface << "Surface " + QString::number(i) << "" <<
		"" << "";

		const GeoLib::Surface &sfc(*(*surfaces)[i]);
		GeoTreeItem* surfaceItem(new GeoTreeItem(surface, sfcList, &sfc));
		sfcList->appendChild(surfaceItem);

		int nElems = static_cast<int>((*surfaces)[i]->getNTriangles());
		for (int j = 0; j < nElems; j++)
		{
			QList<QVariant> elem;
			elem.reserve(4);
			const GeoLib::Triangle &triangle(*sfc[j]);
			elem << j << static_cast<int>(triangle[0])
			     << static_cast<int>(triangle[1])
			     << static_cast<int>(triangle[2]);
			TreeItem* child(new TreeItem(elem, surfaceItem));
			surfaceItem->appendChild(child);

			for (int k = 0; k < 3; k++)
			{
				QList<QVariant> node;
				node.reserve(4);
				const GeoLib::Point &pnt(*(nodesVec[triangle[k]]));
				node << static_cast<int>(triangle[k])
				     << QString::number(pnt[0], 'f')
				     << QString::number(pnt[1], 'f')
				     << QString::number(pnt[2], 'f');
				child->appendChild(new TreeItem(node, child));
			}
		}
	}

	for (auto pnt = surface_vec.getNameIDMapBegin(); pnt != surface_vec.getNameIDMapEnd(); ++pnt)
		QVariant pnt_data (sfcList->child(pnt->second)->setData(1, QString::fromStdString(pnt->first)));

	INFO("%d surfaces added.", end_index - start_index);
}
开发者ID:envinf,项目名称:ogs,代码行数:50,代码来源:GeoTreeModel.cpp

示例7: fillNeighborStructures

void MeshGenerator::fillNeighborStructures()
{
    QList<QSet<int> > vertexElements;
    vertexElements.reserve(nodeList.count());
    for (int i = 0; i < nodeList.count(); i++)
        vertexElements.push_back(QSet<int>());

    for (int i = 0; i < elementList.count(); i++)
        if (elementList[i].isUsed)
            for (int elemNode = 0; elemNode < (elementList[i].isTriangle() ? 3 : 4); elemNode++)
                vertexElements[elementList[i].node[elemNode]].insert(i);

    for (int i = 0; i < edgeList.count(); i++)
    {
        if (edgeList[i].isUsed && edgeList[i].marker != -1)
        {
            QSet<int> neighbours = vertexElements[edgeList[i].node[0]];
            neighbours.intersect(vertexElements[edgeList[i].node[1]]);
            assert((neighbours.size() > 0) && (neighbours.size() <= 2));
            edgeList[i].neighElem[0] = neighbours.values()[0];
            if (neighbours.size() == 2)
                edgeList[i].neighElem[1] = neighbours.values()[1];
        }
    }
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例8: insertRows

bool GenericEditableTableModel::insertRows ( int row, int count, const QModelIndex & parent)
{
    if(row<0 || row>rowCount()){
        return false;
    }

    beginInsertRows(parent, row, row+count-1);

    modelData.reserve(rowCount()+count);


    int colCount=columnCount();
    int currentRowCount=rowCount();


    for(int i=0; i<count; i++){
        QList<QHash<int,QVariant> > newCols;
        newCols.reserve(colCount);
        for(int j=0; j<colCount; j++){
            newCols.append(QHash<int,QVariant>());
        }
        if(row==currentRowCount){
            modelData.append(newCols);
        }else{
            modelData.insert(row+i, newCols);
        }
    }


    endInsertRows();

    return true;
}
开发者ID:rovshan-b,项目名称:oraexp,代码行数:33,代码来源:genericeditabletablemodel.cpp

示例9: initialize

 void initialize(const FileList &targetFiles, const FileList &queryFiles)
 {
     Output::initialize(targetFiles, queryFiles);
     bestMatches.reserve(queryFiles.size());
     for (int i=0; i<queryFiles.size(); i++)
         bestMatches.append(BestMatch(-std::numeric_limits<float>::max(), QPair<int,int>(-1, -1)));
 }
开发者ID:Alegzandra,项目名称:openbr,代码行数:7,代码来源:output.cpp

示例10: shouldAddItemInTreeList

void FollowupReminderInfoDialogTest::shouldAddItemInTreeList()
{
    FollowUpReminderInfoDialog dlg;
    FollowUpReminderInfoWidget *infowidget = dlg.findChild<FollowUpReminderInfoWidget *>(QStringLiteral("FollowUpReminderInfoWidget"));
    QTreeWidget *treeWidget = infowidget->findChild<QTreeWidget *>(QStringLiteral("treewidget"));
    QList<FollowUpReminder::FollowUpReminderInfo *> lstInfo;
    lstInfo.reserve(10);
    for (int i = 0; i < 10; ++i) {
        FollowUpReminder::FollowUpReminderInfo *info = new FollowUpReminder::FollowUpReminderInfo();
        lstInfo.append(info);
    }
    dlg.setInfo(lstInfo);
    //We load invalid infos.
    QCOMPARE(treeWidget->topLevelItemCount(), 0);

    //Load valid infos
    for (int i = 0; i < 10; ++i) {
        FollowUpReminder::FollowUpReminderInfo *info = new FollowUpReminder::FollowUpReminderInfo();
        info->setOriginalMessageItemId(42);
        info->setMessageId(QStringLiteral("foo"));
        info->setFollowUpReminderDate(QDate::currentDate());
        info->setTo(QStringLiteral("To"));
        lstInfo.append(info);
    }

    dlg.setInfo(lstInfo);
    QCOMPARE(treeWidget->topLevelItemCount(), 10);
}
开发者ID:KDE,项目名称:kdepim,代码行数:28,代码来源:followupreminderinfodialogtest.cpp

示例11:

static QList<double> _calcEqualIntervalBreaks( double minimum, double maximum, int classes )
{

  // Equal interval algorithm
  //
  // Returns breaks based on dividing the range ('minimum' to 'maximum')
  // into 'classes' parts.

  double step = ( maximum - minimum ) / classes;

  QList<double> breaks;
  double value = minimum;
  breaks.reserve( classes );
  for ( int i = 0; i < classes; i++ )
  {
    value += step;
    breaks.append( value );
  }

  // floating point arithmetics is not precise:
  // set the last break to be exactly maximum so we do not miss it
  breaks[classes-1] = maximum;

  return breaks;
}
开发者ID:nicanor-b,项目名称:QGIS,代码行数:25,代码来源:qgsgraduatedsymbolrendererv2.cpp

示例12: load

void CookieJar::load()
{
    QFile cookieFile(m_cookieFileName);
    if (!cookieFile.open(QIODevice::ReadOnly))
        return;

    QDataStream stream(&cookieFile);
    quint8 version;
    stream >> version;
    if (version != cookieFileVersion)
        return;

    QList<QNetworkCookie> cookies;
    qint32 count;
    stream >> count;

#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
    cookies.reserve(count);
#endif
    for (int i = 0; i < count && !stream.atEnd(); ++i) {
        QByteArray rawCookie;
        stream >> rawCookie;
        cookies += QNetworkCookie::parseCookies(rawCookie);
    }

    setAllCookies(cookies);

    expireCookies();
}
开发者ID:Cescfangs,项目名称:liquid,代码行数:29,代码来源:cookiejar.cpp

示例13: pool

    QList<float> pool(const Mat &bottom, const Mat &top) const
    {
        QList<float> features;
        for (int i=0; i<=top.rows-3; i+=3) {
            for (int j=0; j<=top.cols-3; j+=3) {
                QList<float> vals;
                vals.reserve(3*3 + 4*4);

                // Top values
                for (int k=0; k<3; k++) {
                    const float *data = top.ptr<float>(i+k, j);
                    for (int l=0; l<3; l++)
                        vals.append(data[l]);
                }

                // Bottom values
                for (int k=0; k<4; k++) {
                    const float *data = bottom.ptr<float>(4*i/3+k, 4*j/3);
                    for (int l=0; l<4; l++)
                        vals.append(data[l]);
                }

                double mean, stddev;
                Common::MeanStdDev(vals, &mean, &stddev);
                features.append(mean);
                features.append(stddev);
            }
        }

        return features;
    }
开发者ID:caomw,项目名称:openbr,代码行数:31,代码来源:ebif.cpp

示例14: foreach

 QList<VDPtr> VideoDevice::getSystemDevices() {
   auto udevs = VideoDeviceImpl::getSystemDevices();
   QList<VDPtr> devs;
   devs.reserve(udevs.size());
   foreach (const auto &dev, udevs) {
     devs << VDPtr(new VideoDevice(dev));
   }
开发者ID:netromdk,项目名称:mocam,代码行数:7,代码来源:VideoDevice.cpp

示例15: _q_sourceLayoutChanged

void QIdentityProxyModelPrivate::_q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
{
    Q_Q(QIdentityProxyModel);

    for (int i = 0; i < proxyIndexes.size(); ++i) {
        q->changePersistentIndex(proxyIndexes.at(i), q->mapFromSource(layoutChangePersistentIndexes.at(i)));
    }

    layoutChangePersistentIndexes.clear();
    proxyIndexes.clear();

    QList<QPersistentModelIndex> parents;
    parents.reserve(sourceParents.size());
    foreach (const QPersistentModelIndex &parent, sourceParents) {
        if (!parent.isValid()) {
            parents << QPersistentModelIndex();
            continue;
        }
        const QModelIndex mappedParent = q->mapFromSource(parent);
        Q_ASSERT(mappedParent.isValid());
        parents << mappedParent;
    }

    q->layoutChanged(parents, hint);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:25,代码来源:qidentityproxymodel.cpp


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