c++ - How to move elements in doubly linked list? -
i have custom list (doubly linked list , not std::list) implemented in code. requirement move element 1 left or right updating references. possible? class elem { elem *next; elem *prev; } ....... void move_element_left(elem *e) { if(e->prev()==null) return; //left ... return elem *left = e->prev(); left->next() = e->next(); e->prev() = left->prev(); if (left->next()) left->next()->prev() = left; if (e->prev()) e->prev()->next() = e; e->next() = left; left->prev() = e; } ....... int main() { elemlist ls; ... ... move_element_left(e); //e of type elem * ... } above code works except 2nd object in list want move left (or top most). (i.e. if list(obj5, obj9, obj11, obj12,..), moving obj9 first in list gives error) works designed ? following code in schema, shows works designed: void move_element_left(elem *e) { if(e-...