#ifndef __CIRCULARLISTINT_H__ #define __CIRCULARLISTINT_H__ #include "datalibx.h" ////////////////////////////////////////////////////////////////////////////// // CCircularListInt Class // // This class does not take responsibility for deleting the data indexed by it // Nor does its destructor delete its links, since sometimes they'll be // incorporated into another list. class CCircularListIterInt; class CCircularListInt { public: friend class CCircularListIterInt; public: CCircularListInt(); ~CCircularListInt(); BOOL Init(); protected: VOID Uninit(); public: // Insertion Functions inline VOID *Insert(VOID *pData, INT_32 iKey); VOID *InsertForward(VOID *pData, INT_32 iKey); VOID *InsertBackward(VOID *pData, INT_32 iKey); VOID *InsertFirst(VOID *pData, INT_32 iKey); VOID *InsertLast(VOID *pData, INT_32 iKey); // Deletion Functions inline VOID *Remove(INT_32 iKey); VOID *RemoveForward(INT_32 iKey); VOID *RemoveBackward(INT_32 iKey); VOID *RemoveFirst(INT_32 *piKey = NULL); VOID *RemoveLast(INT_32 *piKey = NULL); VOID RemoveAll(); // Look up Functions inline VOID *Peek(INT_32 iKey) const; VOID *PeekForward(INT_32 iKey) const; VOID *PeekBackward(INT_32 iKey) const; VOID *PeekFirst(INT_32 *piKey = NULL) const; VOID *PeekLast(INT_32 *piKey = NULL) const; VOID *PeekFirstLink(INT_32 *piKey = NULL) const; VOID *PeekLastLink(INT_32 *piKey = NULL) const; // Functions for really getting down and dirty with the list VOID *GetHead(); VOID *GetTail(); VOID SetHead(VOID *pHead); VOID SetTail(VOID *pTail); VOID SetHeadPrev(VOID *pPrev); VOID SetHeadNext(VOID *pNext); #define SORT_ENABLED #ifdef SORT_ENABLED // Sorting Functions BOOL Sort(); // This preforms a Merge Sort #endif // SORT_ENABLED // Display Functions VOID Display(); //Inlined Functions public: // UINT_32 GetLength(); protected: VOID *m_pCCircularList; }; ////////////////////////////////////////////////// // Inlined Functions // inline VOID *CCircularListInt::Insert(VOID *pvData, INT_32 iKey) { return InsertForward(pvData, iKey); } inline VOID *CCircularListInt::Remove(INT_32 iKey) { return RemoveForward(iKey); } inline VOID *CCircularListInt::Peek(INT_32 iKey) const { return PeekForward(iKey); } ////////////////////////////////////////////////////////////////////////////// // CCircularListIterInt Class // class CCircularListIterInt { public: CCircularListIterInt(); ~CCircularListIterInt(); BOOL Init(CCircularListInt *pCCircularListInt); protected: VOID Uninit(); public: VOID SetCurr(VOID *pCurr); // Iteration Functions VOID *Peek(INT_32 iKey); VOID *PeekForward(INT_32 iKey); VOID *PeekBackward(INT_32 iKey); VOID *PeekFirst(INT_32 *piKey = NULL); VOID *PeekNext(INT_32 *piKey = NULL); VOID *PeekLast(INT_32 *piKey = NULL); VOID *PeekPrev(INT_32 *piKey = NULL); VOID *PeekFirstLink(INT_32 *piKey = NULL); VOID *PeekNextLink(INT_32 *piKey = NULL); VOID *PeekLastLink(INT_32 *piKey = NULL); VOID *PeekPrevLink(INT_32 *piKey = NULL); protected: VOID *m_pCCircularListIter; }; ////////////////////////////////////////////////// // Inlined Functions // inline VOID *CCircularListIterInt::Peek(INT_32 iKey) { return PeekForward(iKey); } #endif // __LISTINT_H__