Boost logo

Boost Users :

Subject: Re: [Boost-users] A need for a complex pool type container
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2009-02-18 21:54:33


On Wed, Feb 18, 2009 at 21:44, Robert Dailey <rcdailey_at_[hidden]> wrote:
>
> Wow, this is actually perfect. So before I do a rotate(), I need to do:
> schedule[0].clear() right? When I do future push_back operations on
> schedule[99], I want it to be adding to an empty vector and not adding to
> the old contents of it.
>

Yes, you will. (I had thought you were popping tasks off the vectors
to run them.) And be sure to keep the capacity and size of the
circular_buffer the same, or else the rotate will start copying and
destructing vectors.

Of course, even on other containers you always have the option of

    c.push_back(vector<T>());
    swap(c.front(), c.back());
    c.pop_front();

which should also avoid any allocing or freeing by the vectors.


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