I have already the list pointer of CDrawObject*
std::list<CDrawObject*> elements; How I can move some element to the end of list. I see STL Algorithms Reference but i don't find this operations. How i can do it?
I have already the list pointer of CDrawObject*
std::list<CDrawObject*> elements; How I can move some element to the end of list. I see STL Algorithms Reference but i don't find this operations. How i can do it?
Use the list method splice()
void list::splice ( iterator position, list<T,Allocator>& x, iterator i );
Move iterator i from list x into current list at position "position"
Thus to move it to the end put
x.splice( x.end(), x, iter ); (they can both be the same list or different lists as long as the list from which the item is moved has the same type, both T and Allocator)
iter is already pointing to the last element—is it necessary to special-case that?A std::list is a doubly-linked list, which means you do not have random access to element n. You have to can remove the element, and then use push_back.
remove destructs the object, and it could be non-trivial to re-construct a new one.Remove it then append it to your list.
std::memmove()the content of astd::vectorof containers, especially when aspects like locality of data (CPU cache) is taken into account.