Boost logo

Boost :

From: David A. Greene (greened_at_[hidden])
Date: 2002-10-17 14:01:54


Herve Bronnimann wrote:

> I assume that by fixed-size vectors your mean a sequence container where
> all the operations insert/erase have been made inacessible?
> imho you don't need a container adaptor for fixed-size vector. You
> should rewrite your code to use a range [first,last) instead.

I was thinking more of a vector (or deque) where inserting an
element on a full container (however "full" is defined) would
either throw an exception, automatically remove an element from the
container before inserting the new one or take some other
policy-dependent action. Ditto on the removal side.

> Granted you can't pass a range as a single object, but Jeremy Siek has
> written (in the boost-sandbox) a series of container algorithms that
> take a pair<iterator,iterator> (representing a range) and applying
> standard library functions to the pair. It's pretty usable (he uses it
> in the BGL IIRC, but don't take my word for it, go look!)

Unfortunately, a range is (I think) too static for my needs. I
suppose I could write algorithms to simulate item insertion and
removal via copying, but that is expensive. Am I missing
something important? I'd love to learn that something like this
exists already, especially something not in the form I envisioned.

> I'm really unclear as to what a container adaptor library would provide
> (are you thinking of something along the lines of std::stack,
> std::queue, and std::priority_queue?) I'm pretty convinced that
> fixed-size vectors would encourage using the wrong solution style, but
> they are a convenience, and some people can't live without a certain
> level of it. Other adaptors may be more useful, would you have a few
> suggestions?

I had stack, queue, etc. in mind when I wrote the post. I'm curious
why you feel fixed-sized vectors encourage the wrong solution style.
What is the solution style you are worried about?

In case you're interested, I'm planning on using these containers to
model hardware queues, etc. in a simulation environment.

                          -Dave

-- 
"Some little people have music in them, but Fats, he was all music,
  and you know how big he was."  --  James P. Johnson

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