Il 27/01/2015 09:41, Mark Gaiser ha scritto:
As far as i know this is for historic reasons. QList used to be faster then QVector (someone, please correct me if i'm wrong) in the old days, but nowadays (Qt5 era) they prefer QVector over QList. It is as fast or faster then QList in nearly every situation. I vaguely remember there being one exception where QList was faster, but i don't know the exception anymore.
I don't think it has ever been faster. The main reason behind QList is to generate less code: all the handling of the backing array is shared amongst the specializations. But please refer to Marc Mutz's awesome blog posts for more info:
https://marcmutz.wordpress.com/effective-qt/containers/ The other difference with QVector is that QList has a prepend optimization.
A somewhat related question, why is there no QList::reserve()?
There is, what's missing is resize(). (Fundamentally that "shared part" behind QList has no code dealing with shrinking.) I've got a WIP on gerrit, if only I get the time to work on it again...
Cheers, -- Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Software Engineer KDAB (UK) Ltd., a KDAB Group company Tel. UK +44-1738-450410, Sweden (HQ) +46-563-540090 KDAB - Qt Experts - Platform-independent software solutions
smime.p7s
Description: Firma crittografica S/MIME
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest