[Qt-interest] Qt Containers (or: why I must use STL)
Thiago Macieira
thiago at kde.org
Tue Oct 13 10:07:44 CEST 2009
Em Terça-feira 13. Outubro 2009, às 09.03.35, Yves Bailly escreveu:
> David Forstenlechner a écrit :
> > Honestly,
> > I would not even think about using the Qt containers unless I must.
> >
> > Every C++ programmer should be familiar with STL containers,
> > there are lots of great books and documentation on how to use them,
> > and the STL implementations are reasonably stable at this point.
> >
> > When you got special needs you may have to write your own data
> > structures anyways,
> > I see the Qt data structures mainly as a support for the Qt GUI
> > framework, not as general purpose replacements for STL/boost or custom
> > written special-purpose ones.
>
> I totally agree. Besides I used STL containers most of the time.
>
> My point was nothing more than saying that the answer given by Thiago,
> which was more or less "2 billion elements means 16GB in QList" and
> suggesting such needs of memory would never happen, was not a good answer.
> Because *yes*, such needs of memory can happen, and at least in my field,
> they will happen more and more often.
With that, I wanted to convey two things:
1) use of "int" doesn't mean limitation to 2 GB. It limits to 2 billion
elements, which on a QList of small, movable items means 16 GB. If you have
anything non-movable (non-memcpyable), it means more. On a QVector, it's
simply sizeof(T)*2 billion.
2) If you *do* need that many elements, I'm guessing you need a specialised
container. Both QList and QVector require a continuous memory block. Maybe you
have a better structure... (and I actually hope you do)
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
Qt Developer Days 2009 | Registration Now Open!
Munich, Germany: Oct 12 - 14 San Francisco, California: Nov 2 - 4
http://qt.nokia.com/qtdevdays2009
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091013/21c2ae1f/attachment.bin
More information about the Qt-interest-old
mailing list