Leaked source code of windows server 2003
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.

80 lines
2.2 KiB

  1. // Copyright (c) 1996-1999 Microsoft Corporation
  2. //
  3. // clist.h
  4. //
  5. #ifndef __CLIST_H__
  6. #define __CLIST_H__
  7. class CListItem
  8. {
  9. public:
  10. CListItem() { m_pNext=NULL; };
  11. CListItem *GetNext() const {return m_pNext;};
  12. void SetNext(CListItem *pNext) {m_pNext=pNext;};
  13. LONG GetCount() const;
  14. BOOL IsMember(CListItem *pItem);
  15. CListItem* Cat(CListItem* pItem);
  16. CListItem* AddTail(CListItem* pItem) {pItem->SetNext(NULL); return Cat(pItem);};
  17. CListItem* Remove(CListItem* pItem);
  18. CListItem* GetPrev(CListItem *pItem) const;
  19. CListItem* GetItem(LONG index);
  20. private:
  21. CListItem *m_pNext;
  22. };
  23. class CList
  24. {
  25. public:
  26. CList() {m_pHead=NULL;};
  27. CListItem *GetHead() const { return m_pHead;};
  28. void RemoveAll() { m_pHead=NULL;};
  29. LONG GetCount() const {return m_pHead->GetCount();};
  30. CListItem *GetItem(LONG index) { return m_pHead->GetItem(index);};
  31. void InsertBefore(CListItem *pItem,CListItem *pInsert);
  32. void Cat(CListItem *pItem) {m_pHead=m_pHead->Cat(pItem);};
  33. void Cat(CList *pList)
  34. {
  35. // assert(pList!=NULL);
  36. m_pHead=m_pHead->Cat(pList->GetHead());
  37. };
  38. void AddHead(CListItem *pItem)
  39. {
  40. // assert(pItem!=NULL);
  41. pItem->SetNext(m_pHead);
  42. m_pHead=pItem;
  43. }
  44. void AddTail(CListItem *pItem)
  45. {
  46. if (m_pHead == NULL)
  47. {
  48. AddHead(pItem);
  49. }
  50. else
  51. {
  52. m_pHead=m_pHead->AddTail(pItem);
  53. }
  54. };
  55. void Remove(CListItem *pItem) {m_pHead=m_pHead->Remove(pItem);};
  56. CListItem *GetPrev(CListItem *pItem) const {return m_pHead->GetPrev(pItem);};
  57. CListItem *GetTail() const {return GetPrev(NULL);};
  58. BOOL IsEmpty(void) const {return (m_pHead==NULL);};
  59. BOOL IsMember(CListItem *pItem) {return (m_pHead->IsMember(pItem));};
  60. CListItem *RemoveHead(void)
  61. {
  62. CListItem *li;
  63. li=m_pHead;
  64. if(m_pHead)
  65. m_pHead=m_pHead->GetNext();
  66. if (li)
  67. li->SetNext(NULL);
  68. return li;
  69. }
  70. protected:
  71. CListItem *m_pHead;
  72. };
  73. #endif // __CLIST_H__