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.

100 lines
2.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1990 - 1999
  6. //
  7. // File: bitset.hxx
  8. //
  9. //--------------------------------------------------------------------------
  10. /* --------------------------------------------------------------------
  11. Microsoft OS/2 LAN Manager
  12. Copyright(c) Microsoft Corp., 1990
  13. -------------------------------------------------------------------- */
  14. /* --------------------------------------------------------------------
  15. File : bitset.hxx
  16. Title : Bit vector implementation of a set.
  17. History :
  18. mikemon ??-??-?? Beginning of this file as we know it.
  19. mikemon 11-13-90 Commented the file.
  20. -------------------------------------------------------------------- */
  21. #ifndef __BITSET_HXX__
  22. #define __BITSET_HXX__
  23. //
  24. // Implementation of a set using a bit vector. Other than available memory,
  25. // and the maximum value of a signed integer, there are no constraints on
  26. // the size of the bitset.
  27. //
  28. class BITSET
  29. {
  30. private:
  31. //
  32. // The array of bits making up the bit vector.
  33. //
  34. unsigned int * pBits;
  35. //
  36. // This is the number of unsigned ints in the bit vector,
  37. // rather than the number of bits; the number of bits is
  38. // cBits*sizeof(int)*8.
  39. //
  40. int cBits;
  41. // Initial storage
  42. unsigned int InitialStorage;
  43. public:
  44. BITSET (void)
  45. {
  46. pBits = &InitialStorage;
  47. cBits = 1;
  48. InitialStorage = 0;
  49. }
  50. ~BITSET (void)
  51. {
  52. if (pBits != &InitialStorage)
  53. delete pBits;
  54. }
  55. //
  56. // Indicates success (0), or an error. A return value of one (1),
  57. // means that a memory allocation error occured. NOTE: If an error
  58. // does occur, the bitset is left in the same state as before the
  59. // Insert operation was attempted.
  60. //
  61. int
  62. Insert (
  63. int Key
  64. );
  65. //
  66. // Indicates whether the key is a member (1) or not (0).
  67. // Tests whether a key is a member of the set or not.
  68. //
  69. int
  70. MemberP (
  71. int Key
  72. );
  73. //
  74. // Deletes Key from the bitset
  75. //
  76. void
  77. Delete (
  78. int Key
  79. );
  80. };
  81. #endif // __BITSET_HXX__