• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cache_t类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: eraseExpired

	void eraseExpired()
	{
		F64 now = LLFrameTimer::getTotalSeconds();
		cache_t::iterator it = sCache.begin();
		while (it != sCache.end())
		{
			cache_t::iterator cur = it;
			LLSD& exp = cur->second;
			++it;

			if(exp.has(EXPIRES) && exp[EXPIRES].asReal() < now)
			{
                if(!exp.has(EXPERIENCE_ID))
				{
                    LL_WARNS("ExperienceCache") << "Removing experience with no id " << LL_ENDL ;
                    sCache.erase(cur);
					}
                else
                {
                    LLUUID id = exp[EXPERIENCE_ID].asUUID();
                    LLUUID private_key = exp.has(LLExperienceCache::PRIVATE_KEY) ? exp[LLExperienceCache::PRIVATE_KEY].asUUID():LLUUID::null;
                    if(private_key.notNull() || !exp.has("DoesNotExist"))
					{
						fetch(id, true);
					}
					else
					{
                        LL_WARNS("ExperienceCache") << "Removing invalid experience " << id << LL_ENDL ;
						sCache.erase(cur);
					}
				}
			}
		}
	}
开发者ID:Belxjander,项目名称:Kirito,代码行数:34,代码来源:llexperiencecache.cpp


示例2: get

	void get( const LLUUID& key, callback_slot_t slot )
	{
		if(key.isNull()) return;

		cache_t::const_iterator it = sCache.find(key);
		if (it != sCache.end())
		{
			// ...name already exists in cache, fire callback now
			callback_signal_t signal;
			signal.connect(slot);
			
			signal(it->second);
			return;
		}

		fetch(key);

		// always store additional callback, even if request is pending
		signal_map_t::iterator sig_it = sSignalMap.find(key);
		if (sig_it == sSignalMap.end())
		{
			// ...new callback for this id
			callback_signal_t* signal = new callback_signal_t();
			signal->connect(slot);
			sSignalMap[key] = signal;
		}
		else
		{
			// ...existing callback, bind additional slot
			callback_signal_t* signal = sig_it->second;
			signal->connect(slot);
		}
	}
开发者ID:Belxjander,项目名称:Kirito,代码行数:33,代码来源:llexperiencecache.cpp


示例3: erase

	void erase( const LLUUID& key )
	{
		cache_t::iterator it = sCache.find(key);
				
		if(it != sCache.end())
		{
			sCache.erase(it);
		}
	}
开发者ID:Belxjander,项目名称:Kirito,代码行数:9,代码来源:llexperiencecache.cpp


示例4: new_keys

	typename std::enable_if<(sizeof...(Args), std::is_same<cache_t, cache_map_t>::value) && tp == timeout_policy_t::NEVER, std::remove_const_t<std::decay_t<R>>>::type
	const& call(Args const&... args)
	{
		decayed_key_t new_keys(getKey(args)...);
		auto&& it(cache.find(new_keys));

		if (it == cache.end())      //not cached
		{
			auto&& pos(cache.insert(std::pair<key_t, R>(std::move(new_keys), fptr(args...))));

			return pos.first->second;
		}
		else                        //was cached
			return it->second;
	};
开发者ID:ggwpez,项目名称:Lambda-Counter,代码行数:15,代码来源:cache.hpp


示例5: cycleLengthRecursive

int cycleLengthRecursive(unsigned int n) {
  // base case is handled by cache
  
  cache_t::iterator it = cache.find(n);
  if (it != cache.end()) {
    return it->second;  
  }
  
  int out;
  if (n % 2 == 1) 
    out = 1 + cycleLengthRecursive((n*3) + 1);  // if n is odd then  n <- 3n + 1
  else           
    out = 1 + cycleLengthRecursive(n/2);        // else n <- n/2

  cache[n] = out;
  return out;
}
开发者ID:xyzelement,项目名称:UVA,代码行数:17,代码来源:100.cpp


示例6: exportFile

	void exportFile(std::ostream& ostr)
	{
		LLSD experiences;

		cache_t::const_iterator it =sCache.begin();
		for( ; it != sCache.end() ; ++it)
		{
			if(!it->second.has(EXPERIENCE_ID) || it->second[EXPERIENCE_ID].asUUID().isNull() ||
				it->second.has("DoesNotExist") || (it->second.has(PROPERTIES) && it->second[PROPERTIES].asInteger() & PROPERTY_INVALID))
				continue;

			experiences[it->first.asString()] = it->second;
		}

		LLSD data;
		data["experiences"] = experiences;

		LLSDSerialize::toPrettyXML(data, ostr);
	}
