std::list customization
Hello List, 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. Kind Regards, Etienne
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
Steven Watanabe wrote:
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
Thank you, looks exactly what I need. Etienne
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Etienne Philip Pretorius
-
Steven Watanabe