Hi,

On 03/05/2017 17:57, Jason H wrote:
I have a app that does a lot of numeric processing,using quint32, qreal mostly 
(and occasional QVector3D). 10k-1M items in the data set. I generally do know 
the size of the dataset before I start adding to it, so I call reserve() on it. 
Given that, and that I've been using QMap and QVector, when I use QMap and want 
the keys() it gives me a QList, which I then have to call toVector() on.

So this leads me to ask if I should be using QList all this time? I had thought 
that QList was considered harmful. [1][2][3]
But "everything" seems to return to me a QList, rather than a QVector.

What should I be using? (I'm Targeting 5.8 and later.)

Depends upon your usage patterns. Do you do a lot of map operations over the vectors/maps? If so cache coherency may well be the biggest factor, in which case QVector or even std::vector may give you better performance than QMap. Given the current discrepancy between CPU speeds and memory access latencies it's hard to do better than a vector for pure performance as the contiguous memory layout makes better use of the L2 cache.

If ease of API use is your main concern then QMap may be a better fit. It all depends what you are using this data for.

Cheers,

Sean

--
Dr Sean Harmer | sean.har...@kdab.com | Managing Director UK
KDAB (UK) Ltd, a KDAB Group company
Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090
Mobile: +44 (0)7545 140604
KDAB - Qt Experts
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to