开发者ID:Belxjander,项目名称:Kirito,代码行数:19,代码来源:llexperiencecache.cpp


示例7: CacheGet

// static
bool Dbase::CacheGet(Cddb::Matches& res, const Cddb::discid_t discID)
{
    bool ret = false;
    for (cache_t::const_iterator it = s_cache.find(discID); it != s_cache.end(); ++it)
    {
        if (it->discID == discID)
        {
            ret = true;
            res.discID = discID;
            LOG(VB_MEDIA, LOG_DEBUG, QString("Cddb CacheGet %1 found %2 ")
                .arg(discID,0,16).arg(it->discID,0,16)
                + it->discGenre + " " + it->artist + " / " + it->title);

            // If it's marker for 'no match' then genre is empty
            if (!it->discGenre.isEmpty())
                res.matches.push_back(Cddb::Match(*it));
        }
    }
    return ret;
}
开发者ID:faginbagin,项目名称:mythtv,代码行数:21,代码来源:cddb.cpp


示例8: mx

 //start = startIndex
 int mx(int start, int maxw)
 {
    if(start >= tt->size() || maxw <= 0) return 0;
    cache_t::iterator it = cache.find(PI(start, maxw));
    if(it != cache.end()){
       return it->second;
    }
    int without = mx(start+1, maxw);
    int res = without;
    int st_w = (*tt)[start].w;
    int st_st = (*tt)[start].st;
    int with = -1;
    if(st_w <= maxw){
       int new_maxw = min(maxw - st_w, st_st - st_w);
       with = mx(start+1, new_maxw);
       if(1+with > res){
          res = 1+with;
       }
    }
    cache[PI(start,maxw)] = res;
    return res;
 }
开发者ID:deepankar,项目名称:prog-challenges-sol,代码行数:23,代码来源:3.cpp


示例9: mapKeys

namespace LLExperienceCache
{

    typedef std::map<LLUUID, LLUUID> KeyMap;
    KeyMap privateToPublicKeyMap;

    void mapKeys(const LLSD& legacyKeys);

	std::string sLookupURL;

	typedef std::map<LLUUID, std::string> ask_queue_t;
	ask_queue_t sAskQueue;

	typedef std::map<LLUUID, F64> pending_queue_t;
	pending_queue_t sPendingQueue;

	cache_t sCache;
	int sMaximumLookups = 10;

	LLFrameTimer sRequestTimer;

	// Periodically clean out expired entries from the cache
	LLFrameTimer sEraseExpiredTimer;

	// May have multiple callbacks for a single ID, which are
	// represented as multiple slots bound to the signal.
	// Avoid copying signals via pointers.
	typedef std::map<LLUUID, callback_signal_t*> signal_map_t;
	signal_map_t sSignalMap;



	bool max_age_from_cache_control(const std::string& cache_control, S32 *max_age);
	void eraseExpired();

	void processExperience( const LLUUID& public_key, const LLSD& experience ) 
	{
		sCache[public_key]=experience;
		LLSD & row = sCache[public_key];

		if(row.has(EXPIRES))
		{
			row[EXPIRES] = row[EXPIRES].asReal() + LLFrameTimer::getTotalSeconds();
		}

		if(row.has(EXPERIENCE_ID))
		{
			sPendingQueue.erase(row[EXPERIENCE_ID].asUUID());
		}

		//signal
		signal_map_t::iterator sig_it =	sSignalMap.find(public_key);
		if (sig_it != sSignalMap.end())
		{
			callback_signal_t* signal = sig_it->second;
			(*signal)(experience);

			sSignalMap.erase(public_key);

			delete signal;
		}
	}

	void initClass( )
	{
	}

	const cache_t& getCached()
	{
		return sCache;
	}

	void setMaximumLookups( int maximumLookups)
	{
		sMaximumLookups = maximumLookups;
	}

