-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reverse Reader #4
Comments
It probably makes the most sense to implement them as different endianness types, like BigEndianReversed and LittleEndianReversed. The endianness implementations can push and pop values into and out of a bitqueue any way they'd like, and you'd get both a reader and writer for free. All the numeric types do have a reverse_bits method which could make this relatively straightforward. Unfortunately, it's a nightly-only experimental API for now. |
Hmm, I think I have expressed this incorrectly. What I'm interested in doing is
So I want to seek to the end of the buffer and read the things I have written in reverse order. The use case for this is a new kind of entropy coder (ANS) which recovers the encoded sequence by processing the written bits in reverse order they are written to the output stream. |
Yes, I see what you mean. In that instance, you're definitely going to overhaul how the reader processes the stream's input, turning it into more of a bit stack. Having some sort of reversible byte source for the reader would make life easier, but even then the internal queue will need to be consumed in the opposite order. It's a tough nut to crack that I'm still pondering an efficient solution to accomplish. |
After giving it a bit more thought, simply reversing the endianness should be sufficient once the byte stream is reversed in order to pop off values in the opposite order. The difficulty is coming up with an implementation of Read that traverses the stream backwards - assuming it's not feasible to simply read in the whole file to a buffer and reverse it that way. It appears Crates.io has an old buggy reverse IO implementation and one that returns chunks in reverse order (though the chunks themselves would need reversing), but neither is exactly what you need.
|
for a specific application I require to read the written bits in reverse order. What would be the easiest way to accomplish this?
Write a BitReaderReverse class with a custom BitQueue?
The text was updated successfully, but these errors were encountered: