| 36 | #include "../include/NvFlexExt.h" |
| 37 | |
| 38 | class Bitmap |
| 39 | { |
| 40 | public: |
| 41 | |
| 42 | typedef unsigned int Word; |
| 43 | |
| 44 | static const int kWordSize = sizeof(Word)*8; |
| 45 | |
| 46 | Bitmap(int numBits) : mBits((numBits+kWordSize-1)/kWordSize) |
| 47 | { |
| 48 | } |
| 49 | |
| 50 | inline void Set(int bit) |
| 51 | { |
| 52 | const int wordIndex = bit/kWordSize; |
| 53 | const int bitIndex = bit&(kWordSize-1); |
| 54 | |
| 55 | const Word word = mBits[wordIndex]; |
| 56 | |
| 57 | mBits[wordIndex] = word|(1<<bitIndex); |
| 58 | } |
| 59 | |
| 60 | inline void Reset(int bit) |
| 61 | { |
| 62 | const int wordIndex = bit/kWordSize; |
| 63 | const int bitIndex = bit&(kWordSize-1); |
| 64 | |
| 65 | const Word word = mBits[wordIndex]; |
| 66 | |
| 67 | mBits[wordIndex] = word&~(1<<bitIndex); |
| 68 | } |
| 69 | |
| 70 | inline bool IsSet(int bit) |
| 71 | { |
| 72 | const int wordIndex = bit/kWordSize; |
| 73 | const int bitIndex = bit&(kWordSize-1); |
| 74 | |
| 75 | const Word word = mBits[wordIndex]; |
| 76 | |
| 77 | return (word & (1<<bitIndex)) != 0; |
| 78 | } |
| 79 | |
| 80 | private: |
| 81 | |
| 82 | std::vector<Word> mBits; |
| 83 | }; |
| 84 | |
| 85 | |
| 86 | struct NvFlexExtContainer |
nothing calls this directly
no outgoing calls
no test coverage detected