vectors vs. lists

Harri Porten porten at froglogic.com
Thu Feb 19 12:47:25 GMT 2004


On Thu, 19 Feb 2004, David Faure wrote:

> That's exactly what Werner is talking about, QGList::locate().
> Still, as Marc pointed out privately:
> if you implement an algorithm on it using antiparallel iteration with indexing
> instead of iterators (e.g. quicksort), then you get n^2 again.

I'd like to also point out the difference in memory allocation behaviour.
A vector class normally* does a smaller number of allocations and has a
smaller overhead. And unless you do a lot of insertions and removals a
vector might* be the less memory hungry and faster solution.

Harri.

* implementation dependant. always profile as Waldo correctly noted.





More information about the kde-core-devel mailing list