Subject: Re: [boost] [GSOC] Regarding the project Boost.DeVector
From: Esben Mose Hansen (boost_at_[hidden])
Date: 2009-03-28 18:17:42
On Friday 27 March 2009 20:02:41 Satyam Shekhar wrote:
> b. Why isn't the reserve function already there in a deque?
> Assuming there is a [use] valid case for this function, adding it shouldn't
> be too difficult. Allocate a block(s) and add the address to the
> top-level array.
I'm pretty sure the assumption "there is a valid [use] case" is false.
reserve() is in vector so that clients can control when a possible complete
realloc+move is going to happen, and possibly even avoid it altogether. This
is important for a lot of reasons, including that all iterators get
invalidated. For deque, new blocks are simply allocated as needed and the
existing blocks are never reallocated. Thus, there would be little point with
preallocating the array.
-- kind regards, Esben
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk