| 62 | uint64_t BitsWritten() const { return counter * 2; } |
| 63 | |
| 64 | void Insert(ChimpConstants::Flags value) { |
| 65 | if (!EMPTY) { |
| 66 | if ((counter & 3) == 0) { |
| 67 | // Start the new byte fresh |
| 68 | buffer[counter >> 2] = 0; |
| 69 | #ifdef DEBUG |
| 70 | flags.clear(); |
| 71 | #endif |
| 72 | } |
| 73 | #ifdef DEBUG |
| 74 | flags.push_back((uint8_t)value); |
| 75 | #endif |
| 76 | buffer[counter >> 2] |= (((uint8_t)value & 3) << FlagBufferConstants::SHIFTS[counter & 3]); |
| 77 | #ifdef DEBUG |
| 78 | // Verify that the bits are serialized correctly |
| 79 | D_ASSERT(flags[counter & 3] == ExtractValue(buffer[counter >> 2], counter & 3)); |
| 80 | #endif |
| 81 | } |
| 82 | counter++; |
| 83 | } |
| 84 | |
| 85 | void Insert(GorillasConstants::Flags value) { |
| 86 | if (!EMPTY) { |