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.

83 lines
2.2 KiB

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