/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. using System;
  4. namespace Microsoft.Cci.Pdb {
  5. internal struct BitSet {
  6. internal BitSet(BitAccess bits) {
  7. bits.ReadInt32(out size); // 0..3 : Number of words
  8. words = new uint[size];
  9. bits.ReadUInt32(words);
  10. }
  11. //internal BitSet(int size) {
  12. // this.size = size;
  13. // words = new uint[size];
  14. //}
  15. internal bool IsSet(int index) {
  16. int word = index / 32;
  17. if (word >= this.size) return false;
  18. return ((words[word] & GetBit(index)) != 0);
  19. }
  20. //internal void Set(int index) {
  21. // int word = index / 32;
  22. // if (word >= this.size) return;
  23. // words[word] |= GetBit(index);
  24. //}
  25. //internal void Clear(int index) {
  26. // int word = index / 32;
  27. // if (word >= this.size) return;
  28. // words[word] &= ~GetBit(index);
  29. //}
  30. private static uint GetBit(int index) {
  31. return ((uint)1 << (index % 32));
  32. }
  33. //private static uint ReverseBits(uint value) {
  34. // uint o = 0;
  35. // for (int i = 0; i < 32; i++) {
  36. // o = (o << 1) | (value & 1);
  37. // value >>= 1;
  38. // }
  39. // return o;
  40. //}
  41. internal bool IsEmpty {
  42. get { return size == 0; }
  43. }
  44. //internal bool GetWord(int index, out uint word) {
  45. // if (index < size) {
  46. // word = ReverseBits(words[index]);
  47. // return true;
  48. // }
  49. // word = 0;
  50. // return false;
  51. //}
  52. private int size;
  53. private uint[] words;
  54. }
  55. }