By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,264 Members | 1,767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,264 IT Pros & Developers. It's quick & easy.

erase a "pair" element in set

P: n/a
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?

Jul 18 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a

newbie <mi******@yahoo.comwrote in message...
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 );

--
Bob R
POVrookie
Jul 19 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.