PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs

http://github.com/jbevain/cecil
C# | 67 lines | 23 code | 12 blank | 32 comment | 3 complexity | 11beafa412f83332aa6b527bb6a6e01e MD5 | raw file
 1// Copyright (c) Microsoft. All rights reserved.
 2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 3
 4using System;
 5
 6namespace Microsoft.Cci.Pdb {
 7  internal struct BitSet {
 8    internal BitSet(BitAccess bits) {
 9      bits.ReadInt32(out size);    // 0..3 : Number of words
10      words = new uint[size];
11      bits.ReadUInt32(words);
12    }
13
14    //internal BitSet(int size) {
15    //  this.size = size;
16    //  words = new uint[size];
17    //}
18
19    internal bool IsSet(int index) {
20      int word = index / 32;
21      if (word >= this.size) return false;
22      return ((words[word] & GetBit(index)) != 0);
23    }
24
25    //internal void Set(int index) {
26    //  int word = index / 32;
27    //  if (word >= this.size) return;
28    //  words[word] |= GetBit(index);
29    //}
30
31    //internal void Clear(int index) {
32    //  int word = index / 32;
33    //  if (word >= this.size) return;
34    //  words[word] &= ~GetBit(index);
35    //}
36
37    private static uint GetBit(int index) {
38      return ((uint)1 << (index % 32));
39    }
40
41    //private static uint ReverseBits(uint value) {
42    //  uint o = 0;
43    //  for (int i = 0; i < 32; i++) {
44    //    o = (o << 1) | (value & 1);
45    //    value >>= 1;
46    //  }
47    //  return o;
48    //}
49
50    internal bool IsEmpty {
51      get { return size == 0; }
52    }
53
54    //internal bool GetWord(int index, out uint word) {
55    //  if (index < size) {
56    //    word = ReverseBits(words[index]);
57    //    return true;
58    //  }
59    //  word = 0;
60    //  return false;
61    //}
62
63    private int size;
64    private uint[] words;
65  }
66
67}