|
Boost Users : |
Subject: Re: [Boost-users] std::list customization
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-01-30 13:10:28
AMDG
Etienne Philip Pretorius wrote:
> I know this is not boost specific, but I would appreciate any comments
> about the following.
>
> I have a specific set of values stored in a std::list<unsigned char>.
> As expected I can delete and add items anywhere, since I am using the
> std::list object rearrange its own contents. But here is the problem -
> when I have already decided that item at position 13 should always
> remain at position 13 if the list has 13 or more objects in it...
>
> If I remove an item from the beginning then the item at position 13
> becomes the item at position 12, while this is undesired - the effect
> of shifting everything else on by one value is desired.
>
> Some examples of what I require:
>
> Fixed position marked with [].
>
> a,b,c,[d],e,f
>
> pop_front() is called
>
> b,c,e,[d],f
>
> This list object should also work when inserting items and keep those
> with fixed positions at their position if the object size allows it.
>
> Any suggestions, Ideas on how to implement this would be greatly
> appreciated.
You could use Boost.Intrusive to superimpose a second list
containing just the fixed position elements. You'll have to
implement wrappers for all the mutating operations that do
appropriate fixing up.
In Christ,
Steven Watanabe
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