14 #ifndef THRILL_CORE_BIT_STREAM_HEADER 15 #define THRILL_CORE_BIT_STREAM_HEADER 26 template <
typename BlockWriter>
39 die_unless(block_writer.block_size() %
sizeof(size_t) == 0);
63 assert(bits == 64 || (value & (~
size_t(0) << bits)) == 0);
68 length_second = bits - length_first;
70 buffer_ |= value >> (bits - length_first);
74 pos_ = (pos_ + bits) &
mask;
113 template <
typename BlockReader>
128 : block_reader_(block_reader)
152 bits_second = bits - bits_first;
154 res =
buffer_ >> (pos_ - 1) << bits_second;
155 buffer_ = block_reader_.template GetRaw<size_t>();
159 pos_ = (pos_ + bits) &
mask;
177 if (!block_reader_.HasNext())
181 buffer_ = block_reader_.template GetRaw<size_t>();
185 return (~
buffer_ >>
pos_) != 0 || block_reader_.HasNext();
195 unsigned no_ones = 0;
199 buffer_ = block_reader_.template GetRaw<size_t>();
208 buffer_ = block_reader_.template GetRaw<size_t>();
232 #endif // !THRILL_CORE_BIT_STREAM_HEADER size_t buffer_
current buffer of 32/64 bits
BitStreamWriter(BlockWriter &block_writer)
BlockWriter & block_writer_
Output BlockWriter.
size_t GetBits(unsigned bits)
Get bits at the cursor.
unsigned GetNumberOfOnesUntilNextZero()
Returns the number of continuous 1 bits at the cursor, followed by a zero.
BitStreamReader(BlockReader &block_reader)
BitStreamWriter & operator=(const BitStreamWriter &)=delete
non-copyable: delete assignment operator
BlockReader & block_reader_
Input BlockReader.
void PutBits(const size_t &value, unsigned bits)
Append k bits to the data array.
void FlushBits()
Flush out buffered bits.
size_t pos_
currently filled number of bits