qt-interest@trolltech.com
[Top] [All Lists]

Re: [QT3] QPtrVector or QPtrList

Subject: Re: [QT3] QPtrVector or QPtrList
From: Dave Knopp
Date: Thu, 21 Jul 2005 08:43:34 -0600

Till Oliver Knoll wrote:
> Christopher Thompson schrieb:
>>
>>> My requirements are:
>>> * Allocate only when needed.
>>> * Program doesn't know the amount of records, it could be 4 or 4
>>> million.
>>> * Achieve best possible performance
> 
> Welcome aboard, you've just hit the "Ying and Yang" of computer science
> question, or: "Do we go for speed or do we save resources?" :)
> 
> First thing you need to be aware (regardless of the actual
> implementation, STL or QTL): arrays have usually O(1) element access
> time, whereas lists have O(n) (don't nail me down on these figures, they
> come from my stomach, but basically if you need fast element access, you
> would go for arrays (or "vectors")).

There is some discussion of Algorithmic Complexity specific to Qt
containers in the docs:

http://doc.trolltech.com/4.0/containers.html#algoritmic-complexity

And some Growth strategies are discussed in the following section.

Dave

<Prev in Thread] Current Thread [Next in Thread>