[Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO

André Somers andre at familiesomers.nl
Tue Jul 21 12:14:42 CEST 2015


Op 21-7-2015 om 11:55 schreef Bubke Marco:
>
>
> From: development-bounces+marco.bubke=theqtcompany.com at qt-project.org <development-bounces+marco.bubke=theqtcompany.com at qt-project.org> on behalf of Kevin Kofler <kevin.kofler at chello.at>
>> If you have large objects, and insert or remove items within the list,
>> QVector will have to move (or even copy&delete, if they're not movable)
>> large amounts of data. Unless you use a QVector<T*>, but that loses the
>> value semantics in several places. And a QLinkedList is not an option if you
>> also need O(1) (or anything faster than O(n), even) item retrieval. Pointer
>> arrays have their advantages.
> It depends if you care about the order of the container. If you don't and my
> experience you don't care in many cases you can simply use std::remove_if + erase
> and being very efficient.
Well, even if you _do_ care about the order that works. std::remove_if 
is stable after all. An unstable version would probably be faster (you 
could simply swap the item to remove with the last valid item instead of 
shifting the items in between), but that is not in the stl AFAIK.

André




More information about the Development mailing list