is there a performance difference between QList<QList<int> >myList; and int ** myList;?
I would like to know if it is more efficien开发者_运维问答t 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
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.
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 !
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.
精彩评论