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.

91 lines
1.3 KiB

  1. //*************************************************************
  2. //
  3. // Copyright (c) Microsoft Corporation 1998
  4. // All rights reserved
  5. //
  6. // list.hxx
  7. //
  8. //*************************************************************
  9. #if !defined(__LIST_HXX__)
  10. #define __LIST_HXX__
  11. class CListItem
  12. {
  13. friend class CList;
  14. public:
  15. CListItem() : _pPrev(0), _pNext(0) {}
  16. void
  17. Remove();
  18. void
  19. InsertBefore(
  20. IN CListItem * pItem
  21. );
  22. private:
  23. CListItem * _pPrev;
  24. CListItem * _pNext;
  25. };
  26. class CList
  27. {
  28. public:
  29. CList();
  30. void
  31. InsertLIFO(
  32. IN CListItem * pItem
  33. );
  34. void
  35. InsertFIFO(
  36. IN CListItem * pItem
  37. );
  38. //
  39. // Interation methods.
  40. //
  41. inline void
  42. Reset()
  43. {
  44. _pCurrentSave = _pCurrent;
  45. _pCurrent = _Head._pNext;
  46. }
  47. inline BOOL
  48. MoveNext()
  49. {
  50. _pCurrent = _pCurrent->_pNext;
  51. return (_pCurrent != &_Head);
  52. }
  53. inline CListItem *
  54. GetCurrentItem()
  55. {
  56. return (_pCurrent != &_Head) ? _pCurrent : NULL;
  57. }
  58. inline void
  59. ResetEnd()
  60. {
  61. _pCurrent = _pCurrentSave;
  62. }
  63. private:
  64. CListItem _Head;
  65. CListItem * _pCurrent;
  66. CListItem * _pCurrentSave;
  67. };
  68. #endif // __LIST_HXX__