/* * Move all elements of another list into this one. */ void CListHead::MoveList(CListHead &lhOther) { ASSERT(IsValid() && lhOther.IsValid()); // if the second list is empty if (lhOther.IsEmpty()) { // no moving return; } // get first element in other list CListNode &lnOtherFirst = *lhOther.lh_Head; // get last element in other list CListNode &lnOtherLast = *lhOther.lh_Tail; // get last element in this list CListNode &lnThisLast = *lh_Tail; // relink elements lnOtherLast.ln_Succ = lnThisLast.ln_Succ; lnThisLast.ln_Succ = &lnOtherFirst; lnOtherFirst.ln_Pred = &lnThisLast; lh_Tail = &lnOtherLast; // clear the other list lhOther.Clear(); }