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.

71 lines
1.7 KiB

  1. #if !defined __DLINK_HXX__
  2. #define __DLINK_HXX__
  3. //+---------------------------------------------------------------------------
  4. //
  5. // File: DLINK.HXX
  6. //
  7. // Contents: Parametrized doubly linked list and iterators
  8. //
  9. // History: 15-Jun-92 BartoszM Created.
  10. //
  11. //----------------------------------------------------------------------------
  12. //+---------------------------------------------------------------------------
  13. //
  14. // Class: CDoubleLink
  15. //
  16. // Purpose: Linked element
  17. //
  18. // History: 15-Jun-92 BartoszM Created.
  19. //
  20. // Notes: Use as base for your class. No need to override anything.
  21. //
  22. // class CFoo: public CDoubleLink
  23. // {
  24. // // your data and code goes here
  25. // };
  26. //
  27. //----------------------------------------------------------------------------
  28. class CDoubleLink
  29. {
  30. public:
  31. CDoubleLink* Next() { return _next; }
  32. CDoubleLink* Prev() { return _prev; }
  33. void Close() { _next = this; _prev = this; }
  34. BOOL IsSingle() const { return _next == this; }
  35. void Unlink()
  36. {
  37. _next->_prev = _prev;
  38. _prev->_next = _next;
  39. }
  40. void InsertBefore ( CDoubleLink* pAfter )
  41. {
  42. CDoubleLink* pBefore = pAfter->_prev;
  43. _next = pAfter;
  44. _prev = pBefore;
  45. pAfter->_prev = this;
  46. pBefore->_next = this;
  47. }
  48. void InsertAfter ( CDoubleLink* pBefore )
  49. {
  50. CDoubleLink* pAfter = pBefore->_next;
  51. _next = pAfter;
  52. _prev = pBefore;
  53. pAfter->_prev = this;
  54. pBefore->_next = this;
  55. }
  56. protected:
  57. CDoubleLink* _next;
  58. CDoubleLink* _prev;
  59. };
  60. #endif