469,578 Members | 1,914 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

STL insert with hint

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
1 2013
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.

Similar topics

18 posts views Thread by deancoo | last post: by
3 posts views Thread by rudymoore | last post: by
3 posts views Thread by Howard Hinnant | last post: by
6 posts views Thread by Mark P | last post: by
16 posts views Thread by robert | last post: by
5 posts views Thread by asdf | last post: by
reply views Thread by subramanian100in | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.