本文整理汇总了C++中unordered_multimap::equal_range方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_multimap::equal_range方法的具体用法?C++ unordered_multimap::equal_range怎么用?C++ unordered_multimap::equal_range使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unordered_multimap
的用法示例。
在下文中一共展示了unordered_multimap::equal_range方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: 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);
}
}
}
}
示例3: 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();
}
示例4: 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;
}
示例5: 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));;
}
示例6: 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;
//.........这里部分代码省略.........
示例7: 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;
}