views:

95

answers:

2

Implementing streaming compression algorithms, one usually need a super-fast FIFO bit container class with the following functions:

AddBits(UINT n, UINT nBits);  // Add lower nBits bits of n 
GetBitCount();                // Get the number of bits currently stored
GetBits(BYTE* n, UINT nBits); // Extract n Bits, and remove them

The number of bits is bounded to a relatively small size (the 'packet' size or a bit more).

I'm looking for a small C++ class which implement this functionality.

Yes, I can write one (and know how to do it), but probably someone wrote it already...

Note: I don't want to add boost / whatever-big-lib to my project just for this.

A: 

I know you don't want to, but you could use a boost dynamic bitset and provide the FIFO capability on top of it using supplier/consumer semantics.

I didn't want to use boost either, but it's really not a big deal. You don't have to do anything with libraries. You just need to have boost available on your build system and include the right include files.

Dave
+1  A: 
supercat