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.

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