Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • I recommend that you pick up an introductory computer science book to learn stuff things like Big O notation and basic data structures and algorithms. The biggest performance benefits comes from choosing the right algorithm and data structures; you're doomed to write suboptimal code if you don't have a good grasp of the basics in computer science. Commented Jul 7, 2010 at 23:19
  • Lookup on a sorted list is O(lg N). Lookup on a map is supposed to be O(1), not O(lg N), though it degrades if your hash function causes collisions. Commented Jul 7, 2010 at 23:38
  • For a hash map look-up time is amortized O(1), yes. For a std::map it's O(log n). See e.g. this sgi.com/tech/stl/SortedAssociativeContainer.html Commented Jul 7, 2010 at 23:51
  • I know about the different lookup speeds maps and vectos are suposed to have. They are the reason why i asked my question in the first place, since i didn't understand why the map lookup seemed to perform worse. Commented Jul 8, 2010 at 5:37