From d75bb35c59db929f3ce9bae9e2a8df83af411a0c Mon Sep 17 00:00:00 2001 From: Vitaly Orekhov Date: Fri, 27 Sep 2024 23:09:30 +0300 Subject: [PATCH] [ATL] Implement CAtlList::AddHeadList and CAtlList::AddTailList What about a convenient way to append CAtlList to each other? --- sdk/lib/atl/atlcoll.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/sdk/lib/atl/atlcoll.h b/sdk/lib/atl/atlcoll.h index 1068deeacc588..1220326f8375e 100644 --- a/sdk/lib/atl/atlcoll.h +++ b/sdk/lib/atl/atlcoll.h @@ -483,6 +483,9 @@ class CAtlList E RemoveHead(); E RemoveTail(); + void AddHeadList(_In_ const CAtlList* plNew); + void AddTailList(_In_ const CAtlList* plNew); + POSITION InsertBefore(_In_ POSITION pos, INARGTYPE element); POSITION InsertAfter(_In_ POSITION pos, INARGTYPE element); @@ -639,6 +642,34 @@ POSITION CAtlList::AddTail(INARGTYPE element) return (POSITION)Node; } +template +void CAtlList::AddHeadList(_In_ const CAtlList* plNew) +{ + ATLASSERT(plNew == NULL); + + POSITION pos = plNew->GetTailPosition(); + + while (pos) + { + INARGTYPE element = plNew->GetPrev(pos); + AddHead(element); + } +} + +template +void CAtlList::AddTailList(_In_ const CAtlList* plNew) +{ + ATLASSERT(plNew == NULL); + + POSITION pos = plNew->GetHeadPosition(); + + while (pos) + { + INARGTYPE element = plNew->GetNext(pos); + AddTail(element); + } +} + template E CAtlList::RemoveHead() {