PDA

View Full Version : fastest access Qt array for double?



timmu
2nd October 2012, 19:55
I need to access a 2D array (matrix) a large number of times. What Qt class offers the fastest access 2D array for double? Is QVector a good choice or QLlinkedList? Speedwise, how do they measure up against C's "malloc" in terms of access speed?

I don't know the size of my matrix until the code starts to build it. So, it would be great if it could be built dynamically without predefining its dimensions.

wysota
2nd October 2012, 20:44
QVector is as fast as a plain C array since data is indeed kept as a C array internally. QLinkedList doesn't allow indexed access so it will be a bit slower (if you only need sequential access) or horribly slower (if you need random access). If you're after speed and you know the size of the data upfront (I mean when creating the array, not when running the program), use a plain C array.