How to maintain 2 lists of object
- by michael
Hi,
My c++ program needs to maintain 2 list of objects.
list inuse;
list free;
So objects A can even in 'inuse' list or in 'free' list, but not both.
http://www.cplusplus.com/reference/stl/list/
I am think of using 'list' as the data structure for my lists.
My questions are
1. why i can't randomly access an elmenet in the list, I look at the above api, I don't see a way to get inuse[2];
2. How can I remove an element in the list? There is an erase(), but how can I use it to remove element #2? And after I remove element 2? will STL list fill the erased spot automatically? e.g. #3 will become #2, #4 will become #3 and so on?
Thank you.