tags:

views:

123

answers:

3

I would like to know if it is more efficient to use a int ** than a QList > or if they are pretty much equal. I have to do alot of calculations so I might want to get to faster one

+4  A: 

The difference in speed depends on the operations you are doing. QList is safer because it automatically allocates and deallocates its storage.

Worry about your program being correct first, then worry about performance, and always profile first before you optimize.

Dietrich Epp
+1  A: 

If I refer to QList documentation:

Internally, QList is represented as an array of pointers to items of type T

Ref: http://qt.nokia.com/doc/4.6/qlist.html#details

So, it seems to be pretty equivalent. If you want to be sure, you can look at the source code or write a benchmark using QTestLib.

esavard
+3  A: 

Hey,

Here is a chart with complexity of Qt containers depending on their use case :

http://qt.nokia.com/doc/4.6/containers.html#algorithmic-complexity

Maybe it will help you !

Andy M