Class MyCompressorOutputStream

java.lang.Object
java.io.OutputStream
mazealgo.model.io.MyCompressorOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class MyCompressorOutputStream extends OutputStream
Decorator that wraps another OutputStream and applies a streaming run-length encoding. Output format: pairs of (count, value) where count is 1..255. Runs longer than 255 split across multiple pairs with the same value.

Designed for the maze grid, whose cells are almost all 0 or 1 with long runs — typical compression ratios of 50-100x. On varied data (the maze header, for instance) it costs 2 bytes per input byte, so the wrapper is net positive only when long runs dominate.

Pair this with MyDecompressorInputStream on the read side.