Warning: session_start(): open(/var/lib/php/sessions/sess_3m7ulkv09k6v31n2dr4ielhqdt, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// little-endian
sclass BitBuffer is IntSize {
new ByteBuffer byteBuffer; // TODO (optimization): use a growing circular buffer
int currentByte, currentBit;
void add(bool b) {
if (b) currentByte |= 1 << currentBit;
if (currentBit == 7) {
byteBuffer.add((byte) currentByte);
currentByte = 0;
currentBit = 0;
} else
++currentBit;
}
bool get(int iBit) {
ret (byteBuffer.get(iBit >> 3) & (1 << (iBit & 7))) != 0;
}
bool hasFullByte() {
ret !byteBuffer.isEmpty();
}
byte popFullByte() {
ret byteBuffer.popFirst();
}
public int size() {
ret byteBuffer.size()*8 + currentBit;
}
// TODO: optimize void writeBits(int data, int nBits)
}