jpalecek@web.de wrote:
Hello,
I know there is a method "insert with hint" int std::set. But there
isn't anything similar for find and erase.
Does somebody know why?
Regards
Jiri Palecek
Hello Jiri,
You can use the std:: find algorithm. But I can't say if this is the
best and/or fastest way. The example below won't compile because
SomeObject has some methods missing. It's only meant as a hint.
#include <set>
#include <algorithm>
class SomeObject {
};
void func()
{
std::set<SomeObject> myset;
myset.insert(SomeObject("first"));
myset.insert(SomeObject("second"));
myset.insert(SomeObject("third"));
std::set<SomeObject>::const_iterator iter;
iter = std::find(myset.begin(), myset.end(), SomeObject("second));
if (iter != myset.end()) {
iter->doSomething();
}
}
--
Regards
Daniel Kay
Sorry, that I wasn't answering your question. I didn't read your post
correctly. I think it's time to go to bed... ;-)