- expansion of a list beyond the currently addressed list size
changes both the allocated size and the addressed list size
- contracting list below the currently addressed list size
changes the addressed list size only.
If someone really wishes to increase the underlying allocated list size
without touching the addressed list size:
prevSize = myList.size();
myList.setSize(largerSize);
myList.setSize(prevSize);
or introduce an equivalent allocSize(const label) method if this is needed
setSize(const label)
- When the new size is smaller than the addressed list size, the addressed
list size is reduced and the allocated size does not change.
- Otherwise the allocated size is adjusted, but the addressed list size
does not change.
setSize(const label, const T&)
- When the new size is larger than the addressed list size, both allocated
and addressed list sizes are adjusted.
NOTE: it might be more consistent to have setSize(label) also adjust the
addressed list size. This also corresponds to what previous releases
did, although I don't know if anyone has relied upon any particular
behaviour
usage of the public 'label& List::size()'.
IMO this method is much too dangerous to leave public - the different
signature is needed to avoid confusing the compiler.
- A simple container for objects of type \<T\> that can be used for
transferring the contents rather than copying them.
- The wrapped object of type \<T\> must implement a transfer() method.