Skip to content

Commit

Permalink
[ATL] Implement CAtlList::AddHeadList and CAtlList::AddTailList
Browse files Browse the repository at this point in the history
What about a convenient way to append CAtlList to each other?
  • Loading branch information
SigmaTel71 committed Sep 27, 2024
1 parent 053939e commit d75bb35
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions sdk/lib/atl/atlcoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,9 @@ class CAtlList
E RemoveHead();
E RemoveTail();

void AddHeadList(_In_ const CAtlList<E, ETraits>* plNew);
void AddTailList(_In_ const CAtlList<E, ETraits>* plNew);

POSITION InsertBefore(_In_ POSITION pos, INARGTYPE element);
POSITION InsertAfter(_In_ POSITION pos, INARGTYPE element);

Expand Down Expand Up @@ -639,6 +642,34 @@ 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);

POSITION pos = plNew->GetTailPosition();

while (pos)
{
INARGTYPE element = plNew->GetPrev(pos);
AddHead(element);
}
}

template<typename E, class ETraits>
void CAtlList<E, ETraits>::AddTailList(_In_ const CAtlList<E, ETraits>* plNew)
{
ATLASSERT(plNew == NULL);

POSITION pos = plNew->GetHeadPosition();

while (pos)
{
INARGTYPE element = plNew->GetNext(pos);
AddTail(element);
}
}

template<typename E, class ETraits>
E CAtlList<E, ETraits>::RemoveHead()
{
Expand Down

0 comments on commit d75bb35

Please sign in to comment.