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


C++ unordered_multimap::insert方法代码示例

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


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

示例1: evict

    void evict()
	{

	    /* We are being evicted. Print our stats, update waste maps and clear. */
	    if(WANT_RAW_OUTPUT)
	    {
		cout << bytesUsed->count() << "\t" << timesReusedBeforeEvicted 
		     << "\t" << accessSite << "[" << varInfo << "]\t" 
		     << "0x" << hex << address << dec << endl;
	    }

	    if(timesReusedBeforeEvicted == 0)
	    {
		zeroReuseMap.insert(pair<string, ZeroReuseRecord>
				    (accessSite, 
				     ZeroReuseRecord(varInfo, address)));
	    }
	    if((float)(bytesUsed->count()) / (float)lineSize < LOW_UTIL_THRESHOLD)
	    {
		lowUtilMap.insert(pair<string, LowUtilRecord>
				  (accessSite, 
				   LowUtilRecord(varInfo, address, bytesUsed->count())));
	    }


	    address = 0;
	    tag = 0;
	    accessSite = "";
	    varInfo = "";
	    timesReusedBeforeEvicted = 0;
	    bytesUsed->reset();
	}
开发者ID:DataChi,项目名称:memdb,代码行数:32,代码来源:cache-waste-analysis.cpp

示例2: insert

 /** Inserts a value to the collection. Returns true if the collection did not already contain the specified element. */
 bool insert(int val) {
     int count = map.count(val);
     map.insert(make_pair(val, elements.size()));
     elements.push_back(val);
     
     return !count;
 }
开发者ID:kmather73,项目名称:LeetCode,代码行数:8,代码来源:Insert+Delete+GetRandom+O(1)+-+Duplicates+allowed.cpp

示例3: insert_hash

inline void insert_hash(hash_t key,hashtgt &val){
#if PERFORMANCE_STATISTICS
	++totalh;
#endif
	for(auto it=hashes.find(key);it!=hashes.end();++it){
		if(memcmp(val.digest,it->second.digest,sizeof(val.digest))==0){
#if PERFORMANCE_STATISTICS
			++conflict;
#endif
			//already have the same one inserted!
			return;
		}
	}
	hashes.insert(make_pair(key,val));
}
开发者ID:kikoqiu,项目名称:r2diff,代码行数:15,代码来源:r2diff.cpp

示例4: remove

 /** Removes a value from the collection. Returns true if the collection contained the specified element. */
 bool remove(int val) {
     auto inSet = map.find(val);
     
     if(inSet != map.end()){
         int pos = map.find(val)->second;
         map.erase (map.find(val), ++map.find(val));
         
         int last = elements.back(); elements.pop_back();
         elements[pos] = last;
         
         for(auto findPos = map.find(last); findPos != map.end(); ++findPos){
             if(findPos->second == elements.size()){
                 map.erase( findPos, std::next(findPos));
                 map.insert( make_pair(last, pos));
                 break;
             }
         }
     }
     
     return inSet != map.end();
 }
开发者ID:kmather73,项目名称:LeetCode,代码行数:22,代码来源:Insert+Delete+GetRandom+O(1)+-+Duplicates+allowed.cpp

示例5: cache_access2

bool cache_access2 (int index, int tag, Data d) {
    bool hit = 1;
    pair<int, Data> mypair(index, d);
                int count = L2.count(index);
                // Miss
                if (count <= 0) {
                    L2.insert(mypair);
                    miss_count2++;
                    hit = 0;
                    valid_cacheline2++;
                }
                else if (count == 1) {
                    auto range = L2.equal_range(index);
                    auto it = range.first;
                    Data d1 = it->second;
                    // Hit
                    if (d1.tag == tag) {
                        it->second.lru = 0;
                        //cout << "Hit" << endl;
                        hit_count2++;
                    }

                    // Miss
                    else {
                        it->second.lru = 1;
                        //cout << "Miss" << endl;
                        miss_count2++;
                        hit = 0;
                        L2.insert(mypair);
                        valid_cacheline2++;
                    }
                }
                else if (count == 2) {
                    auto range = L2.equal_range(index);
                    auto it = range.first;
                    auto it_1 = range.first;
                    auto it_2 = ++it;
                    Data d1 = it_1->second;
                    Data d2 = it_2->second;
                    // Hit
                    if (d1.tag == tag) {
                        it_1->second.lru = 0;
                        it_2->second.lru = 1;
                        //cout << "Hit" << endl;
                        hit_count2++;
                    }
                    else if (d2.tag == tag) {
                        it_1->second.lru = 1;
                        it_2->second.lru = 0;
                        //cout << "Hit" << endl;
                        hit_count2++;
                    }
                    else if (d1.lru == 1) {
                        it_2->second.lru = 1;
                        //cout << "Miss" << endl;
                        miss_count2++;
                        evict_count2++;
                        hit = 0;
                        L2.erase(it_1);
                        L2.insert(mypair);
                    }
                    else {
                        it_1->second.lru = 1;
                        //cout << "Miss" << endl;
                        miss_count2++;
                        evict_count2++;
                        hit = 0;
                        L2.erase(it_2);
                        L2.insert(mypair);
                    }

                }
                else {
                    cout << "Containing more than 2 cachelines" <<endl;
                    exit(1);
                }
    return hit;
}
开发者ID:yzhu29,项目名称:ca,代码行数:78,代码来源:main.cpp


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