N
Niklas Norrthon
Axter said:Should not be a factor in considering using std::list instead of
std::vector
Except that once vector has reserved some memory it's not returned
to the memory manager until the entire vector is destroyed, while
memory used by a list node is returned as soon as that node is
erased.
If data needs to be frequently sorted, then consider using std::set or
std::map instead.
Except when data needs to be sorted in different ways each time.
Most experts, (like Herb Sutters and Scott Meyers) recommend using
std::vector as the default container.
The Official C++ standard also recommends using std::vector as the
default container.
In most container requirements, std::vector will out perform std::list.
I agree, use vector as the default container, but don't forget about
the alternatives, and their usage.
/Niklas Norrthon