1 //-----------------------------------------------------------------------------
2 //
3 // Copyright (c) Microsoft. All rights reserved.
4 // This code is licensed under the Microsoft Public License.
5 // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 //
10 //-----------------------------------------------------------------------------
11 using System;
12 
13 namespace Microsoft.Cci.Pdb {
14   internal struct BitSet {
BitSetMicrosoft.Cci.Pdb.BitSet15     internal BitSet(BitAccess bits) {
16       bits.ReadInt32(out size);    // 0..3 : Number of words
17       words = new uint[size];
18       bits.ReadUInt32(words);
19     }
20 
21     //internal BitSet(int size) {
22     //  this.size = size;
23     //  words = new uint[size];
24     //}
25 
IsSetMicrosoft.Cci.Pdb.BitSet26     internal bool IsSet(int index) {
27       int word = index / 32;
28       if (word >= this.size) return false;
29       return ((words[word] & GetBit(index)) != 0);
30     }
31 
32     //internal void Set(int index) {
33     //  int word = index / 32;
34     //  if (word >= this.size) return;
35     //  words[word] |= GetBit(index);
36     //}
37 
38     //internal void Clear(int index) {
39     //  int word = index / 32;
40     //  if (word >= this.size) return;
41     //  words[word] &= ~GetBit(index);
42     //}
43 
GetBitMicrosoft.Cci.Pdb.BitSet44     private static uint GetBit(int index) {
45       return ((uint)1 << (index % 32));
46     }
47 
48     //private static uint ReverseBits(uint value) {
49     //  uint o = 0;
50     //  for (int i = 0; i < 32; i++) {
51     //    o = (o << 1) | (value & 1);
52     //    value >>= 1;
53     //  }
54     //  return o;
55     //}
56 
57     internal bool IsEmpty {
58       get { return size == 0; }
59     }
60 
61     //internal bool GetWord(int index, out uint word) {
62     //  if (index < size) {
63     //    word = ReverseBits(words[index]);
64     //    return true;
65     //  }
66     //  word = 0;
67     //  return false;
68     //}
69 
70     private int size;
71     private uint[] words;
72   }
73 
74 }
75