	void bootstrap(const LLSD& legacyKeys, int initialExpiration)
	{
        mapKeys(legacyKeys);
		LLSD::array_const_iterator it = legacyKeys.beginArray();
		for(/**/; it != legacyKeys.endArray(); ++it)
		{
			LLSD experience = *it;
			if(experience.has(EXPERIENCE_ID))
			{
				if(!experience.has(EXPIRES))
				{
					experience[EXPIRES] = initialExpiration;
				}
				processExperience(experience[EXPERIENCE_ID].asUUID(), experience);
			}
			else
			{
				LL_WARNS("ExperienceCache") 
					<< "Skipping bootstrap entry which is missing " << EXPERIENCE_ID 
					<< LL_ENDL;
			}
		}		
	}
//.........这里部分代码省略.........
开发者ID:Belxjander,项目名称:Kirito,代码行数:101,代码来源:llexperiencecache.cpp


示例10: while

expr_ref bind_variables::abstract(expr* term, cache_t& cache, unsigned scope) {
    unsigned sz = m_todo.size();
    m_todo.push_back(term);
    m_args.reset();
    expr* b, *arg;
    while (m_todo.size() > sz) {
        expr* e = m_todo.back();
        if (cache.contains(e)) {
            m_todo.pop_back();
            continue;
        }
        switch(e->get_kind()) {
        case AST_VAR: {
            SASSERT(to_var(e)->get_idx() < scope); 
            // mixing bound variables and free is possible for the caller, 
            // but not proper use.
            // So we assert here even though we don't check for it.
            cache.insert(e, e);
            m_todo.pop_back();
            break;
        }
        case AST_APP: {
            app* a = to_app(e);
            var2bound::obj_map_entry* w = m_var2bound.find_core(a);
            if (w) {
                var* v = w->get_data().m_value;
                if (!v) {
                    // allocate a bound index.
                    v = m.mk_var(m_names.size(), m.get_sort(a));
                    m_names.push_back(a->get_decl()->get_name());
                    m_bound.push_back(m.get_sort(a));
                    w->get_data().m_value = v;
                    m_pinned.push_back(v);
                }
                if (scope == 0) {
                    cache.insert(e, v);
                }
                else {
                    var* v1 = m.mk_var(scope + v->get_idx(), m.get_sort(v));
                    m_pinned.push_back(v1);
                    cache.insert(e, v1);
                }
                m_todo.pop_back();
                break;
            }
            bool all_visited = true;
            bool some_diff = false;
            m_args.reset();
            for (unsigned i = 0; i < a->get_num_args(); ++i) {
                arg = a->get_arg(i);                
                if (!cache.find(arg, b)) {
                    m_todo.push_back(arg);
                    all_visited = false;
                }
                else if (all_visited) {
                    m_args.push_back(b);
                    if (b != arg) {
                        some_diff = true;
                    }
                }
            }
            if (all_visited) {
                if (some_diff) {
                    b = m.mk_app(a->get_decl(), m_args.size(), m_args.c_ptr());
                    m_pinned.push_back(b);
                }
                else {
                    b = a;
                }
                cache.insert(e, b);
                m_todo.pop_back();
            }
            break;
        }
        case AST_QUANTIFIER: {
            quantifier* q = to_quantifier(e);
            expr_ref_buffer patterns(m);
            expr_ref result1(m);
            unsigned new_scope = scope + q->get_num_decls();
            cache_t new_cache;
            for (unsigned i = 0; i < q->get_num_patterns(); ++i) {
                patterns.push_back(abstract(q->get_pattern(i), new_cache, new_scope));
            }
            result1 = abstract(q->get_expr(), new_cache, new_scope);
            b = m.update_quantifier(q, patterns.size(), patterns.c_ptr(), result1.get());
            m_pinned.push_back(b);            
            cache.insert(e, b);
            m_todo.pop_back();            
            break;
        }
        default:
            UNREACHABLE();
        }
    }
    return expr_ref(cache.find(term), m);
}
开发者ID:AleksandarZeljic,项目名称:z3,代码行数:96,代码来源:bind_variables.cpp


示例11: fetch

	bool fetch( const LLUUID& key, bool refresh/* = true*/ ) 
	{
		if(!key.isNull() && !isRequestPending(key) && (refresh || sCache.find(key)==sCache.end()))
		{
			LL_DEBUGS("ExperienceCache") << " queue request for " << EXPERIENCE_ID << " " << key << LL_ENDL ;
			sAskQueue[key]=EXPERIENCE_ID;

			return true;
		}
		return false;
	}
开发者ID:Belxjander,项目名称:Kirito,代码行数:11,代码来源:llexperiencecache.cpp


示例12: solve

