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.

261 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. numset.hxx
  5. Abstract:
  6. This class implements a sparse number set. The number are
  7. stored in ascending order.
  8. Author:
  9. Norbert P. Kusters (norbertk) 10-Jan-91
  10. --*/
  11. #if !defined(NUMBER_SET_DEFN)
  12. #define NUMBER_SET_DEFN
  13. #include "bigint.hxx"
  14. #include "list.hxx"
  15. #if defined ( _AUTOCHECK_ )
  16. #define IFSUTIL_EXPORT
  17. #elif defined ( _IFSUTIL_MEMBER_ )
  18. #define IFSUTIL_EXPORT __declspec(dllexport)
  19. #else
  20. #define IFSUTIL_EXPORT __declspec(dllimport)
  21. #endif
  22. DECLARE_CLASS( NUMBER_SET );
  23. class NUMBER_EXTENT : public OBJECT {
  24. public:
  25. DECLARE_CONSTRUCTOR( NUMBER_EXTENT );
  26. BIG_INT Start;
  27. BIG_INT Length;
  28. };
  29. DEFINE_POINTER_TYPES(NUMBER_EXTENT);
  30. class NUMBER_SET : public OBJECT {
  31. public:
  32. IFSUTIL_EXPORT
  33. DECLARE_CONSTRUCTOR( NUMBER_SET );
  34. VIRTUAL
  35. IFSUTIL_EXPORT
  36. ~NUMBER_SET(
  37. );
  38. NONVIRTUAL
  39. IFSUTIL_EXPORT
  40. BOOLEAN
  41. Initialize(
  42. );
  43. NONVIRTUAL
  44. IFSUTIL_EXPORT
  45. BOOLEAN
  46. Add(
  47. IN BIG_INT Number
  48. );
  49. NONVIRTUAL
  50. IFSUTIL_EXPORT
  51. BOOLEAN
  52. AddStart(
  53. IN BIG_INT Number
  54. );
  55. NONVIRTUAL
  56. IFSUTIL_EXPORT
  57. BOOLEAN
  58. AddNext(
  59. IN BIG_INT Number
  60. );
  61. NONVIRTUAL
  62. IFSUTIL_EXPORT
  63. BOOLEAN
  64. Add(
  65. IN BIG_INT Start,
  66. IN BIG_INT Length
  67. );
  68. NONVIRTUAL
  69. IFSUTIL_EXPORT
  70. BOOLEAN
  71. Add(
  72. IN PCNUMBER_SET NumberSet
  73. );
  74. NONVIRTUAL
  75. IFSUTIL_EXPORT
  76. BOOLEAN
  77. CheckAndAdd(
  78. IN BIG_INT Number,
  79. OUT PBOOLEAN Duplicate
  80. );
  81. NONVIRTUAL
  82. IFSUTIL_EXPORT
  83. BOOLEAN
  84. Remove(
  85. IN BIG_INT Number
  86. );
  87. NONVIRTUAL
  88. IFSUTIL_EXPORT
  89. BOOLEAN
  90. RemoveAll(
  91. );
  92. NONVIRTUAL
  93. IFSUTIL_EXPORT
  94. BOOLEAN
  95. CheckAndRemove(
  96. IN BIG_INT Number,
  97. OUT PBOOLEAN DoesExists
  98. );
  99. NONVIRTUAL
  100. IFSUTIL_EXPORT
  101. BOOLEAN
  102. Remove(
  103. IN BIG_INT Start,
  104. IN BIG_INT Length
  105. );
  106. NONVIRTUAL
  107. IFSUTIL_EXPORT
  108. BOOLEAN
  109. Remove(
  110. IN PCNUMBER_SET NumberSet
  111. );
  112. NONVIRTUAL
  113. BIG_INT
  114. QueryCardinality(
  115. ) CONST;
  116. NONVIRTUAL
  117. IFSUTIL_EXPORT
  118. BIG_INT
  119. QueryNumber(
  120. IN BIG_INT Index
  121. ) CONST;
  122. NONVIRTUAL
  123. IFSUTIL_EXPORT
  124. BOOLEAN
  125. DoesIntersectSet(
  126. IN BIG_INT Start,
  127. IN BIG_INT Length
  128. ) CONST;
  129. NONVIRTUAL
  130. ULONG
  131. QueryNumDisjointRanges(
  132. ) CONST;
  133. NONVIRTUAL
  134. IFSUTIL_EXPORT
  135. VOID
  136. QueryDisjointRange(
  137. IN ULONG Index,
  138. OUT PBIG_INT Start,
  139. OUT PBIG_INT Length
  140. ) CONST;
  141. NONVIRTUAL
  142. IFSUTIL_EXPORT
  143. BOOLEAN
  144. QueryContainingRange(
  145. IN BIG_INT Number,
  146. OUT PBIG_INT Start,
  147. OUT PBIG_INT Length
  148. ) CONST;
  149. private:
  150. NONVIRTUAL
  151. VOID
  152. Construct (
  153. );
  154. NONVIRTUAL
  155. VOID
  156. Destroy(
  157. );
  158. LIST _list;
  159. BIG_INT _card;
  160. PITERATOR _iterator;
  161. };
  162. INLINE
  163. BIG_INT
  164. NUMBER_SET::QueryCardinality(
  165. ) CONST
  166. /*++
  167. Routine Description:
  168. This routine computes the number of elements in the set.
  169. Arguments:
  170. None.
  171. Return Value:
  172. The number of elements in the set.
  173. --*/
  174. {
  175. return _card;
  176. }
  177. INLINE
  178. ULONG
  179. NUMBER_SET::QueryNumDisjointRanges(
  180. ) CONST
  181. /*++
  182. Routine Description:
  183. This routine computes the number of disjoint ranges contained
  184. in this number set.
  185. Arguments:
  186. None.
  187. Return Value:
  188. The number of disjoint ranges contained in this number set.
  189. --*/
  190. {
  191. return _list.QueryMemberCount();
  192. }
  193. #endif // NUMBER_SET_DEFN