472,139 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,139 software developers and data experts.

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 2280
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.