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.

67 lines
1.9 KiB

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