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.

75 lines
1.6 KiB

  1. /*===================================================================
  2. Microsoft Denali
  3. Microsoft Confidential.
  4. Copyright 1996 Microsoft Corporation. All Rights Reserved.
  5. Component: Hash table for Script Manager
  6. File: DblList.h
  7. Owner: DGottner
  8. extremly simple, yet very flexible, linked list manager
  9. ===================================================================*/
  10. #ifndef DBLLINK_H
  11. #define DBLLINK_H
  12. #ifdef LINKTEST
  13. #define _DEBUG
  14. #include <assert.h>
  15. #define Assert assert
  16. #else
  17. #include "debug.h"
  18. #endif
  19. /* C D b l L i n k
  20. *
  21. * This structure contains a set of links suitable for a doubly linked list
  22. * implementation. Here we actually use it as a circularly linked list -
  23. * the links are extracted into this file because the list headers are also
  24. * of this type.
  25. */
  26. class CDblLink
  27. {
  28. public:
  29. CDblLink();
  30. virtual ~CDblLink();
  31. // manipulators
  32. /////
  33. void UnLink();
  34. void AppendTo(CDblLink &);
  35. void PrependTo(CDblLink &);
  36. // accessors
  37. /////
  38. CDblLink *PNext() const;
  39. CDblLink *PPrev() const;
  40. // testers
  41. /////
  42. bool FIsEmpty() const;
  43. void AssertValid() const
  44. {
  45. #ifdef _DEBUG
  46. Assert (this == m_pLinkPrev->m_pLinkNext && this == m_pLinkNext->m_pLinkPrev);
  47. #endif
  48. }
  49. private:
  50. CDblLink *m_pLinkNext, *m_pLinkPrev;
  51. };
  52. inline CDblLink::CDblLink() { m_pLinkNext = m_pLinkPrev = this; }
  53. inline CDblLink::~CDblLink() { UnLink(); }
  54. inline bool CDblLink::FIsEmpty() const { return this == m_pLinkNext; }
  55. inline CDblLink *CDblLink::PNext() const { return m_pLinkNext; }
  56. inline CDblLink *CDblLink::PPrev() const { return m_pLinkPrev; }
  57. #endif // DBLLINK_H