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.

125 lines
2.5 KiB

  1. #ifndef _TPQUEUE_H
  2. #define _TPQUEUE_H
  3. #include "PssException.h"
  4. #include "Allocator.h"
  5. #include "BasicTree.h"
  6. template <class WmiKey,class WmiElement>
  7. class WmiTreePriorityQueue
  8. {
  9. private:
  10. WmiBasicTree <WmiKey,WmiElement> m_Tree ;
  11. WmiAllocator &m_Allocator ;
  12. public:
  13. class Iterator ;
  14. typedef WmiStatusCode ( * IteratorFunction ) ( void *a_Void , typename WmiTreePriorityQueue :: Iterator &a_Iterator ) ;
  15. friend Iterator ;
  16. class Iterator
  17. {
  18. private:
  19. typename WmiBasicTree <WmiKey,WmiElement> :: Iterator m_Iterator ;
  20. public:
  21. Iterator () { ; }
  22. Iterator ( typename WmiBasicTree <WmiKey,WmiElement> :: Iterator &a_Iterator ) { m_Iterator = a_Iterator ; }
  23. Iterator ( const Iterator &a_Iterator ) { m_Iterator = a_Iterator.m_Iterator ; }
  24. Iterator &Left () { m_Iterator.Left () ; return *this ; }
  25. Iterator &Right () { m_Iterator.Right () ; return *this ; }
  26. Iterator &Parent () { m_Iterator.Parent () ; return *this ; }
  27. Iterator &LeftMost ()
  28. {
  29. m_Iterator.LeftMost () ;
  30. return *this ;
  31. }
  32. Iterator &RightMost ()
  33. {
  34. m_Iterator.RightMost () ;
  35. return *this ;
  36. }
  37. Iterator &Decrement ()
  38. {
  39. m_Iterator.Decrement () ;
  40. return *this ;
  41. }
  42. Iterator &Increment ()
  43. {
  44. m_Iterator.Increment () ;
  45. return *this ;
  46. }
  47. bool Null () { return m_Iterator.Null () ; }
  48. WmiKey &GetKey () { return m_Iterator.GetKey () ; }
  49. WmiElement &GetElement () { return m_Iterator.GetElement () ; }
  50. WmiStatusCode PreOrder ( void *a_Void , IteratorFunction a_Function ) ;
  51. WmiStatusCode InOrder ( void *a_Void , IteratorFunction a_Function ) ;
  52. WmiStatusCode PostOrder ( void *a_Void , IteratorFunction a_Function ) ;
  53. } ;
  54. public:
  55. WmiTreePriorityQueue (
  56. WmiAllocator &a_Allocator
  57. ) ;
  58. ~WmiTreePriorityQueue () ;
  59. WmiStatusCode Initialize () ;
  60. WmiStatusCode UnInitialize () ;
  61. WmiStatusCode EnQueue (
  62. const WmiKey &a_Key ,
  63. const WmiElement &a_Element
  64. ) ;
  65. WmiStatusCode Top (
  66. WmiKey &a_Key ,
  67. WmiElement &a_Element
  68. ) ;
  69. WmiStatusCode Top (
  70. Iterator &a_Iterator
  71. ) ;
  72. WmiStatusCode DeQueue () ;
  73. WmiStatusCode Delete (
  74. const WmiKey &a_Key
  75. ) ;
  76. WmiStatusCode Merge (
  77. WmiTreePriorityQueue <WmiKey,WmiElement> &a_Queue
  78. ) ;
  79. ULONG Size () { return m_Tree.Size () ; } ;
  80. Iterator Begin () { return Iterator ( m_Tree.Begin () ) ; }
  81. Iterator End () { return Iterator ( m_Tree.End () ) ; }
  82. Iterator Root () { return Iterator ( m_Tree.Root () ) ; }
  83. } ;
  84. #include <TPQueue.cpp>
  85. #endif _TPQUEUE_H