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

STL insert with hint

P: n/a
Is an insert with hint (in say std::set) only beneficial if the
insertion occurs immediately before the pointed to location of the hint?
Suppose the insertion occurs right after the hint location? Or
suppose the insertion is near to the hint location but not adjacent? Is
there a performance penalty for an approximate hint, a partial gain, or
no gain?

Thanks,
Mark
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Mark P wrote:
Is an insert with hint (in say std::set) only beneficial if the
insertion occurs immediately before the pointed to location of the
hint?
No, the hint is most beneficial if the insertion takes place immediately
_after_ the hint.
Suppose the insertion occurs right after the hint location? Or
suppose the insertion is near to the hint location but not adjacent?
Is there a performance penalty for an approximate hint, a partial
gain, or no gain?
It depends on the implementation of std::set<> on your system, but an
insertion with hint should not be less efficient than insertion without
a hint.
Depending on the implementation and how close the hint is to the actual
insertion point, insertion with a hint may or may not be noticeably
more efficient.

Thanks,
Mark


Bart v Ingen Schenau
--
a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
c.l.c FAQ: http://www.eskimo.com/~scs/C-faq/top.html
c.l.c++ FAQ: http://www.parashift.com/c++-faq-lite/
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.