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.

88 lines
2.2 KiB

  1. /*===================================================================
  2. Microsoft Denali
  3. Microsoft Confidential.
  4. Copyright 1996 Microsoft Corporation. All Rights Reserved.
  5. Component: Hash tables with LRU threading
  6. File: DblLink.cpp
  7. Owner: DGottner
  8. simple, effective linked list manager
  9. ===================================================================*/
  10. #include "denpre.h"
  11. #pragma hdrstop
  12. #include "DblLink.h"
  13. #include "memchk.h"
  14. /*------------------------------------------------------------------
  15. * C D b l L i n k
  16. */
  17. /*===================================================================
  18. CDblLink::UnLink
  19. Unlink this element from the list that it currently resides on
  20. ===================================================================*/
  21. void CDblLink::UnLink()
  22. {
  23. m_pLinkPrev->m_pLinkNext = m_pLinkNext;
  24. m_pLinkNext->m_pLinkPrev = m_pLinkPrev;
  25. // Paranoia:
  26. // reset the node to empty after the unlink
  27. //
  28. m_pLinkPrev = m_pLinkNext = this;
  29. }
  30. /*===================================================================
  31. CDblLink::AppendTo
  32. Append this link onto a list
  33. Parameters: pListHead - pointer to a the list header (itself
  34. a CDblLink) to append this item onto.
  35. Condition: the link must be UnLink'ed before this method is called
  36. ===================================================================*/
  37. void CDblLink::AppendTo(CDblLink &ListHead)
  38. {
  39. UnLink();
  40. m_pLinkNext = &ListHead; // remember termination is at list head
  41. m_pLinkPrev = ListHead.m_pLinkPrev;
  42. ListHead.m_pLinkPrev->m_pLinkNext = this;
  43. ListHead.m_pLinkPrev = this;
  44. }
  45. /*===================================================================
  46. CDblLink::Prepend
  47. Prepend this link onto a list
  48. Parameters: pListHead - pointer to a the list header (itself
  49. a CDblLink) to prepend this item onto.
  50. Condition: the link must be UnLink'ed before this method is called
  51. ===================================================================*/
  52. void CDblLink::PrependTo(CDblLink &ListHead)
  53. {
  54. UnLink();
  55. m_pLinkPrev = &ListHead;
  56. m_pLinkNext = ListHead.m_pLinkNext;
  57. ListHead.m_pLinkNext->m_pLinkPrev = this;
  58. ListHead.m_pLinkNext = this;
  59. }