DoublyLinkedList: Add a RemoveAllBefore convenience function.

Extracted from hamishm's event queue patches.
This commit is contained in:
Augustin Cavalier
2023-07-24 16:09:42 -04:00
parent a2efc7ec03
commit c6cd9b51a2
@@ -338,6 +338,8 @@ public:
inline void Add(Element* element, bool back = true);
inline void Remove(Element* element);
inline void RemoveAllBefore(Element* element);
inline void Swap(Element* a, Element* b);
inline void MoveFrom(DOUBLY_LINKED_LIST_CLASS_NAME* fromList);
@@ -500,6 +502,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Add(Element* element, bool back)
Insert(element, back);
}
// Remove
DOUBLY_LINKED_LIST_TEMPLATE_LIST
void
@@ -528,6 +531,19 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Remove(Element* element)
}
}
// RemoveAllBefore
DOUBLY_LINKED_LIST_TEMPLATE_LIST
void
DOUBLY_LINKED_LIST_CLASS_NAME::RemoveAllBefore(Element* element)
{
if (element != NULL) {
fFirst = element;
sGetLink(element)->previous = NULL;
}
}
// Swap
DOUBLY_LINKED_LIST_TEMPLATE_LIST
void
@@ -551,6 +567,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Swap(Element* a, Element* b)
}
}
// MoveFrom
DOUBLY_LINKED_LIST_TEMPLATE_LIST
void
@@ -570,6 +587,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::MoveFrom(DOUBLY_LINKED_LIST_CLASS_NAME* fromList)
}
}
// RemoveAll
DOUBLY_LINKED_LIST_TEMPLATE_LIST
void
@@ -579,6 +597,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::RemoveAll()
fLast = NULL;
}
// RemoveHead
DOUBLY_LINKED_LIST_TEMPLATE_LIST
Element*