Dave's Brain

Browse - programming tips - stl list faster

Date: 2008oct1
Language: C/C++
Keywords: Standard Template Library, optimize

Q.  How can I make my STL <list> faster?

A.  <list> is doubly-link which isn't needed in many applications.
Consider using <slist> which is singly-linked.  Takes less time linking
and it also uses less space.

Try using a <vector> instead.  You might be surprised.  Its sometimes
faster since it doesn't have do a malloc() for each element.

Can you reserve() some space?  This often helps.
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: