本文整理汇总了C++中multimap::find方法的典型用法代码示例。如果您正苦于以下问题:C++ multimap::find方法的具体用法?C++ multimap::find怎么用?C++ multimap::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multimap
的用法示例。
在下文中一共展示了multimap::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sumaElementosMultimap
//devuelve la suma de los elementos de 'mi_multimap' que usan 'llave' como llave
int sumaElementosMultimap(multimap<string, int> mi_multimap, string llave)
{
int cont = 0; // Creo una variable cont
while(mi_multimap.count(llave) != 0) //mientras el conteo de las llaves no sea cero
{
int c = mi_multimap.find(llave)-> second; //La variable c toma el valor del segundo elemento de la llave
cont = cont + c; //Suma los valores
mi_multimap.erase(mi_multimap.find(llave)); //se borra el ultimo elemento
}
return cont; //devuelve la suma
}
示例2: logoutReq
//handle login requests
int logoutReq(struct request_logout *rl)
{
string username = getUserOfCurrAddr();
multimap<string, struct sockaddr_in>::iterator sockIt = userToAddrStrct.find(username);
userToAddrStrct.erase(sockIt);
map<string,vector<string> >::iterator git;
git = usrTlkChan.find(username);
if(git != usrTlkChan.end()) {
usrTlkChan.erase(username);
}
//erase user on channels in chanTlkUser
//for(int ick=0; ick<channels.size(); ick++) {
map<string,vector<pair<string,struct sockaddr_in> > >::iterator sat;
for(sat=chanTlkUser.begin(); sat != chanTlkUser.end(); sat++) {
map<string,vector<pair<string,struct sockaddr_in> > >::iterator itck = chanTlkUser.find(sat->first);
vector<pair<string,struct sockaddr_in> > usersC = itck->second;
for(int j=0; j<usersC.size(); j++) {
if(usersC[j].first == username) {
usersC.erase(usersC.begin()+j);
}
}
chanTlkUser.erase(itck);
chanTlkUser.insert(pair<string,vector<pair<string,struct sockaddr_in> > >(sat->first,usersC));
}
return 0;
}
示例3: 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;
}
示例4: if
// Maps highest frequency of codons to each amino acid
vector<float> CodonFrequency::createMaxMap(multimap<char, pair<int, float> > AAtoCodonMap){
// cout << "------maxFreq------" << endl;
vector<float> maxMap;
float maxFreq;
// Loops through all amino acids
// If char rep of AA exists
// Calculate highest frequency to maxMap
for (char AA = 'A'; AA <= 'Z'; AA++) {
int addressAA = AA - 65;
if (AA == 'B' || AA == 'J' || AA == 'O' || AA == 'U' || AA == 'X') {
maxMap.push_back(-1);
// continue;
}
else if (AAtoCodonMap.count(AA) > 1) {
maxFreq = findMax(AAtoCodonMap, AA);
maxMap.push_back(maxFreq);
// continue;
} else if (AAtoCodonMap.count(AA) == 1) {
maxMap.push_back(AAtoCodonMap.find(AA)->second.second);
}
// to print values: comment out the continues in if statements
// cout << addressAA << " " << AA << " " << maxMap[addressAA] << endl;
}
return maxMap;
}
示例5: 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;
}
}
示例6: 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++;
}
}
示例7: whoReq
//handle login requests
int whoReq(struct request_who *rw)
{
string username = getUserOfCurrAddr();
struct sockaddr_in address;
string chaNel = (string)(rw->req_channel);
multimap<string, struct sockaddr_in>::iterator ui = userToAddrStrct.find(username);
map<string,vector<pair<string,struct sockaddr_in> > >::iterator vi;
if((vi = chanTlkUser.find(chaNel)) == chanTlkUser.end()) {
return -1;
}
int numCHAN = (vi->second).size();
vector<pair<string,struct sockaddr_in> > v = vi->second;
address = ui->second;
struct text_who *msg = (struct text_who*)malloc(sizeof(struct text_who)+(numCHAN* sizeof(struct user_info)));
msg->txt_type= TXT_WHO;
msg->txt_nusernames = numCHAN;
const char* str = chaNel.c_str();
strcpy(msg->txt_channel, str);
for (int i = 0; i<v.size(); i++) {
const char* tstr = v[i].first.c_str();
strcpy(((msg->txt_users)+i)->us_username, tstr);
}
int size = sizeof(struct sockaddr);
int res= sendto(sockfd, msg, (sizeof(struct text_who)+(numCHAN* sizeof(struct user_info))), 0, (struct sockaddr*)&address, size);
if (res == -1) {
return -1;
}
free(msg);
return 0;
}
示例8: eliminate_left_recursion
void eliminate_left_recursion(multimap<string,string> &rules)
{
//cout<<"Left Recurse"<<endl;
multimap<string,string>::iterator it;
multimap<string,string>::iterator it1;
string non_term,non_term_1;
string RHS,leftmost,RHS1,remaining;
const char *rhs;
//string tok_rhs;
char *tok_rhs;
char r[1000];
string new_rhs;
for(int i=0;i<n_t.size();i++)
{
for(int j=0;j<i;j++)
{
it=rules.find(n_t[i]);
non_term=(*it).first;
for(;it!=rules.end() && (((*it).first.compare(non_term))==0);it++)
{
RHS=(*it).second;
rhs=RHS.c_str();
strcpy(r,rhs);
tok_rhs=strtok(r," ");
remaining.copy(r,strlen(r));
leftmost.copy(tok_rhs,strlen(tok_rhs));
if(leftmost.compare(n_t[j])==0)
{
new_rhs.clear();
it1=rules.find(n_t[j]);
non_term_1=(*it1).first;
for(;it1!=rules.end() && (((*it1).first.compare(non_term_1))==0);it1++)
{
RHS1=(*it1).second;
new_rhs.append(RHS1).append(remaining);
rules.erase(it);
rules.insert(pair<string,string>(non_term,new_rhs));
}
}
}
}
eliminate_immediate_left_recursion(rules,i);
}
}
示例9: copyrandom
void copyrandom(struct node *newnode,struct node *root)
{
if(root==NULL)
return;
multimap<struct node *,struct node *>::iterator i;
i=m.find(root->random);
newnode->random=i->second;
copyrandom(newnode->left,root->left);
copyrandom(newnode->right,root->right);
}
示例10: removeFromTickQueue
static void removeFromTickQueue(EventHandler getRidOf) {
for ( auto j = tickQueue.find(getRidOf.freq); j != tickQueue.end(); ) {
if ( (*j).first > getRidOf.freq )
break;
if ( (*j).second != getRidOf ) {
j++;
continue;
}
j = tickQueue.erase(j);
}
}
示例11: eraseName
void eraseName(multimap<string, string>& m_map)
{
string authorname;
cout << "Which author do you want to delete ?" << endl;
cin >> authorname;
multimap<string, string>::iterator it = m_map.find(authorname);
if (it != m_map.end())
m_map.erase(authorname);
else
cout << "Can't find the author !" << endl;
}
示例12: printmultimap
void printmultimap(multimap <string, string> &authors)
{
typedef multimap <string, string>::size_type sz_type;
sz_type co = authors.count("Barth, John");
//cout << count;
multimap <string, string>::iterator iter = authors.find("Barth, John");
for (sz_type cnt = 0; cnt != co; ++cnt,++iter)
{
cout << iter->first << ":--->" << iter->second << endl;
}
}
示例13: markRead
//O(logn)
void Library::markRead(string titleToMark){
map<string,string>::iterator it = unreadKeyTitle.find(titleToMark);
string toFind = it->second;
multimap<string,string>::iterator i = unreadKeyAuth.find(toFind);
if (it!=unreadKeyTitle.end()){
read.insert(pair<string, string>(it->second, it->first));
cout << "You've read " << '\"' << it->first << "!" << '\"' << endl;
unreadKeyAuth.erase(i);
unreadKeyTitle.erase(it);
}
}
示例14: checkValidAddr
//check if current request address is valid or exist in map
int checkValidAddr(struct request *r)
{
string realAddrString = getAddr_string();
string smiAddrString = getSemiAddr_string();
map<pair<string,string>,string>::iterator it = addrToUser.find(pair<string,string>(realAddrString,smiAddrString));
if(it == addrToUser.end()) {
cout << "super baddd addressss mann\n";
cout << realAddrString << " that THING\n";
return -1;
}
return 0;
}
示例15: solve
void solve(multimap<string, string>& dic, string seq, string ans)
{
for (unsigned int i = 1; i <= seq.size(); ++i) {
string h = seq.substr(0, i), rem = seq.substr(i);
for (multimap<string, string>::iterator it = dic.find(h); it != dic.end() && (*it).first == h; ++it) {
if (rem.empty())
cout << ans << (*it).second << "." << endl;
else
solve(dic, rem, ans + (*it).second + " ");
}
}
return;
}