本文整理汇总了C++中unordered_multimap类的典型用法代码示例。如果您正苦于以下问题:C++ unordered_multimap类的具体用法?C++ unordered_multimap怎么用?C++ unordered_multimap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了unordered_multimap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cbn_consoleOutput
void cbn_consoleOutput(unordered_multimap<string, string> &folder)
{
std::cout << "Folder contains:"<<endl;
for ( auto it = folder.begin(); it != folder.end(); ++it ){
std::cout << " " << it->first << ":" << it->second;
std::cout << std::endl;}
}
示例2: eraseIf
void eraseIf(unordered_multimap<K, V, H, E, A>& unordered, EraseIfFn const& f) {
for (typename unordered_multimap<K, V, H, E, A>::iterator i = unordered.begin(), e = unordered.end();
i != e;) // no ++i - intentional
if (f(*i))
i = unordered.erase(i);
else
++i;
}
示例3: eraseIfVal
void eraseIfVal(unordered_multimap<K, V, H, E, A>& umap, EraseIfFn const& f) {
for (typename unordered_multimap<K, V, H, E, A>::iterator i = umap.begin(), e = umap.end();
i != e;) // no ++i - intentional
if (f(i->second))
i = umap.erase(i);
else
++i;
}
示例4: umm_buckets
void umm_buckets(unordered_multimap<string, string> &folder)
{
std::cout << "folder buckets contain:\n";
for ( unsigned i = 0; i < folder.bucket_count(); ++i) {
std::cout << "bucket #" << i << " contains:";
for ( auto local_it = folder.begin(i); local_it!= folder.end(i); ++local_it )
std::cout << " " << local_it->first << ":" << local_it->second;
std::cout << std::endl;
}
}
示例5: consecutives
// 这里必须假设hash的操作是O(1)的
int consecutives(unordered_multimap<int, int> &hash,
int value,
bool ascending) { // true: 升序 false: 降序
int count = 0;
while (hash.count(value) > 0) {
++count;
hash.erase(value); // 非常重要!
value += ascending ? 1: (-1);
}
return count;
}
示例6: sketchUnorderedComparisonError
uint64_t sketchUnorderedComparisonError(const unordered_multimap<string, string>& map1, const unordered_multimap<string, string>& map2){
uint64_t res(0);
string beg,end;
for (auto it=map1.begin(); it!=map1.end(); ++it){
beg=it->first;
end=it->second;
auto ret = map2.equal_range(beg);
for (auto it2=ret.first; it2!=ret.second; ++it2){
if(isCorrect(end,it2->second)){
++res;
}
}
}
return res;
}
示例7: umm_out_key
void umm_out_key(unordered_multimap<string, string> &folder, char *key)
{
auto its = folder.equal_range(key); ///iterator for a keys values
for (auto it = its.first; it != its.second; ++it) {
cout << it->first << '\t' << it->second << endl;
}
}
示例8: buildLoopMemberSet
void SESELoop::buildLoopMemberSet(BasicBlock& backEdgeDestination, const unordered_multimap<BasicBlock*, BasicBlock*>& destToOrigin, unordered_set<BasicBlock*>& members, unordered_set<BasicBlock*>& entries, unordered_set<BasicBlock*>& exits)
{
// Build paths to back-edge start nodes.
unordered_set<BasicBlock*> sinkNodeSet;
auto range = destToOrigin.equal_range(&backEdgeDestination);
for (auto iter = range.first; iter != range.second; iter++)
{
sinkNodeSet.insert(iter->second);
}
auto pathsToBackNodes = findPathsToSinkNodes(&backEdgeDestination, sinkNodeSet);
// Build initial loop membership set
for (const auto& path : pathsToBackNodes)
{
members.insert(path.begin(), path.end());
}
// The path-to-sink-nodes algorithm won't follow back edges. Because of that, if the cycle contains a
// sub-cycle, we need to add its member nodes. This is probably handled by the loop membership refinement
// step from the "No More Gotos" paper, but as noted below, we don't use that step.
unordered_set<BasicBlock*> newMembers;
for (BasicBlock* bb : members)
{
auto range = loopMembers.equal_range(bb);
for (auto iter = range.first; iter != range.second; iter++)
{
newMembers.insert(iter->second);
}
}
members.insert(newMembers.begin(), newMembers.end());
for (BasicBlock* member : members)
{
loopMembers.insert({&backEdgeDestination, member});
for (BasicBlock* pred : predecessors(member))
{
if (members.count(pred) == 0)
{
entries.insert(member);
}
}
for (BasicBlock* succ : successors(member))
{
if (members.count(succ) == 0)
{
exits.insert(succ);
}
}
}
}
示例9: getPath
void getPath(string &start, string &end, unordered_set<string> &dict,
unordered_multimap<string, string> &father, vector<vector<string>> &ret, vector<string> &path)
{
path.push_back(start);
if (start == end) {
ret.push_back(vector<string>(path.rbegin(), path.rend()));
} else {
auto range = father.equal_range(start);
for (auto ite = range.first; ite != range.second; ++ite) {
getPath(ite->second, end, dict, father, ret, path);
}
}
path.pop_back();
}
示例10: percentStrandedErrors
double percentStrandedErrors(uint64_t k, const string& seq, const unordered_multimap<string, string>& genomicKmers, char nuc){
double inter(0);
string kmer;
kmer.reserve(k);
uint64_t i(0);
for(; i+k<=seq.size(); ++i){
kmer=seq.substr(i,k);
if(kmer.size()!=k){cout<<"wtf"<<endl;}
auto range(genomicKmers.equal_range(kmer.substr(0,nuc)));
for(auto it(range.first); it!=range.second; ++it){
if(isCorrect(kmer.substr(nuc),it->second)){
++inter;
break;
}else{}
}
}
return double(100*inter/(seq.size()-k+1));;
}
示例11: reconcile
void reconcile( PhyloTree< TreeNode >& reftree, string treefile, unordered_multimap<string, string>& gene_map, string output_fname ){
// read ref tree
ifstream treein(treefile.c_str());
if(!treein.is_open()){
cerr << "Unable to read file " << treefile << endl;
return;
}
//
// read a tree with edge numberings from pplacer
// assume jplace format with treestring on second line
//
string line;
string treestring;
getline( treein, line );
getline( treein, treestring );
size_t qpos = treestring.find("\"");
size_t rqpos = treestring.rfind("\"");
treestring = treestring.substr( qpos + 1, rqpos - qpos - 1);
stringstream treestr(treestring);
// cout << "Trying to read " << treestring << endl;
PhyloTree< TreeNode > tree;
tree.readTree( treestr );
cout << "The read tree has " << tree.size() << " nodes\n";
//
// remove edge numbers
// assume jplace format
//
std::unordered_map<int,int> edgenum_map;
for(int i=0; i<tree.size(); i++){
size_t atpos = tree[i].name.find("{");
size_t ratpos = tree[i].name.rfind("}");
int edgenum = -1;
if( atpos == string::npos ){
edgenum = atoi(tree[i].name.c_str());
}else{
edgenum = atoi(tree[i].name.substr(atpos+1, ratpos - atpos - 1).c_str());
// cerr << "node " << i << " edgenum is " << tree[i].name.substr(atpos+1, ratpos - atpos - 1) << " name is " << tree[i].name.substr(0, atpos) << endl;
tree[i].name = tree[i].name.substr(0, atpos);
}
// cerr << "mapping " << i << " to " << edgenum << "\n";
edgenum_map.insert(make_pair(i,edgenum));
}
// cerr << "Done removing edge numbers\n";
//
// construct boost graphs of the trees
//
PhyloGraph pg;
make_graph( tree, pg );
PhyloGraph refpg;
make_graph( reftree, refpg );
//
// Phase 3: construct map to reference tree
//
// a) cut gene tree on each edge
// b) compute splits at cut point
// c) cut species tree on each edge
// d) determine which species tree split matches the gene tree split best
// e) write out the split match
// plan for later...
// c) compute PD on either side of cut point
// d) logical AND splits with reftree splits
// e) compute minimum spanning tree among remaining nodes
// f) compute PD of minimum spanning trees
//
vector< boost::dynamic_bitset<> > pg_splitlist;
vector<Vertex> pg_vertex_map;
enumerate_splits( pg, pg_splitlist, pg_vertex_map );
cout << "Done with gene tree splits\n";
vector< boost::dynamic_bitset<> > ref_splitlist;
vector<Vertex> ref_vertex_map;
enumerate_splits( refpg, ref_splitlist, ref_vertex_map );
// need a mapping from vertex numbers in refpg to vertex numbers in pg
cout << "Making gene tree map\n";
unordered_map< string, int > gtmap;
for(int i=0; i<tree.size(); i++){
if(tree[i].children.size()==0){
gtmap.insert(make_pair(tree[i].name, i));
}
}
cout << gtmap.size() << " genes mapped\n";
cout << "Making species to gene tree map\n";
vector< vector< int > > species_to_gene_map; // maps split IDs in species tree to split IDs in gene tree
for(int i=0; i<refpg.V; i++){
if(ref_vertex_map[i]==-1)
continue;
// which genes does this species contain?
pair< unordered_multimap<string,string>::iterator, unordered_multimap<string,string>::iterator> iter;
iter = gene_map.equal_range(reftree[i].name);
vector<int> curmap;
if(iter.first ==iter.second){
cerr << "Error no mapping found for " << reftree[i].name << endl;
//.........这里部分代码省略.........
示例12: swap
void swap(unordered_multimap<K, T, H, P, A> &m1,
unordered_multimap<K, T, H, P, A> &m2)
{
m1.swap(m2);
}
示例13: swap
inline void
swap(unordered_multimap<_Key, _Tp, _Hash, _Pred,
_Alloc, __cache_hash_code>& __x,
unordered_multimap<_Key, _Tp, _Hash, _Pred,
_Alloc, __cache_hash_code>& __y)
{ __x.swap(__y); }
示例14: 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();
}
示例15: 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;
}