On 6/3/2013 8:44 PM, Walter Bright wrote:
https://github.com/WalterBright/phobos/blob/std_compress/std/compress.d
I wrote this to add components to compress and expand ranges.
Highlights:
1. doesn't do any memory allocation
2. can handle arbitrarily large sets of data
3. it's lazy
4. takes an InputRange, and outputs an InputRange
Comments welcome.
BTW, I also wrote this because it is a tricky component to write. There is not a
1:1 correspondence between input and output - the relationship is not
predictable. Worse, there are "look backs" on input and "back patches" on
output. Hence, sliding buffers have to be used on both input and output.
I like to think of it as an example of how to do such. It took me a bit of time
to figure out a way to do it that wasn't too numbingly complex.