[ATL] Implement CAtlList::AddHeadList and CAtlList::AddTailList

What about a convenient way to append CAtlList to each other?
This commit is contained in:
Vitaly Orekhov 2024-09-27 23:09:30 +03:00 committed by Hermès BÉLUSCA - MAÏTO
parent d3ec7cdd48
commit 103d84448f

View file

@ -480,6 +480,9 @@ public:
POSITION AddHead(INARGTYPE element);
POSITION AddTail(INARGTYPE element);
void AddHeadList(_In_ const CAtlList<E, ETraits>* plNew);
void AddTailList(_In_ const CAtlList<E, ETraits>* plNew);
E RemoveHead();
E RemoveTail();
@ -639,6 +642,24 @@ POSITION CAtlList<E, ETraits>::AddTail(INARGTYPE element)
return (POSITION)Node;
}
template <typename E, class ETraits>
void CAtlList<E, ETraits>::AddHeadList(_In_ const CAtlList<E, ETraits>* plNew)
{
ATLASSERT(plNew != NULL && plNew != this);
POSITION pos = plNew->GetTailPosition();
while (pos)
AddHead(plNew->GetPrev(pos));
}
template <typename E, class ETraits>
void CAtlList<E, ETraits>::AddTailList(_In_ const CAtlList<E, ETraits>* plNew)
{
ATLASSERT(plNew != NULL && plNew != this);
POSITION pos = plNew->GetHeadPosition();
while (pos)
AddTail(plNew->GetNext(pos));
}
template<typename E, class ETraits>
E CAtlList<E, ETraits>::RemoveHead()
{