本文整理汇总了C++中multimap::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ multimap::erase方法的具体用法?C++ multimap::erase怎么用?C++ multimap::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multimap
的用法示例。
在下文中一共展示了multimap::erase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logoutReq
//handle login requests
int logoutReq(struct request_logout *rl)
{
string realAddrString = getAddr_string();
string username = getUserOfCurrAddr();
string tmpaddr;
map<string, struct sockaddr_in>::iterator sockIt = userToAddrStrct.find(username);
userToAddrStrct.erase(sockIt);
multimap<pair<string,string>, string>::iterator i;
for(i=addrToUser.begin(); i!=addrToUser.end(); i++) {
if(i->second == username) {
tmpaddr = i->first.first;
cout << "deleting 1 \n";
addrToUser.erase(i);
}
}
multimap<string, pair<string,string> >::iterator ii;
for(ii=userToAddr.begin(); ii!=userToAddr.end(); ii++) {
if(ii->first == username) {
cout << "deleting 2 \n";
userToAddr.erase(ii);
}
}
// look for user in channel listen
//look for user in channel talk
map<string,string>::iterator git;
git = usrTlkChan.find(username);
if(git != usrTlkChan.end()) {
cout << "deleting 5 \n";
usrTlkChan.erase(username);
}
//erase user on channels in chanTlkUser
for(int ick=0; ick<channels.size(); ick++) {
cout << "in outerr \n";
map<string,vector<string> >::iterator itck = chanTlkUser.find(channels[ick]);
vector<string> usersC = itck->second;
for(int j=0; j<usersC.size(); j++) {
if(usersC[j] == username) {
cout << "deleting user: " << usersC[j] << " \n";
usersC.erase(usersC.begin()+j);
}
}
chanTlkUser.erase(itck);
chanTlkUser.insert(pair<string,vector<string> >(channels[ick],usersC));
}
return 0;
}
示例2: 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;
}
示例3: 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);
}
示例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: 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;
}
示例6: fun
int fun(){
int i;
for(i=1;i<root;i++){
if(freq[i] ==0 ){
leaf.push(i);
}
}
int f, p;
i = 0;
while(! leaf.empty() ){
f = leaf.top(); leaf.pop();
p = node[i];
edge.insert( make_pair(p, f) );
if(--freq[p] == 0 && p < root-1){
leaf.push(p);
}
i++;
}
edge.erase(0);
printf("(");
traceback(root-1);
printf(")\n");
edge.clear();
}
示例7: manageTickEvent
static void manageTickEvent(color_ostream& out) {
if (!df::global::world)
return;
unordered_set<EventHandler> toRemove;
int32_t tick = df::global::world->frame_counter;
while ( !tickQueue.empty() ) {
if ( tick < (*tickQueue.begin()).first )
break;
EventHandler handle = (*tickQueue.begin()).second;
tickQueue.erase(tickQueue.begin());
handle.eventHandler(out, (void*)tick);
toRemove.insert(handle);
}
if ( toRemove.empty() )
return;
for ( auto a = handlers[EventType::TICK].begin(); a != handlers[EventType::TICK].end(); ) {
EventHandler handle = (*a).second;
if ( toRemove.find(handle) == toRemove.end() ) {
a++;
continue;
}
a = handlers[EventType::TICK].erase(a);
toRemove.erase(handle);
if ( toRemove.empty() )
break;
}
}
示例8: 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++;
}
}
示例9: 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;
}
示例10: 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);
}
示例11: Erasing_Prescribed_Candidates
void CDetCandit::Erasing_Prescribed_Candidates(multimap<double, size_t>& FeedbackCase_mm)
{
if((int)FeedbackCase_mm.size() > FEEDBACK_CASES_NUM){
for(int num = FeedbackCase_mm.size() - FEEDBACK_CASES_NUM; num > 0; num--){
FeedbackCase_mm.erase(FeedbackCase_mm.begin());
}
}
}
示例12: setResponseHeader
void setResponseHeader(const char* name, const char* value) {
HTTPResponse::setResponseHeader(name, value);
// Set for later.
if (value)
m_headers.insert(make_pair(name,value));
else
m_headers.erase(name);
}
示例13: erase_from_timestamp_map
void erase_from_timestamp_map(pid_t pid, int resource_id) {
for (multimap<long, client_timeout>::iterator i = timestamp_map.begin();
i != timestamp_map.end(); ++i) {
if (i->second.pid == pid && i->second.resource_id == resource_id) {
timestamp_map.erase(i);
break;
}
}
// ewentualnie przestawic alarm
}
示例14: 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;
}
示例15: balance
void balance(int id){
auto count = flat_tree.count(id);;
if (count > max_items_per_quad) {
int target_depth = get_depth(id) + logn(count, 4);
for (auto&a : query_quad(id)) {
//flat_tree.insert({})
insert(id, positions[id], target_depth);
}
flat_tree.erase(id); // erase all by key, can also erase iterator
}
}