Move list element to the end in STL

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)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)