 int solve(vector<Turtle> &tt)
 {
    this->tt = &tt;
    cache.clear();
    sort(tt.begin(), tt.end(), carry_desc());
    return mx(0, INT_MAX);
 }
开发者ID:deepankar,项目名称:prog-challenges-sol,代码行数:7,代码来源:3.cpp


示例13: MakeAlias

// Create a local alias for a matched discID
// static
void Dbase::MakeAlias(const Cddb::Album& album, const Cddb::discid_t discID)
{
    LOG(VB_MEDIA, LOG_DEBUG, QString("Cddb MakeAlias %1 for %2 ")
        .arg(discID,0,16).arg(album.discID,0,16)
        + album.genre + " " + album.artist + " / " + album.title);
    s_cache.insert(discID, album)->discID = discID;
}
开发者ID:faginbagin,项目名称:mythtv,代码行数:9,代码来源:cddb.cpp


示例14: CachePut

// static
void Dbase::CachePut(const Cddb::Album& album)
{
    LOG(VB_MEDIA, LOG_DEBUG, QString("Cddb CachePut %1 ")
        .arg(album.discID,0,16)
        + album.genre + " " + album.artist + " / " + album.title);
    s_cache.insertMulti(album.discID, album);
}
开发者ID:faginbagin,项目名称:mythtv,代码行数:8,代码来源:cddb.cpp


示例15: getContent

		/*virtual*/ void httpCompleted()
		{
			LLSD experiences = getContent()["experience_keys"];
			LLSD::array_const_iterator it = experiences.beginArray();
			for( /**/ ; it != experiences.endArray(); ++it)
			{
				const LLSD& row = *it;
				LLUUID public_key = row[EXPERIENCE_ID].asUUID();


				LL_DEBUGS("ExperienceCache") << "Received result for " << public_key 
					<< " display '" << row[LLExperienceCache::NAME].asString() << "'" << LL_ENDL ;

				processExperience(public_key, row);
			}

			LLSD error_ids = getContent()["error_ids"];
			LLSD::array_const_iterator errIt = error_ids.beginArray();
			for( /**/ ; errIt != error_ids.endArray() ; ++errIt )
			{
				LLUUID id = errIt->asUUID();		
				LLSD exp;
				exp[EXPIRES]=DEFAULT_EXPIRATION;
				exp[EXPERIENCE_ID] = id;
				exp[PROPERTIES]=PROPERTY_INVALID;
				exp[MISSING]=true;
                exp[QUOTA] = DEFAULT_QUOTA;

				processExperience(id, exp);
				LL_WARNS("ExperienceCache") << "LLExperienceResponder::result() error result for " << id << LL_ENDL ;
			}

			LL_DEBUGS("ExperienceCache") << sCache.size() << " cached experiences" << LL_ENDL;
		}
开发者ID:Belxjander,项目名称:Kirito,代码行数:34,代码来源:llexperiencecache.cpp


示例16: fptr

	Cache(fptr_t arg)
		: fptr(arg),
		  internal_cache(),
		  internal_it(internal_cache.begin()),
		  cache(),
		  cache_it(cache.begin())
	{ }
开发者ID:ggwpez,项目名称:Lambda-Counter,代码行数:7,代码来源:cache.hpp


示例17: main

int main(int argc,char *argv[]) {
    cache.resize(3145739); // avoid any future rebucketing
    cache[1] = 1; // base case, avoids lots of future ==
    unsigned int i, j;
    while (cin >> i && cin >> j) {
      cout << i << " " << j << " " << maxCycleLength(i, j) << endl;
    }
  }
开发者ID:xyzelement,项目名称:UVA,代码行数:8,代码来源:100.cpp


示例18: importFile

	void importFile(std::istream& istr)
	{
		LLSD data;
		S32 parse_count = LLSDSerialize::fromXMLDocument(data, istr);
		if(parse_count < 1) return;

		LLSD experiences = data["experiences"];

		LLUUID public_key;
		LLSD::map_const_iterator it = experiences.beginMap();
		for(; it != experiences.endMap() ; ++it)
		{
			public_key.set(it->first);
			sCache[public_key]=it->second;
		}

		LL_DEBUGS("ExperienceCache") << "importFile() loaded " << sCache.size() << LL_ENDL;
	}
开发者ID:Belxjander,项目名称:Kirito,代码行数:18,代码来源:llexperiencecache.cpp


示例19: New

// Create a new entry for a discID
// static
void Dbase::New(const Cddb::discid_t discID, const Cddb::Toc& toc)
{
    s_cache.insert(discID, Cddb::Album(discID))->toc = toc;
}
开发者ID:faginbagin,项目名称:mythtv,代码行数:6,代码来源:cddb.cpp


示例20: size

	inline std::size_t size() const
	{
		return cache.size();
	}
开发者ID:ggwpez,项目名称:Lambda-Counter,代码行数:4,代码来源:cache.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cache_type类代码示例发布时间:2022-05-31
下一篇:
C++ cWorld类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap