WanzenBug / bitstream

Provide methods for dealing with single bit input and output in Rust
MIT License
1 stars 1 forks source link

Stream bits from the least significant bit? #2

Open adsharma opened 5 years ago

adsharma commented 5 years ago

I'm not sure how this library is used, but most other implementations I've seen stream bits from least significant to most significant.

https://www.boost.org/doc/libs/master/boost/beast/zlib/detail/bitstream.hpp

Any reason to do it the other way?

WanzenBug commented 5 years ago

I'm not sure I had any particular reason. I wrote this library as a part of a naive implementation of LZ77 and Huffman coding.

Its probably that way because in my head the output is a stream of bytes where each byte is "written" from left to right as MSB to LSB. So a contiguous bit stream has to "start" at the MSB.

I did not look at other implementations, as you can probably tell. I haven't done any optimizations so its probably not what you want for production use cases