erase a "pair" element in set

N

newbie

say I have a set containing pairs.


set< pair<AbstractClass*, double> > container;
container.insert(pair <objectPtrA, 0.0> );
....
....
at here, I don't know what is the value in that pair, but I do want to
erase that pair, may I do that?
 
B

BobR

newbie said:
say I have a set containing pairs.

set< pair<AbstractClass*, double> > container;
container.insert(pair <objectPtrA, 0.0> );
...
at here, I don't know what is the value in that pair, but I do want to
erase that pair, may I do that?

For std::set:
void erase(iterator pos) Erases the element pointed to by pos.
size_type erase(const key_type& k) Erases the element whose key is k.
void erase(iterator first, iterator last) Erases all elements in a range.

Try (untested):
std::set<pair<AbstractClass*, double> >::irerator it( container.begin()
+3 );
container.erase( it );
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top