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


C++ multimap::equal_range方法代码示例

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


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

示例1: writeMetadataFile

    void writeMetadataFile( const string coll, boost::filesystem::path outputFile, 
                            map<string, BSONObj> options, multimap<string, BSONObj> indexes ) {
        log() << "\tMetadata for " << coll << " to " << outputFile.string() << endl;

        ofstream file (outputFile.string().c_str());
        uassert(15933, "Couldn't open file: " + outputFile.string(), file.is_open());

        bool hasOptions = options.count(coll) > 0;
        bool hasIndexes = indexes.count(coll) > 0;

        if (hasOptions) {
            file << "{options : " << options.find(coll)->second.jsonString();

            if (hasIndexes) {
                file << ", ";
            }
        } else {
            file << "{";
        }

        if (hasIndexes) {
            file << "indexes:[";
            for (multimap<string, BSONObj>::iterator it=indexes.equal_range(coll).first; it!=indexes.equal_range(coll).second; ++it) {
                if (it != indexes.equal_range(coll).first) {
                    file << ", ";
                }
                file << (*it).second.jsonString();
            }
            file << "]";
        }
        file << "}";
    }
开发者ID:tanakh,项目名称:mongo,代码行数:32,代码来源:dump.cpp

示例2: readtable

void ReservationTable::readtable()
{
	ifstream fin;
	fin.open("ReservationTable.txt",ifstream::in);
	if(!fin) 
	{
		cerr<<"Cannot open INVENTORY file!"<<endl;
		system("pause");
		exit(1);	
	}
	string str;
	getline(fin,str);
	stages=stoi(str);
	getline(fin,str);
	time=stoi(str);
	int i=0,j;
	cout<<"Reservation Table:\n  ";
	for(j=1; j<=time; ++j)
		cout<<"  "<<j;
	cout<<endl;
	while(!fin.eof())
	{
		getline(fin,str);
		++i;
		j=0;
		cout<<"S"<<i<<" ";
		for (string::iterator it=str.begin(); it!=str.end(); ++it)
		{
			cout<<" ";
			if(*it=='1')
			{ cout<<"X"; rtable.insert(pair<int,int>(i,++j)); }
			else if(*it=='0')
			{ cout<<" "; ++j; }
		}
		cout<<endl;
	}
	fin.close();
	vector<int> row;
	multimap<int,int>::iterator it;
	list<int>::iterator f;
	for(i=1; i<=stages; i++)
    {
		for(it=rtable.equal_range(i).first; it!=rtable.equal_range(i).second; ++it)
		row.push_back((*it).second);
		for(size_t p=0; p<row.size(); ++p)
		for(size_t q=p+1; q<row.size(); ++q)
		{
			f=find(forbidden.begin(),forbidden.end(),row[q]-row[p]);
			if(f==forbidden.end())
			forbidden.push_back(row[q]-row[p]);
		}
		row.clear();
	}
	stable_sort(forbidden.begin(),forbidden.end());
	cout<<"\nForbidden latencies: ";
	for (list<int>::iterator it=forbidden.begin(); it!=forbidden.end(); ++it)
    cout<<" "<<*it;
	cout<<endl;
}
开发者ID:prkaroma,项目名称:Minimum-Average-Latency,代码行数:59,代码来源:MAL.cpp

示例3: main

int main()
{
    init();

    rdio(namenum);

    lli n;
    cin >> n;
    if (M.count(n) > 0) {
        for (auto it = M.equal_range(n).first; it != M.equal_range(n).second; ++it) {
            cout << it->second << endl;
        }
    } else cout << "NONE" << endl;

    return 0;
}
开发者ID:fyh,项目名称:training,代码行数:16,代码来源:namenum.cpp

示例4: delete_author

void delete_author(multimap<string, string> &books, const string &name){
	auto p = books.equal_range(name);
	if (p.first == p.second)
		cout << "No author named " << name << endl;
	else
		books.erase(p.first, p.second);
}
开发者ID:buaakq,项目名称:cpp_primer,代码行数:7,代码来源:task_11_31.cpp

示例5: solve

    void solve(string cur)
    {
        // cout << cur << endl;
        while (true)
        {
            pair<trav_it, trav_it> ret = trav.equal_range(cur);

            if (ret.first == ret.second) break;
            else
            {
                // cout << "\tnot yet" << endl;
                trav_it to_del=ret.first;
                string next = ret.first->second;
                for (trav_it it = ret.first; it != ret.second; ++it)
                {
                    if (it->second < next) 
                    {
                        next = it->second;
                        to_del = it;
                    }
                }
                // cout << "\t" << next << endl;
                
                trav.erase(to_del);
                solve(next);
            }
        }
        ans.push_back(cur);
    }
开发者ID:Rayleigh0328,项目名称:OJ,代码行数:29,代码来源:332.cpp

示例6: writeMetadataFile

    void writeMetadataFile( const string coll, boost::filesystem::path outputFile, 
                            map<string, BSONObj> options, multimap<string, BSONObj> indexes ) {
        toolInfoLog() << "\tMetadata for " << coll << " to " << outputFile.string() << std::endl;

        bool hasOptions = options.count(coll) > 0;
        bool hasIndexes = indexes.count(coll) > 0;

        BSONObjBuilder metadata;

        if (hasOptions) {
            metadata << "options" << options.find(coll)->second;
        }

        if (hasIndexes) {
            BSONArrayBuilder indexesOutput (metadata.subarrayStart("indexes"));

            // I'd kill for C++11 auto here...
            const pair<multimap<string, BSONObj>::iterator, multimap<string, BSONObj>::iterator>
                range = indexes.equal_range(coll);

            for (multimap<string, BSONObj>::iterator it=range.first; it!=range.second; ++it) {
                 indexesOutput << it->second;
            }

            indexesOutput.done();
        }

        ofstream file (outputFile.string().c_str());
        uassert(15933, "Couldn't open file: " + outputFile.string(), file.is_open());
        file << metadata.done().jsonString();
    }
开发者ID:ANTco,项目名称:mongo,代码行数:31,代码来源:dump.cpp

示例7:

 vector<int> query_quad(size_t id) {
     vector<int> ret;
     auto multimap_qry = flat_tree.equal_range(id);
     for(auto it = multimap_qry.first; it != multimap_qry.second; ++it){
         ret.push_back(it->second);
     }
     return ret;
 }
开发者ID:jokoon,项目名称:eio,代码行数:8,代码来源:grid_search.cpp

示例8: query

 void query(Vec2i pos, vector<Transformable*> &result)
 {
     //auto range = buckets.equal_range(Vec2i(pos / resolution));
     auto range = obj_buckets.equal_range(pos);
     for (auto i = range.first; i != range.second; ++i)
     {
         result.push_back(i->second);
     }
 }
开发者ID:jokoon,项目名称:eio,代码行数:9,代码来源:grid_search.cpp

示例9: pick

	int pick(int target) {
		auto p = mmnums.equal_range(target);
		if (p.first == p.second) return -1;
		vector<int> idxs;
		for (auto it = p.first; it != p.second; ++it) {
			idxs.push_back(it->second);
		}
		return idxs[rand() % idxs.size()];
	}
开发者ID:wonghoifung,项目名称:tips,代码行数:9,代码来源:medium_random_pick_index.cpp

