I have a linked list like this:
typedef struct _LIST_ELEMENT
{
T* data;
_LIST_ELEMENT* nextItem;
int index;
}LITEM,*P_LITEM,**PP_LITEM;
and four pointers to pointer
PP_LITEM _head;
PP_LITEM _tail;
PP_LITEM _current;
PP_LITEM _previous;
The situation is like this:
I have 4 elements in the list and _head points to the first and _tail to the last, _current and _previous work together as a cursor. After i erase element with index 2, the list contains 3 elements with indexes 0,1 and 3 and all pointers point right. At this point if i do this (to move the cursor to the start):
(*_previous) = (*_tail);
(*_current) = (*_head);
The list is missing element with index 1 but all pointers point correctly. If i do this:
_previous = &(*_tail);
_current = &(*_head);
everything is fine and nothing missing.
If anyone has any idea why is this happening please enlighten me.