chandas
asked on
a question on suitability of stl's map container
Hi guys, I have a simple question on STL's map<> container. My question is, how efficient is it to use the find algorithm with a map when the number of elements is very large? Particularly when the map is unordered? IS the algorithm faster if the map is ordered/sorted first?
Any fact based opinions will be greatly appreciated.
Thanks
Senkwe
Any fact based opinions will be greatly appreciated.
Thanks
Senkwe
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Actually scrap that last comment, I've re-read Jasons post and seen the light via the sentence "By default the sort order is established using operator< on the key"
So going once, going twice for any more light shedding comments...
Regards
Senkwe
Thanks Jason.
So going once, going twice for any more light shedding comments...
Regards
Senkwe
Thanks Jason.
To clarify, yes, objects are added when you insert them into the list.
This insertion is fairly efficient usually (but clearly it typically takes longer than inserting into say, a vector) - as I said it is usually a binary tree - so the insertion time should be related the depth of the tree.
This insertion is fairly efficient usually (but clearly it typically takes longer than inserting into say, a vector) - as I said it is usually a binary tree - so the insertion time should be related the depth of the tree.
ASKER
When are maps ordered? Does this happen implicitly when you call insert? And if so, do you have any idea on how efficient this is? What if what I have to insert is in the middle of some long lap of pairings?
Regards
Senkwe