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


C++ clearCache函数代码示例

本文整理汇总了C++中clearCache函数的典型用法代码示例。如果您正苦于以下问题:C++ clearCache函数的具体用法?C++ clearCache怎么用?C++ clearCache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: int

    // Interpolate table (linearly) to some specific k:
    // x any y in physical units (to be divided by dx for indices)
    double XTable::interpolate(double x, double y, const Interpolant2d& interp) const 
    {
        xdbg << "interpolating " << x << " " << y << " " << std::endl;
        x /= _dx;
        y /= _dx;
        int ixMin, ixMax, iyMin, iyMax;
        if ( interp.isExactAtNodes() 
             && std::abs(x - std::floor(x+0.01)) < 10.*std::numeric_limits<double>::epsilon()) {
            // x coord lies right on integer value, no interpolation in x direction
            ixMin = ixMax = int(std::floor(x+0.01));
        } else {
            ixMin = int(std::ceil(x-interp.xrange()));
            ixMax = int(std::floor(x+interp.xrange()));
        }
        ixMin = std::max(ixMin, -_N/2);
        ixMax = std::min(ixMax, _N/2-1);
        if (ixMin > ixMax) return 0.;

        if ( interp.isExactAtNodes() 
             && std::abs(y - std::floor(y+0.01)) < 10.*std::numeric_limits<double>::epsilon()) {
            // y coord lies right on integer value, no interpolation in y direction
            iyMin = iyMax = int(std::floor(y+0.01));
        } else {
            iyMin = int(std::ceil(y-interp.xrange()));
            iyMax = int(std::floor(y+interp.xrange()));
        }
        iyMin = std::max(iyMin, -_N/2);
        iyMax = std::min(iyMax, _N/2-1);
        if (iyMin > iyMax) return 0.;

        double sum = 0.;
        const InterpolantXY* ixy = dynamic_cast<const InterpolantXY*> (&interp);
        if (ixy) {
            // Interpolant is seperable
            // We have the opportunity to speed up the calculation by
            // re-using the sums over rows.  So we will keep a 
            // cache of them.
            if (x != _cacheX || ixy != _cacheInterp) {
                clearCache();
                _cacheX = x;
                _cacheInterp = ixy;
            } else if (iyMax==iyMin && !_cache.empty()) {
                // Special case for interpolation on a single iy value:
                // See if we already have this row in cache:
                int index = iyMin - _cacheStartY;
                if (index < 0) index += _N;
                if (index < int(_cache.size())) 
                    // We have it!
                    return _cache[index];
                else
                    // Desired row not in cache - kill cache, continue as normal.
                    // (But don't clear xwt, since that's still good.)
                    _cache.clear();
            }

            // Build x factors for interpolant
            int nx = ixMax - ixMin + 1;
            // This is also cached if possible.  It gets cleared when kx != cacheX above.
            if (_xwt.empty()) {
                _xwt.resize(nx);
                for (int i=0; i<nx; i++) 
                    _xwt[i] = ixy->xval1d(i+ixMin-x);
            } else {
                assert(int(_xwt.size()) == nx);
            }

            // cache always holds sequential y values (no wrap).  Throw away
            // elements until we get to the one we need first
            std::deque<double>::iterator nextSaved = _cache.begin();
            while (nextSaved != _cache.end() && _cacheStartY != iyMin) {
                _cache.pop_front();
                _cacheStartY++;
                nextSaved = _cache.begin();
            }

            for (int iy = iyMin; iy<=iyMax; iy++) {
                double sumy = 0.;
                if (nextSaved != _cache.end()) {
                    // This row is cached
                    sumy = *nextSaved;
                    ++nextSaved;
                } else {
                    // Need to compute a new row's sum
                    const double* dptr = _array.get() + index(ixMin, iy);
                    std::vector<double>::const_iterator xwt_it = _xwt.begin();
                    int count = nx;
                    for(; count; --count) sumy += (*xwt_it++) * (*dptr++);
                    assert(xwt_it == _xwt.end());
                    // Add to back of cache
                    if (_cache.empty()) _cacheStartY = iy;
                    _cache.push_back(sumy);
                    nextSaved = _cache.end();
                }
                sum += sumy * ixy->xval1d(iy-y);
            }
        } else {
            // Interpolant is not seperable, calculate weight at each point
            for (int iy = iyMin; iy<=iyMax; iy++) {
//.........这里部分代码省略.........
开发者ID:alexabate,项目名称:GalSim,代码行数:101,代码来源:FFT.cpp

示例2: clearCache

void Territory::insert(Position pos) {
  allSquaresVec.push_back(pos);
  allSquares.insert(pos);
  clearCache();
}
开发者ID:Knochenschaeler,项目名称:keeperrl,代码行数:5,代码来源:territory.cpp

示例3: m_pCollection

LibraryScanner::LibraryScanner(QWidget* pParentWidget,
                               TrackCollection* collection,
                               UserSettingsPointer pConfig)
              : m_pCollection(collection),
                m_libraryHashDao(m_database),
                m_cueDao(m_database),
                m_playlistDao(m_database),
                m_crateDao(m_database),
                m_directoryDao(m_database),
                m_analysisDao(m_database, pConfig),
                m_trackDao(m_database, m_cueDao, m_playlistDao,
                           m_crateDao, m_analysisDao, m_libraryHashDao,
                           pConfig),
                m_stateSema(1), // only one transaction is possible at a time
                m_state(IDLE) {
    // Don't initialize m_database here, we need to do it in run() so the DB
    // conn is in the right thread.
    qDebug() << "Starting LibraryScanner thread.";

    // Move LibraryScanner to its own thread so that our signals/slots will
    // queue to our event loop.
    moveToThread(this);
    m_pool.moveToThread(this);

    unsigned static id = 0; // the id of this LibraryScanner, for debugging purposes
    setObjectName(QString("LibraryScanner %1").arg(++id));

    m_pool.setMaxThreadCount(kScannerThreadPoolSize);

    // Listen to signals from our public methods (invoked by other threads) and
    // connect them to our slots to run the command on the scanner thread.
    connect(this, SIGNAL(startScan()),
            this, SLOT(slotStartScan()));

    // Force the GUI thread's TrackInfoObject cache to be cleared when a library
    // scan is finished, because we might have modified the database directly
    // when we detected moved files, and the TIOs corresponding to the moved
    // files would then have the wrong track location.
    if (collection != NULL) { // false only during test
        TrackDAO* dao = &(collection->getTrackDAO());
        connect(this, SIGNAL(scanFinished()), dao, SLOT(clearCache()));
        connect(this, SIGNAL(trackAdded(TrackPointer)),
                dao, SLOT(databaseTrackAdded(TrackPointer)));
        connect(this, SIGNAL(tracksMoved(QSet<TrackId>, QSet<TrackId>)),
                dao, SLOT(databaseTracksMoved(QSet<TrackId>, QSet<TrackId>)));
        connect(this, SIGNAL(tracksChanged(QSet<TrackId>)),
                dao, SLOT(databaseTracksChanged(QSet<TrackId>)));
    }

    // Parented to pParentWidget so we don't need to delete it.
    LibraryScannerDlg* pProgress = new LibraryScannerDlg(pParentWidget);
    connect(this, SIGNAL(progressLoading(QString)),
            pProgress, SLOT(slotUpdate(QString)));
    connect(this, SIGNAL(progressHashing(QString)),
            pProgress, SLOT(slotUpdate(QString)));
    connect(this, SIGNAL(scanStarted()),
            pProgress, SLOT(slotScanStarted()));
    connect(this, SIGNAL(scanFinished()),
            pProgress, SLOT(slotScanFinished()));
    connect(pProgress, SIGNAL(scanCancelled()),
            this, SLOT(slotCancel()));
    connect(&m_trackDao, SIGNAL(progressVerifyTracksOutside(QString)),
            pProgress, SLOT(slotUpdate(QString)));
    connect(&m_trackDao, SIGNAL(progressCoverArt(QString)),
            pProgress, SLOT(slotUpdateCover(QString)));

    start();
}
开发者ID:amoghpc,项目名称:mixxx,代码行数:68,代码来源:libraryscanner.cpp

示例4: removeElement

void Territory::remove(Position pos) {
  removeElement(allSquaresVec, pos);
  allSquares.erase(pos);
  clearCache();
}
开发者ID:LibreGames,项目名称:keeperrl,代码行数:5,代码来源:territory.cpp

示例5: clearCache

QgsAbstractGeometry* QgsGeometryCollection::geometryN( int n )
{
  clearCache();
  return mGeometries.value( n );
}
开发者ID:liminlu0314,项目名称:QGIS,代码行数:5,代码来源:qgsgeometrycollection.cpp

示例6: clearCache

 GLES2StateCacheManagerImp::GLES2StateCacheManagerImp(void) 
 {
     clearCache();
 }
开发者ID:Ali-il,项目名称:gamekit,代码行数:4,代码来源:OgreGLES2NullStateCacheManagerImp.cpp

示例7: clearCache

void FontManager::setDefaultGlyphLoadFlags(const Flags<FontFace::GlyphLoadFlags>& flags)
{
	clearCache();
	m_defaultLoadFlags = flags;
}
开发者ID:tylerreisinger,项目名称:rogueframework,代码行数:5,代码来源:FontManager.cpp

示例8: clearCache

 void EntityDefinitionManager::updateCache() {
     clearCache();
     for (EntityDefinition* definition : m_definitions)
         m_cache[definition->name()] = definition;
 }
开发者ID:kduske,项目名称:TrenchBroom,代码行数:5,代码来源:EntityDefinitionManager.cpp

示例9: clearCache

btGImpactCollisionAlgorithm::~btGImpactCollisionAlgorithm()
{
	clearCache();
}
开发者ID:halogenica,项目名称:Aggrogate,代码行数:4,代码来源:btGImpactCollisionAlgorithm.cpp

示例10: clearCache

KateSyntaxDocument::~KateSyntaxDocument()
{
    // cleanup, else we have a memory leak!
    clearCache();
}
开发者ID:KDE,项目名称:ktexteditor,代码行数:5,代码来源:katesyntaxdocument.cpp

示例11: close

 int close()
 {   clearCache(); return 0;  }
开发者ID:ewwink,项目名称:openlitespeed,代码行数:2,代码来源:chunkostest.cpp

示例12: gpgme_release

KGpgMe::~KGpgMe()
{
    if (m_ctx)
        gpgme_release(m_ctx);
    clearCache();
}
开发者ID:AlD,项目名称:basket,代码行数:6,代码来源:kgpgme.cpp

示例13: qDeleteAll

void QgsGeometryCollection::clear()
{
  qDeleteAll( mGeometries );
  mGeometries.clear();
  clearCache(); //set bounding box invalid
}
开发者ID:liminlu0314,项目名称:QGIS,代码行数:6,代码来源:qgsgeometrycollection.cpp

示例14: addMenu


//.........这里部分代码省略.........
        avatar.get(), SLOT(updateMotionBehaviorFromMenu()),
        UNSPECIFIED_POSITION, "Developer");

    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ScriptedMotorControl, 0, true,
        avatar.get(), SLOT(updateMotionBehaviorFromMenu()),
        UNSPECIFIED_POSITION, "Developer");

    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ShowTrackedObjects, 0, false, qApp, SLOT(setShowTrackedObjects(bool)));

    addActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::PackageModel, 0, qApp, SLOT(packageModel()));

    // Developer > Hands >>>
    MenuWrapper* handOptionsMenu = developerMenu->addMenu("Hands");
    addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false,
        avatar.get(), SLOT(setEnableDebugDrawHandControllers(bool)));

    // Developer > Entities >>>
    MenuWrapper* entitiesOptionsMenu = developerMenu->addMenu("Entities");

    addActionToQMenuAndActionHash(entitiesOptionsMenu, MenuOption::OctreeStats, 0,
        qApp, SLOT(loadEntityStatisticsDialog()));

    addCheckableActionToQMenuAndActionHash(entitiesOptionsMenu, MenuOption::ShowRealtimeEntityStats);

    // Developer > Network >>>
    MenuWrapper* networkMenu = developerMenu->addMenu("Network");
    action = addActionToQMenuAndActionHash(networkMenu, MenuOption::Networking);
    connect(action, &QAction::triggered, [] {
        qApp->showDialog(QString("hifi/dialogs/NetworkingPreferencesDialog.qml"),
            QString("hifi/tablet/TabletNetworkingPreferences.qml"), "NetworkingPreferencesDialog");
    });
    addActionToQMenuAndActionHash(networkMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches()));
    addActionToQMenuAndActionHash(networkMenu, MenuOption::ClearDiskCache, 0,
        DependencyManager::get<AssetClient>().data(), SLOT(clearCache()));
    addCheckableActionToQMenuAndActionHash(networkMenu,
        MenuOption::DisableActivityLogger,
        0,
        false,
        &UserActivityLogger::getInstance(),
        SLOT(disable(bool)));
    addActionToQMenuAndActionHash(networkMenu, MenuOption::ShowDSConnectTable, 0,
        qApp, SLOT(loadDomainConnectionDialog()));

    #if (PR_BUILD || DEV_BUILD)
    addCheckableActionToQMenuAndActionHash(networkMenu, MenuOption::SendWrongProtocolVersion, 0, false,
                qApp, SLOT(sendWrongProtocolVersionsSignature(bool)));

    {
        auto nodeList = DependencyManager::get<NodeList>();
        addCheckableActionToQMenuAndActionHash(networkMenu, MenuOption::SendWrongDSConnectVersion, 0, false,
            nodeList.data(), SLOT(toggleSendNewerDSConnectVersion(bool)));
    }
    #endif


    // Developer >> Tests >>>
    MenuWrapper* testMenu = developerMenu->addMenu("Tests");
    addActionToQMenuAndActionHash(testMenu, MenuOption::RunClientScriptTests, 0, dialogsManager.data(), SLOT(showTestingResults()));

    // Developer > Timing >>>
    MenuWrapper* timingMenu = developerMenu->addMenu("Timing");
    MenuWrapper* perfTimerMenu = timingMenu->addMenu("Performance Timer");
    addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::DisplayDebugTimingDetails, 0, false,
            qApp, SLOT(enablePerfStats(bool)));
    addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::OnlyDisplayTopTen, 0, true);
    addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandUpdateTiming, 0, false);
开发者ID:Menithal,项目名称:hifi,代码行数:67,代码来源:Menu.cpp

示例15: clearCache

void QgsLineString::swapXy()
{
  std::swap( mX, mY );
  clearCache();
}
开发者ID:rouault,项目名称:Quantum-GIS,代码行数:5,代码来源:qgslinestring.cpp


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