31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

9.4 Deflation/Inflation Coder ( DeflateCoder )<br />

1. Definition<br />

<strong>The</strong> class DeflateCoder encapsulates the algorithms “deflation” and “inflation” from the<br />

zlib-library by J.-L. Gilly and M. Adler (see www.zlib.org).<br />

Both algorithms use two buffers (for encoded and decoded data). <strong>The</strong> user can control<br />

the size of each buffer. In addition he can fine-tune some parameters of the algorithm,<br />

which gives him a trade-off between compression rate and speed.<br />

This coder is fast, gives good compression rates and has moderate memory requirements.<br />

#include < <strong>LEDA</strong>/coding/deflate.h ><br />

2. Creation<br />

DeflateCoder C(streambuf ∗ src stream = 0, streambuf ∗ tgt stream = 0,<br />

bool own streams = false, uint32 enc buffer sz = DefaultBufferSize,<br />

uint32 dec buffer sz = DefaultBufferSize);<br />

creates an instance C which uses the given source and target<br />

streams. If own streams is set, then C is responsible for the destruction<br />

of the streams, otherwise the pointers src stream and tgt stream<br />

must be valid during the life-time of C. (In addition the sizes of<br />

the two buffers may be specified.)<br />

DeflateCoder<br />

C(const char ∗ src file name, const char ∗ tgt file name,<br />

uint32 enc buffer sz = DefaultBufferSize,<br />

uint32 dec buffer sz = DefaultBufferSize);<br />

creates an instance C which uses file-streams for input and output.<br />

(In addition the sizes of the two buffers may be specified.)<br />

3. Operations<br />

Standard Operations<br />

void C.encode( ) encodes the source stream and writes the output to<br />

the target stream.<br />

void C.decode( ) decodes the source stream and writes the output to<br />

the target stream.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!