Dave's Brain

Browse - programming tips - stl sorted vector

Date: 2007dec10
Language: C++

Q.  How do I keep the elements of an STL vector always in order?

A.  I have had good success with Martin Holzherr's sorted_vector
template:

	http://www.codeproject.com/KB/stl/sorted_vector.aspx

It's far faster than doing std::sort() after each push_back().

Add a comment

Sign in to add a comment
Copyright © 2008, dave - Code on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License.