|
Boost Users : |
Subject: Re: [Boost-users] [Containers] Marshalling deques
From: Nevin Liber (nevin_at_[hidden])
Date: 2011-08-26 12:35:21
On 26 August 2011 10:33, Michael Goldshteyn <mgoldshteyn_at_[hidden]> wrote:
> Likewise, making the growth multiplier for vector configurable via a
> template argument would be the other boon in such a container library. These
> two features (deque page / block size and vector multiplier config) should
> have been part of the STL to begin with. How many times have library vendors
> tweaked these two items? Why not let the developer choose his constants /
> coefficients at the time of class template instantiation?
1. The problem is that template arguments change the type. Do you really want
vector<int, std::allocator<int>, 2> to be a different type than
vector<int, std::allocator<int>, 3>?
2. You want to be able to pass in floating point numbers to the
multiplier (for instance, multipliers under the golden ratio allow a
vector to reuse the holes it leaves in the heap).
3. In order to guarantee amortized O(1) push_back, you have to
enforce that the multiplier is strictly > 1.
There are, of course, ways to mitigate all of this. But it isn't
clear that the added complexity is worth it.
-- Nevin ":-)" Liber <mailto:nevin_at_[hidden]> (847) 691-1404
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net