Re: removing multiple values in a set
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Thu, 10 May 2007 20:45:04 -0400
"kunal s patel" <kunalspatel@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:B13BAAFF-6E24-470B-85B7-AC31283B690B@xxxxxxxxxxxxx
I have a set which contains a bunch of ip address. Now my application
tries to connect to that ip address and if the connection fails then
it removes that ip address from the set("stale ip")......Now how do i
achieve this???
Here is the loop
set<CString>::iterator itr = remotenodeip.begin();
while(itr != remotenodeip.end())
{
CString ip_addr = *itr;
CString result = PeerLookup(ip_addr);
if(result.Compare("Error")==0)
{
//Remove that ip address from the set
}
itr++;
}
if(result.Compare("Error")==0) {
remotenodeip.erase(itr++); // must use post-increment
} else {
++itr; // slightly more efficient to use pre-increment
}
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- Follow-Ups:
- Re: removing multiple values in a set
- From: SvenC
- Re: removing multiple values in a set
- Prev by Date: Re: sorting std::vector<string> ignoring case
- Next by Date: Re: sorting std::vector<string> ignoring case
- Previous by thread: sorting std::vector<string> ignoring case
- Next by thread: Re: removing multiple values in a set
- Index(es):
Relevant Pages
|
Loading