11#include <framework/utilities/Utils.h>
13namespace Belle2::ECL {
37 void putNBits(
unsigned int value,
unsigned int n)
39 unsigned int bpos =
m_pos % 32, wpos =
m_pos / 32;
40 value &= 0xffffffffu >> (32 - n);
44 if (bpos + n > 32)
m_store[wpos + 1] = value >> (32 - bpos);
54 unsigned int bpos =
m_pos % 32, wpos =
m_pos / 32;
57 unsigned int res =
m_store[wpos] >> bpos;
58 if (bpos + n > 32) res |=
m_store[wpos + 1] << (32 - bpos);
60 return res & (0xffffffffu >> (32 - n));
size_t getPos() const
Get current position in the stream.
std::vector< unsigned int > m_store
The bit storage.
void resize()
Resize data vector to the current position.
void setPos(size_t pos)
Set position in the stream.
BitStream(int n)
Constructor with the reserved and cleared storage prepared for incoming bits.
std::vector< unsigned int > & getStore()
Get data vector.
BitStream()
Default constructor for ROOT.
size_t m_pos
Current position in the storage.
unsigned int getNBits(unsigned int n)
Fetch n bits.
void putNBits(unsigned int value, unsigned int n)
Push n least significant bits of "value" to the stream.
#define branch_unlikely(x)
A macro to tell the compiler that the argument x will be very likely be false.