| 17 | { |
| 18 | template <std::size_t BITS> |
| 19 | class BitArray |
| 20 | { |
| 21 | /* Array element type and vector of element type. */ |
| 22 | using Element = std::uint32_t; |
| 23 | /* Number of bits in each BitArray element. */ |
| 24 | static constexpr size_t WIDTH = sizeof(Element) * CHAR_BIT; |
| 25 | /* Number of elements to represent a bit array of the specified size of bits. */ |
| 26 | static constexpr size_t COUNT = (BITS + WIDTH - 1) / WIDTH; |
| 27 | |
| 28 | public: |
| 29 | /* BUFFER type declaration for BitArray */ |
| 30 | using Buffer = std::array<Element, COUNT>; |
| 31 | /* To tell if a bit is set in array, it selects an element from the array, and test |
| 32 | * if the relevant bit set. |
| 33 | * Note the parameter "bit" is an index to the bit, 0 <= bit < BITS. |
| 34 | */ |
| 35 | inline bool test(size_t bit) const |
| 36 | { |
| 37 | return (bit < BITS) ? mData[bit / WIDTH].test(bit % WIDTH) : false; |
| 38 | } |
| 39 | /* Returns total number of bytes needed for the array */ |
| 40 | inline size_t bytes() { return (BITS + CHAR_BIT - 1) / CHAR_BIT; } |
| 41 | /* Returns true if array contains any non-zero bit from the range defined by start and end |
| 42 | * bit index [startIndex, endIndex). |
| 43 | */ |
| 44 | bool any(size_t startIndex, size_t endIndex); |
| 45 | /* Load bit array values from buffer */ |
| 46 | void loadFromBuffer(const Buffer &buffer) |
| 47 | { |
| 48 | for (size_t i = 0; i < COUNT; i++) |
| 49 | { |
| 50 | mData[i] = std::bitset<WIDTH>(buffer[i]); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | private: |
| 55 | std::array<std::bitset<WIDTH>, COUNT> mData; |
| 56 | }; |
| 57 | } |
| 58 | |
| 59 | class ATouchEvent |
nothing calls this directly
no outgoing calls
no test coverage detected