Package mazealgo.model.io
Class MyCompressorOutputStream
java.lang.Object
java.io.OutputStream
mazealgo.model.io.MyCompressorOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
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.
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.io.OutputStream
nullOutputStream, write, write
-
Constructor Details
-
MyCompressorOutputStream
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-