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.

131 lines
3.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1992.
  5. //
  6. // File: LIST.HXX
  7. //
  8. // Contents: Parametrized list class
  9. //
  10. // Classes: CList
  11. //
  12. // History: 4-Apr-91 BartoszM Created.
  13. // 22-May-92 BartoszM Replaced with doubly linked list
  14. //
  15. //----------------------------------------------------------------------------
  16. #pragma once
  17. #include "index.hxx"
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Class: CIndexList
  21. //
  22. // Purpose: Linked list of indexes
  23. //
  24. // History: 4-Apr-91 BartoszM Created.
  25. //
  26. //----------------------------------------------------------------------------
  27. const LONGLONG eSigIndexList = 0x5453494c58444e49i64; // "INDXLIST"
  28. class CIndexList: public CDoubleList
  29. {
  30. friend class CIndexIter;
  31. public:
  32. CIndexList(): _sigIndexList(eSigIndexList),
  33. _countWl(0), _count(0), _sizeIndex(0) {}
  34. unsigned Count () const { return _count; }
  35. unsigned CountWlist () const { return _countWl; }
  36. unsigned IndexSize () const { return _sizeIndex; }
  37. CIndex* GetTop() { return (CIndex *) _Top(); }
  38. void Add ( CIndex* p );
  39. CIndex* Remove ( INDEXID iid );
  40. inline CIndex* RemoveTop ( void );
  41. void Push ( CIndex* pIndex ) {
  42. _Push ( pIndex );
  43. _count++;
  44. _sizeIndex += pIndex->Size();
  45. }
  46. #ifdef CIEXTMODE
  47. void CiExtDump(void *ciExtSelf);
  48. #endif
  49. private:
  50. const LONGLONG _sigIndexList;
  51. unsigned _count;
  52. unsigned _countWl;
  53. unsigned _sizeIndex;
  54. };
  55. //+---------------------------------------------------------------------------
  56. //
  57. // Class: CForIndexIter
  58. //
  59. // Purpose: Iterator over an index list
  60. //
  61. // History: 4-Apr-91 BartoszM Created.
  62. //
  63. //----------------------------------------------------------------------------
  64. class CForIndexIter : public CForwardIter
  65. {
  66. public:
  67. CForIndexIter ( CIndexList& list ) : CForwardIter(list) {}
  68. CIndex* operator->() { return (CIndex*) _pLinkCur; }
  69. CIndex* GetIndex() { return (CIndex*) _pLinkCur; }
  70. };
  71. //+---------------------------------------------------------------------------
  72. //
  73. // Class: CForIndexIter
  74. //
  75. // Purpose: Iterator over an index list
  76. //
  77. // History: 4-Apr-91 BartoszM Created.
  78. //
  79. //----------------------------------------------------------------------------
  80. class CBackIndexIter : public CBackwardIter
  81. {
  82. public:
  83. CBackIndexIter ( CIndexList& list ) : CBackwardIter(list) {}
  84. CIndex* operator->() { return (CIndex*) _pLinkCur; }
  85. CIndex* GetIndex() { return (CIndex*) _pLinkCur; }
  86. };
  87. //+---------------------------------------------------------------------------
  88. //
  89. // Member: CIndexList::RemoveTop, public
  90. //
  91. // History: 04-Apr-91 BartoszM Created.
  92. //
  93. //----------------------------------------------------------------------------
  94. inline CIndex* CIndexList::RemoveTop ( void )
  95. {
  96. ciDebugOut (( DEB_ITRACE, "IndexList::RemoveTop\n" ));
  97. CIndex* pIndex = (CIndex*) _Pop();
  98. if ( pIndex && pIndex->IsWordlist() )
  99. _countWl--;
  100. return pIndex;
  101. }