c++ - Removing element from dynamic list -
i have dynamic list, current spot, a-> prev - previous element, a-> next - next element, need delete 1 element of list (and set previous/next of adjacent elements 1 another)
if(a->va == var && a->pa == pav){ -> prev -> next = -> next; -> next -> prev = -> prev; delete a; }
you have handle edge cases.
if found element first 1 in list, a -> prev
null.
similarly, if it's last, a -> next
null.
Comments
Post a Comment