Boost logo

Boost :

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2001-12-07 07:37:14


Peter Schmitteckert (boost) wrote:

> Salut,
>
> On Friday 07 December 2001 09:29, Toon Knapen wrote:
>
>>jhrwalter wrote:
>>
>>>Do we really need reserve()? IMO the allocation behaviour of resize()
>>>is a quality of implementation issue, especially since resize() is a
>>>method of the proxy concept. If we intend to make it's behaviour
>>>transparent, we'd have to introduce capacity() first.
>>>
>>I find this really necessary (there's also a good reason why they have
>>capacity and size in std::vector). Everytime you shrink the vector or
>>matrix (i.e. resize(x) with x < size() ), you are going to delete[] the
>>old data and new[] another array. This is very time consuming.
>>I would suggest to allign totally with what std::vector does : you can
>>resize without reallocation (if the capacity is large enough) and you
>>can easily shrink the capacity by copying to a smaller vector.
>>
>
> I agree.
> Allthough a submatrix adapter would be sufficient for me.

Do you mean that you would first create a matrix of sufficient size,
then take a submatrix and resizing the latter does not need reallocation
as long as the size of the submatrix is not bigger as the size of the
original matrix. That would indeed cover the `quest for a minimal number
of reallocations`. But maybe that is what you meant Joerg (and I just
did not get your point).

toon


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk