Source code of Windows XP (NT5)
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.

213 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 1992-2000 Microsoft Corporation
  3. Module Name:
  4. digraph.hxx
  5. Abstract:
  6. This class implements a directed graph.
  7. Author:
  8. Norbert P. Kusters (norbertk) 17-Mar-92
  9. --*/
  10. #if !defined(DIGRAPH_DEFN)
  11. #define DIGRAPH_DEFN
  12. #include "membmgr.hxx"
  13. #include "membmgr2.hxx"
  14. #if defined ( _AUTOCHECK_ )
  15. #define IFSUTIL_EXPORT
  16. #elif defined ( _IFSUTIL_MEMBER_ )
  17. #define IFSUTIL_EXPORT __declspec(dllexport)
  18. #else
  19. #define IFSUTIL_EXPORT __declspec(dllimport)
  20. #endif
  21. DECLARE_CLASS( NUMBER_SET );
  22. DECLARE_CLASS( BITVECTOR );
  23. DECLARE_CLASS( INTSTACK );
  24. DECLARE_CLASS( CONTAINER );
  25. DECLARE_CLASS( DIGRAPH_EDGE );
  26. class DIGRAPH_EDGE : public OBJECT {
  27. public:
  28. IFSUTIL_EXPORT
  29. DECLARE_CONSTRUCTOR( DIGRAPH_EDGE );
  30. ULONG Parent;
  31. ULONG Child;
  32. };
  33. struct CHILD_ENTRY {
  34. CHILD_ENTRY* Next;
  35. ULONG Child; // first child described this node
  36. ULONG ChildBits[1]; // 0 bit is same as "Child"
  37. };
  38. DEFINE_POINTER_TYPES(CHILD_ENTRY);
  39. #define BITS_PER_CHILD_ENTRY (32) // 1 * (bits per ulong)
  40. struct PARENT_ENTRY {
  41. PARENT_ENTRY* Next;
  42. ULONG Parent;
  43. RTL_GENERIC_TABLE Children;
  44. };
  45. DEFINE_POINTER_TYPES(PARENT_ENTRY);
  46. DECLARE_CLASS( DIGRAPH );
  47. class DIGRAPH : public OBJECT {
  48. public:
  49. IFSUTIL_EXPORT
  50. DECLARE_CONSTRUCTOR( DIGRAPH );
  51. IFSUTIL_EXPORT
  52. VIRTUAL
  53. ~DIGRAPH(
  54. );
  55. NONVIRTUAL
  56. IFSUTIL_EXPORT
  57. BOOLEAN
  58. Initialize(
  59. IN ULONG NumberOfNodes
  60. );
  61. NONVIRTUAL
  62. IFSUTIL_EXPORT
  63. BOOLEAN
  64. AddEdge(
  65. IN ULONG Parent,
  66. IN ULONG Child
  67. );
  68. NONVIRTUAL
  69. IFSUTIL_EXPORT
  70. BOOLEAN
  71. RemoveEdge(
  72. IN ULONG Parent,
  73. IN ULONG Child
  74. );
  75. NONVIRTUAL
  76. ULONG
  77. QueryNumChildren(
  78. IN ULONG Parent
  79. ) CONST;
  80. NONVIRTUAL
  81. ULONG
  82. QueryNumParents(
  83. IN ULONG Child
  84. ) CONST;
  85. NONVIRTUAL
  86. IFSUTIL_EXPORT
  87. BOOLEAN
  88. QueryChildren(
  89. IN ULONG Parent,
  90. OUT PNUMBER_SET Children
  91. ) CONST;
  92. NONVIRTUAL
  93. IFSUTIL_EXPORT
  94. BOOLEAN
  95. QueryParents(
  96. IN ULONG Child,
  97. OUT PNUMBER_SET Parents
  98. ) CONST;
  99. NONVIRTUAL
  100. IFSUTIL_EXPORT
  101. BOOLEAN
  102. QueryParentsWithChildren(
  103. OUT PNUMBER_SET Parents,
  104. IN ULONG MinimumNumberOfChildren DEFAULT 1
  105. ) CONST;
  106. NONVIRTUAL
  107. IFSUTIL_EXPORT
  108. BOOLEAN
  109. EliminateCycles(
  110. IN OUT PCONTAINER RemovedEdges
  111. );
  112. INLINE
  113. PVOID
  114. AllocChild(
  115. IN ULONG Size
  116. );
  117. INLINE
  118. VOID
  119. FreeChild(
  120. IN PVOID Buffer
  121. );
  122. private:
  123. NONVIRTUAL
  124. PPARENT_ENTRY
  125. GetParentEntry(
  126. IN ULONG Parent
  127. ) CONST;
  128. NONVIRTUAL
  129. BOOLEAN
  130. DescendDigraph(
  131. IN ULONG CurrentNode,
  132. IN OUT PBITVECTOR Visited,
  133. IN OUT PINTSTACK Ancestors,
  134. IN OUT PCONTAINER RemovedEdges
  135. );
  136. NONVIRTUAL
  137. VOID
  138. Construct (
  139. );
  140. NONVIRTUAL
  141. VOID
  142. Destroy(
  143. );
  144. PPARENT_ENTRY* _parent_head;
  145. ULONG _num_nodes;
  146. MEM_BLOCK_MGR _parent_mgr;
  147. MEM_ALLOCATOR _element_mgr;
  148. };
  149. PVOID
  150. DIGRAPH::AllocChild(
  151. IN ULONG Size
  152. )
  153. {
  154. return _element_mgr.Allocate(Size);
  155. }
  156. VOID
  157. DIGRAPH::FreeChild(
  158. IN PVOID Buffer
  159. )
  160. {
  161. return;
  162. }
  163. #endif // DIGRAPH_DEFN