1 //-----------------------------------------------------------------------------
3 // Copyright (C) Microsoft Corporation. All Rights Reserved.
5 //-----------------------------------------------------------------------------
8 namespace Microsoft
.Cci
.Pdb
{
9 internal struct BitSet
{
10 internal BitSet(BitAccess bits
) {
11 bits
.ReadInt32(out size
); // 0..3 : Number of words
12 words
= new uint[size
];
13 bits
.ReadUInt32(words
);
16 internal BitSet(int size
) {
18 words
= new uint[size
];
21 internal bool IsSet(int index
) {
22 int word
= index
/ 32;
23 if (word
>= this.size
) return false;
24 return ((words
[word
] & GetBit(index
)) != 0);
27 internal void Set(int index
) {
28 int word
= index
/ 32;
29 if (word
>= this.size
) return;
30 words
[word
] |= GetBit(index
);
33 internal void Clear(int index
) {
34 int word
= index
/ 32;
35 if (word
>= this.size
) return;
36 words
[word
] &= ~
GetBit(index
);
39 private uint GetBit(int index
) {
40 return ((uint)1 << (index
% 32));
43 private uint ReverseBits(uint value) {
45 for (int i
= 0; i
< 32; i
++) {
46 o
= (o
<< 1) | (value & 1);
52 internal bool IsEmpty
{
53 get { return size == 0; }
56 internal bool GetWord(int index
, out uint word
) {
58 word
= ReverseBits(words
[index
]);