[Qt-interest] How to clear QVector without releasing memory?
Thiago Macieira
thiago at kde.org
Tue Jun 21 05:09:21 CEST 2011
Em Tuesday, 21 de June de 2011, às 04:44:46, Nikos Chantziaras escreveu:
> What do you mean with "clears existing elements". How can you "clear" an
element? This is not an operation I'm familiar with.
Destroy them. If the element is a non-POD, then QVector will call its
destructors.
QVector::resize calls QVector::realloc(0, d->alloc) which means it will not
release memory, but it will run this loop:
while (asize < d->size) {
(--pOld)->~T();
d->size--;
}
That is the "clear existing elements".
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- 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/20110621/44a0f5ae/attachment.bin
More information about the Qt-interest-old
mailing list