Boost logo

Boost :

From: jhrwalter (walter_at_[hidden])
Date: 2001-12-08 07:20:29


--- In boost_at_y..., Peter Schmitteckert (boost) <boost_at_s...> 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.

This is indeed an alternative. matrix_range should be an suited
submatrix adaptor (with a poor name?).
 
> > > BTW, do we need to consider std::allocator?
> >
> > In the long term : yes. But no allocater can be as smart as what
you
> >
> > can do with capacity() and resize(). So the allocator is not a
solution
> >
> > to the above problem.
> > An allocator would be nice e.g. to optimise allocation of many
small
> > matrices.
> I agree.
>
> Peter
 
Regards
 
Joerg
 


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