示例10: checkPrimitive

      void UnifyTraverser::checkPrimitive( multimap<HashKey,PrimitiveSharedPtr> &v, Primitive * p )
      {
        // Unify Primitives of each type
        DP_ASSERT( m_unifyTargets & UT_PRIMITIVE );

        if( !optimizationAllowed( p->getSharedPtr<Primitive>() ) )
        {
          return;
        }

#if CHECK_HASH_RESULTS
        PrimitiveWeakPtr foundPrimitive = nullptr;
#endif

        // look for all Primitives of the same type already encountered, with the same hash String (should not be too many!)
        bool found = false;
        HashKey hashKey = p->getHashKey();
        typedef multimap<HashKey,PrimitiveSharedPtr>::const_iterator I;
        pair<I,I> itp = v.equal_range( hashKey );
        PrimitiveSharedPtr primitive = p->getSharedPtr<Primitive>();
        for ( I it = itp.first ; it != itp.second && !found ; ++it )
        {
          // check if any of those Primitives is equal or equivalent to the currently handled
          found =   ( primitive == it->second )
                ||  p->isEquivalent( it->second, getIgnoreNames(), false );
          if ( found && ( primitive != it->second ) )
          {
            // there is an equivalent Primitive, that's not the same as the currently handled -> store as replacement
            m_replacementPrimitive = it->second;
          }
#if CHECK_HASH_RESULTS
          if ( found )
          {
            foundPrimitive = it->second.getWeakPtr();
          }
#endif
        }

#if CHECK_HASH_RESULTS
        // just to make sure, that we find the same equivalent Primitive with exhaustive search (no hash string usage)
        bool checkFound = false;
        for ( I it = mm.begin() ; it != mm.end() && !checkFound ; ++it )
        {
          checkFound = ( primitive == it->second )
                    || pT->isEquivalent( SharedHandle<T>::Lock(it->second), getIgnoreNames(), false );
          DP_ASSERT( !checkFound || ( primitive == it->second ) || ( foundPrimitive == it->second.getWeakPtr() ) );
        }
        DP_ASSERT( found == checkFound );
#endif

        // if we did not found that Primitive (or an equivalent one) before -> store it for later searches
        if ( ! found )
        {
          v.insert( make_pair( hashKey, primitive ) );
        }
      }
开发者ID:raedwulf,项目名称:pipeline,代码行数:56,代码来源:UnifyTraverser.cpp

示例11:

/// find operator with specific string and arity
decltype(opers)::iterator find_oper(const string &str, bool unary)
{
	auto range = opers.equal_range(str);
	auto oit = range.first;
	for (; oit != range.second; ++oit)
	{
		if (oit->second.unary == unary)
			break;
	}
	return oit == range.second ? opers.end() : oit;
}
开发者ID:r-lyeh,项目名称:eve,代码行数:12,代码来源:calculate.cpp

示例12: getOptValues

bool getOptValues(vector<string>& values, multimap<string,string>& optmap,const string& key){
	values.clear();
	pair<multimap<string,string>::iterator,multimap<string,string>::iterator> findI=optmap.equal_range(key);
	if(findI.first==optmap.end())
		return false;
	
	for(multimap<string,string>::iterator i=findI.first;i!=findI.second;i++)
		values.push_back(i->second);
	
	return true;
}
开发者ID:albertwcheng,项目名称:clustergram,代码行数:11,代码来源:AdvGetOpt.cpp

示例13: printmultimap2

void printmultimap2(multimap <string, string> &authors)
{
	typedef multimap<string,string>::iterator authors_it;
	pair< authors_it, authors_it > val_type = authors.equal_range("Barth, John");
	//multimap<string,string>::iterator val_type = authors.equal_range("Barth, John");
	while (val_type.first != val_type.second)
	{
		cout << val_type.first->first << "----->" << val_type.first->second << endl;
		++val_type.first;
	}
}
开发者ID:ZMacer,项目名称:c--_example,代码行数:11,代码来源:multimap.cpp

示例14: deleteAuthor

void deleteAuthor(multimap<string, string> &db, string author)
{
    pair<db_iter, db_iter> range = db.equal_range(author);

    if (range.first != range.second) {
        cout << "author: " << author << " found and del" << endl;
    } else {
        cout << "author: " << author << " not found" << endl;
    }

    db.erase(range.first, range.second);
}
开发者ID:ckelsel,项目名称:cpp_primer,代码行数:12,代码来源:e10_27.cpp

示例15: eraseName

void eraseName(multimap<string, string>& m_map)
{
	string authorname;
	cout << "Which author do you want to delete ?" << endl;
	cin >> authorname;
	pair<multimap<string, string>::iterator, multimap<string, string>::iterator> it = m_map.equal_range(authorname);
	if (it.first != it.second){
		m_map.erase(it.first, it.second);
	}
	else
		cout << "Can't find the author !" << endl;
}
开发者ID:XiongQingHui,项目名称:test,代码行数:12,代码来源:10-27.cpp


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