本文整理汇总了C++中multimap::end方法的典型用法代码示例。如果您正苦于以下问题:C++ multimap::end方法的具体用法?C++ multimap::end怎么用?C++ multimap::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multimap
的用法示例。
在下文中一共展示了multimap::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
//ifstream f("file.in");
//ofstream g("file.out");
ifstream f("lupu.in");
ofstream g("lupu.out");
f >> n >> x >> l;
for (i = 1; i <= n; i++)
{
f >> dist >> lana;
if (dist <= x)
{
dist = (x - dist) / l + 1;
oi.insert(make_pair(dist, lana));
}
}
it = oi.begin();
dist = it->first;
while (dist)
{
while (it != oi.end() && dist == it->first)
{
prque.push(it->second);
it++;
}
if (!prque.empty())
{
rez += (long long)prque.top();
prque.pop();
}
dist--;
}
g << rez;
return 0;
}
示例2: SV_SectorList_f
void SV_SectorList_f( void )
{
areaParms_t ap;
// ap.mins = mins;
// ap.maxs = maxs;
// ap.list = list;
// ap.count = 0;
// ap.maxcount = maxcount;
entStats.clear();
SV_AreaEntitiesTree(sv_worldSectors,&ap,0);
char mess[1000];
multimap<int,pair<int,list<CBBox> > >::iterator j;
for(j=entStats.begin();j!=entStats.end();j++)
{
sprintf(mess,"**************************************************\n");
Sleep(5);
OutputDebugString(mess);
sprintf(mess,"level=%i, count=%i\n",(*j).first,(*j).second.first);
Sleep(5);
OutputDebugString(mess);
list<CBBox>::iterator k;
for(k=(*j).second.second.begin();k!=(*j).second.second.end();k++)
{
sprintf(mess,"mins=%f %f %f, maxs=%f %f %f\n",
(*k).mMins[0],(*k).mMins[1],(*k).mMins[2],(*k).mMaxs[0],(*k).mMaxs[1],(*k).mMaxs[2]);
OutputDebugString(mess);
}
}
}
示例3: main
int main() {
int n, id, power, lower_power = 0, higher_power;
s.insert(make_pair(1000000000, 1));
scanf("%d", &n);
while (n--) {
scanf("%d %d", &id, &power);
multimap<int, int>::iterator p;
p = s.insert(make_pair(power, id));
if (p == s.begin()) {
++p;
printf("%d %d\n", id, p->second);
}
else if (p == s.end()) {
printf("%d %d\n", id, p->second);
}
else {
--p;
lower_power = p->first;
++p; ++p;
higher_power = p->first;
if ((higher_power - power) < (power - lower_power)) {
printf("%d %d\n", id, p->second);
}
else {
--p; --p;
printf("%d %d\n", id, p->second);
}
}
}
return 0;
}
示例4: locker
/* Look for mime handler in pool */
static RecollFilter *getMimeHandlerFromCache(const string& key)
{
PTMutexLocker locker(o_handlers_mutex);
string xdigest;
MD5HexPrint(key, xdigest);
LOGDEB(("getMimeHandlerFromCache: %s cache size %u\n",
xdigest.c_str(), o_handlers.size()));
multimap<string, RecollFilter *>::iterator it = o_handlers.find(key);
if (it != o_handlers.end()) {
RecollFilter *h = it->second;
hlruit_tp it1 = find(o_hlru.begin(), o_hlru.end(), it);
if (it1 != o_hlru.end()) {
o_hlru.erase(it1);
} else {
LOGERR(("getMimeHandlerFromCache: lru position not found\n"));
}
o_handlers.erase(it);
LOGDEB(("getMimeHandlerFromCache: %s found size %u\n",
xdigest.c_str(), o_handlers.size()));
return h;
}
LOGDEB(("getMimeHandlerFromCache: %s not found\n", xdigest.c_str()));
return 0;
}
示例5: loginReq
//handle login requests
int loginReq(struct request_login *rl)
{
string username = rl->req_username;
struct sockaddr_in strctAddr = getAddrStruct();
userToAddrStrct.insert(userToAddrStrct.end(), pair<string, struct sockaddr_in>(username, strctAddr));
return 0;
}
示例6: double
map<string, double> indri::query::ConceptSelectorFuns::normConceptScoreFreq(indri::api::QueryEnvironment & env,
map<string, int> conceptsFrq,
multimap<double, pair<string, string> > scoredConcepts_norm )
{
// extract concept freq for the concepts exist in scoredConcepts_norm and store it in a container
map<string, double> conceptsFrqExtr_norm;
double max_cf = 0;
double min_cf = std::numeric_limits<double>::infinity();;
for (auto itSc = scoredConcepts_norm.begin(); itSc != scoredConcepts_norm.end(); itSc++)
{
conceptsFrqExtr_norm[(itSc->second).second] = conceptsFrq[(itSc->second).second] / double(env.documentCount());
max_cf = max(max_cf, conceptsFrqExtr_norm[(itSc->second).second]);
min_cf = min(min_cf, conceptsFrqExtr_norm[(itSc->second).second]);
cout << "indri::query::ConceptSelectorFuns::normConceptScoreFreq: conceptsFrqExtr_norm: min_cf, max_cf: " << min_cf << ", " << max_cf << endl;
cout << "indri::query::ConceptSelectorFuns::normConceptScoreFreq: scoredConcepts_norm: " << (itSc->second).second << " " << itSc->first << endl;
cout << "indri::query::ConceptSelectorFuns::normConceptScoreFreq: conceptsFrq: " << (itSc->second).second << " " << conceptsFrq[(itSc->second).second] << endl;
}
// normalize the extracted concepts' scores
map<string, double> conceptsFrqExtr_norm1;
for (auto itCf = conceptsFrqExtr_norm.begin(); itCf != conceptsFrqExtr_norm.end(); itCf++)
{
conceptsFrqExtr_norm1[itCf->first] = (itCf->second-min_cf)/(max_cf-min_cf);
cout << "indri::query::ConceptSelectorFuns::normConceptScoreFreq: conceptsFrqExtr_norm1: " << itCf->first << " " << conceptsFrqExtr_norm1[itCf->first] << endl;
}
return conceptsFrqExtr_norm1;
}
示例7: dfs
bool dfs(string &s){
e.insert(s);
v.push_back(s);
for(multimap<string,string>::iterator it=h.lower_bound(s);
it!=h.end()&&it->first==s; ++it){
if(e.find(it->second) != e.end()){
continue;
}
map<string, int>::iterator mi = r.find(it->second);
if(mi != r.end()){
/*
v.push_back(it->second);
reverse(v.begin(), v.end());
for(vector<string>::iterator vi=v.begin(); vi!=v.end(); vi++){
cout<<*vi<<" ";
}
cout<<endl;
*/
if(--mi->second<=0){
r.erase(mi);
}
return true;
} else if(dfs(it->second)){
return true;
}
}
v.pop_back();
return false;
}
示例8: search_image
void Vocabulary::search_image(int imgNum, vector<int> images, multimap<int, int> &imageScore, vector<int> &rankedScore)
{
for(int i=0; i<imgNum; i++)
{
imageScore.insert(pair<int,int>(i+1,0));
}
cout<<imageScore.size()<<endl;
int score=0;
for(auto ite=imageScore.begin(); ite!=imageScore.end(); ite++)
{
for(int i=0; i<images.size(); i++)
{
if((*ite).first==images[i])
{
(*ite).second++;
}
}
///normalize
float normalized_score=(float)(*ite).second/(float)images.size();
// (*ite).second=normalized_score;
cout.precision(5);
cout<<(*ite).first<<" "<<(*ite).second<<" "<<normalized_score<<endl;
rankedScore.push_back((*ite).second);
}
}
示例9: while
void DFHack::EventManager::unregisterAll(Plugin* plugin) {
for ( auto i = handlers[EventType::TICK].find(plugin); i != handlers[EventType::TICK].end(); i++ ) {
if ( (*i).first != plugin )
break;
//shenanigans to avoid concurrent modification
EventHandler getRidOf = (*i).second;
bool didSomething;
do {
didSomething = false;
for ( auto j = tickQueue.begin(); j != tickQueue.end(); j++ ) {
EventHandler candidate = (*j).second;
if ( getRidOf != candidate )
continue;
tickQueue.erase(j);
didSomething = true;
break;
}
} while(didSomething);
}
for ( size_t a = 0; a < (size_t)EventType::EVENT_MAX; a++ ) {
handlers[a].erase(plugin);
}
return;
}
示例10: plotCorrespondences
void POICorrespondence::plotCorrespondences(const Mat& img1, vector<Point>& corners1, const Mat& img2,
multimap<Point, Point, PointCompare> &correspondences, Mat& dst)
{
dst.create(max(img1.rows, img2.rows), img1.cols + img2.cols, img1.type());
//ROI of bigger image pointing to first half
Mat dstImg1 = dst(Rect(0, 0, img1.cols, img1.rows));
//ROI of bigger image pointing to second half
Mat dstImg2 = dst(Rect(img1.cols, 0, img2.cols, img2.rows));
img1.copyTo(dstImg1);
img2.copyTo(dstImg2);
//Draw green lines
Scalar colorL(0, 255, 0);
int xP2;
map<Point, Point>::iterator it;
for (it = correspondences.begin(); it != correspondences.end(); ++it)
{
//Displace point in image2 since its located in the second half of the big image
xP2 = it->second.x + img1.cols;
line(dst, it->first, Point(xP2, it->second.y), colorL, 1, CV_AA);
}
}
示例11: get
int get(int key){
multimap<int, V2C>::iterator it = key2Value2Count.find(key);
if(it != key2Value2Count.end())
{
V2C& tmp = it->second;
#if 0
pair <multimap<int,int>::iterator, multimap<int,int>::iterator> ret;
ret = count2Key.equal_range(tmp.count);
for(multimap<int,int>::iterator it=ret.first; it!=ret.second;++it)
{
if(it->second == key)
{
count2Key.erase(it);
tmp.count++;
count2Key.insert(pair<int, int>(tmp.count, key));
break;
}
}
#endif
count2Key.erase(tmp.it);
list<int>::iterator iit = count2Key.insert(count2Key.end(),key);
tmp.it=iit;
#if 0
cout << "cache hit" << key << endl;
#endif
return tmp.value;
}
else
{
// cout << "cache miss" << key << endl;
return -1;
}
}
示例12: set
void set(int key, int value)
{
multimap<int, V2C>::iterator it = key2Value2Count.find(key);
if(it != key2Value2Count.end())
{
V2C& tmp = it->second;
tmp.value = value;
get(key);
}
else
{
if(count >= max)
{
list<int>::iterator cit=count2Key.begin();
// cout << "cache eviction: " << *cit << endl;
key2Value2Count.erase(*cit);
count2Key.erase(cit);
count--;
}
list<int>::iterator iit = count2Key.insert(count2Key.end(),key);
V2C tmp;
tmp.value = value;
tmp.it = iit;
// cout << "xxxx" <<*iit<<endl;
key2Value2Count.insert(pair<int, V2C>(key, tmp));
count++;
}
}
示例13: timeout_alarm
void timeout_alarm(int) {
cout << "!timeout alarm" << endl;
struct timeval tv;
struct timezone tz;
multimap<long, client_timeout>::iterator i;
long ts;
for (i = timestamp_map.begin(); i != timestamp_map.end();) {
gettimeofday(&tv, &tz); // pobranie aktualnego czasu
ts = tv.tv_sec * 1000 + tv.tv_usec / 1000; // zamiana na ms
if (i->first > ts)
break;
map<int, resource_clients>::iterator j = resource_map.find(
i->second.resource_id);
list<client>::iterator k = find_by_pid(j->second.waiting_clients,
i->second.pid);
j->second.waiting_clients.erase(k); // usuniecie klienta z kolejki oczekujacych
send_response(i->second.pid, TIMEDOUT);
timestamp_map.erase(i++); // usuniecie klienta z kolejki timeout
try_grant(j); // proba przydzielenia zasobu
}
if (!timestamp_map.empty()) {
useconds_t alrm = (i->first - ts) * 1000;
ualarm(alrm, 0);
}
cout << "!end of timeout alarm" << endl;
}
示例14: checkBadDest
int Slave::checkBadDest(multimap<int64_t, Address>& sndspd, vector<Address>& bad)
{
bad.clear();
if (sndspd.empty())
return 0;
int m = sndspd.size() / 2;
multimap<int64_t, Address>::iterator p = sndspd.begin();
for (int i = 0; i < m; ++ i)
++ p;
int64_t median = p->first;
int locpos = 0;
for (multimap<int64_t, Address>::iterator i = sndspd.begin(); i != sndspd.end(); ++ i)
{
if (i->first > (median / 2))
return bad.size();
bad.push_back(i->second);
locpos ++;
}
return bad.size();
}
示例15: main
int main() {
int i;
scanf("%d", &n); sq_n = ceil(sqrt(n));
for(i = 0; i < n; i++) {
scanf("%d", &a[i]);
mp.insert(make_pair(a[i], i));
bit[i] = (i & -i);
}
for(i = n; i < n + 4; i++)
bit[i] = (i & -i);
scanf("%d", &q);
for(i = 0; i < q; i++) {
scanf("%d %d %d", &ql[i], &qr[i], &qk[i]);
ql[i]--; qr[i]--;
qs[i] = i;
}
sort(qs, qs + q, cmp_k);
auto it = mp.begin();
for(i = 0; i < q; i++) {
for(; it != mp.end() && it->first <= qk[qs[i]]; ++it)
add(it->second, -1);
ql[qs[i]] = get(ql[qs[i]], qr[qs[i]]);
}
for(i = 0; i < q; i++)
printf("%d\n", ql[i]);
return 0;
}