mirror of https://github.com/lianthony/NT4.0
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.3 KiB
58 lines
1.3 KiB
//
|
|
// Copyright (c) 1996 Microsoft Corporation
|
|
//
|
|
//
|
|
// ILIST.CPP -- Implementation for Classes:
|
|
// CInfList
|
|
//
|
|
//
|
|
// History:
|
|
// 05/27/96 JosephJ Created
|
|
//
|
|
//
|
|
#include "common.h"
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
// CLASS CInfList
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// Simple singly-linked list which can not be modified once it's been
|
|
// created. Assumes creation and eventual deletion are protected by some
|
|
// external critical section.
|
|
//
|
|
// Sample:
|
|
// for (; pList; pList = pList->Next())
|
|
// {
|
|
// const CInfAddregSection *pAS = (CInfAddregSection *) pList->GetData();
|
|
// }
|
|
|
|
//-------------- FreeList ------------------
|
|
// Distroys the list.
|
|
void
|
|
CInfList::FreeList (CInfList *pList)
|
|
{
|
|
while(pList)
|
|
{
|
|
// Cast to get rid of the const declaration of pList->Next().
|
|
CInfList *pNext = (CInfList *) pList->Next();
|
|
delete pList;
|
|
pList = pNext;
|
|
}
|
|
}
|
|
|
|
//-------------- ReverseList ------------------
|
|
// Reverses the specified list.
|
|
void
|
|
CInfList::ReverseList (const CInfList **ppList)
|
|
{
|
|
CInfList *pList = (CInfList *) *ppList; // override const
|
|
const CInfList *pPrev = NULL;
|
|
while(pList)
|
|
{
|
|
const CInfList *pTmp = pList->Next();
|
|
pList->mfn_SetNext(pPrev);
|
|
pPrev = pList;
|
|
pList = (CInfList *) pTmp; // override const
|
|
}
|
|
*ppList = pPrev;
|
|
}
|