1#ifndef CASACORE_TABLES_BITPACKING_H_
2#define CASACORE_TABLES_BITPACKING_H_
6inline void PackBoolArray(
unsigned char* packed_buffer,
const bool* input,
size_t n) {
7 const size_t limit = n / 8;
8 const bool* end = input + n;
9 for (
size_t i = 0; i != limit; ++i) {
11 for (
size_t b = 0; b != 8; ++b) {
12 *packed_buffer |= (*input) << b;
21 *packed_buffer |= (*input) << b;
24 }
while (input != end);
28inline void UnpackBoolArray(
bool* output,
const unsigned char* packed_input,
size_t n) {
29 bool* end = output + n;
30 const size_t limit = n / 8;
31 for (
size_t i = 0; i != limit; i++) {
32 for (
size_t b = 0; b != 8; ++b) {
33 *output = (*packed_input >> b) & 0x1;
39 while (output != end) {
40 *output = (*packed_input >> b) & 0x1;
void UnpackBoolArray(bool *output, const unsigned char *packed_input, size_t n)
void PackBoolArray(unsigned char *packed_buffer, const bool *input, size_t n)