DoublyLinkedQueue: Rework Remove() function.
Equivalent to the changes done to DoublyLinkedList (in 904e9f5512305dbc0eed9146e8a0b2d597269b71.)
This commit is contained in:
parent
74662b662d
commit
9b28ebf997
@ -226,18 +226,24 @@ DOUBLY_LINKED_LIST_TEMPLATE_LIST
|
||||
void
|
||||
DOUBLY_LINKED_QUEUE_CLASS_NAME::Remove(Element *element)
|
||||
{
|
||||
if (element) {
|
||||
Link *elLink = sGetLink(element);
|
||||
if (elLink->previous)
|
||||
sGetLink(elLink->previous)->next = elLink->next;
|
||||
else
|
||||
fFirst = elLink->next;
|
||||
if (elLink->next)
|
||||
sGetLink(elLink->next)->previous = elLink->previous;
|
||||
if (element == NULL)
|
||||
return;
|
||||
|
||||
elLink->previous = NULL;
|
||||
elLink->next = NULL;
|
||||
}
|
||||
#if DEBUG_DOUBLY_LINKED_LIST
|
||||
ASSERT_PRINT(fFirst != NULL,
|
||||
"queue: %p, element: %p\n", this, element);
|
||||
#endif
|
||||
|
||||
Link *elLink = sGetLink(element);
|
||||
if (element == fFirst)
|
||||
fFirst = elLink->next;
|
||||
else
|
||||
sGetLink(elLink->previous)->next = elLink->next;
|
||||
|
||||
if (elLink->next)
|
||||
sGetLink(elLink->next)->previous = elLink->previous;
|
||||
|
||||
elLink->next = elLink->previous = NULL;
|
||||
}
|
||||
|
||||
// Swap
|
||||
|
Loading…
Reference in New Issue
Block a user