|
Boost Users : |
Subject: [Boost-users] A need for a complex pool type container
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2009-02-18 17:57:41
My requirements are a bit complex and involved, but I'll try to be as brief
as possible. We have this "scheduler" type system where for each unit of
time (think of 1 unit as 1 ms) there is a "bucket" of events that shall be
processed. This is relative. Suppose the current time is 103. We will have a
record of events to be processed at time 103, 104, 105, ..., 203. When all
of the events in the "bucket" for time stamp 103 are processed, we
"pop_front" to remove the bucket for 103. Everything is essentially shifted
forward. Hopefully this does not require physically shifting everything
forward, and simply is just a matter of using a lesser index to access the
same element later on.
I insert new events into existing buckets anywhere in the container, it does
not necessarily have to be from the back. I always remove items from the
front since they are processed linearly.
One can kind of think of this as a std::deque< std::vector<> >, but the
containing deque would need to be given a fixed size of 100 (as in the
example above). The tricky part is shifting all of the "buckets" (the
buckets in this case would be the inner-vector objects) forward when
something from the front is removed. The key here is that I do not want to
call pop_front() each time a bucket is processed because I want to avoid
constant new/delete operations since insertion and removal will be happening
quite frequently.
I'm not sure what the best approach to solving this problem is. I'm hoping
someone in the community will be able to suggest a way in which boost can
easily solve this problem. Thanks to everyone for taking the time to read
this.
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