requires: {#PositionableStream. #Trie}. provides: {#LZWReadStream. #LZWWriteStream}. prototypes addPrototype: #LZWReadStream derivedFrom: {PositionableReadStream}. "A ReadStream which reads from another stream some LZW-compressed data and outputs the decompressed contents." LZWReadStream addSlot: #source valued: ReadStream clone. "The stream from which the values are read." LZWReadStream addSlot: #strings valued: Trie newEmpty. "The set of sequences seen so far; the codes are stored at the leaves." LZWReadStream addSlot: #currentString. lz@(LZWReadStream traits) on: s [ lz source: s. lz strings: lz strings newEmpty. lz currentString: lz strings. lz ]. lz@(LZWReadStream traits) wordSize [ lz source wordSize ]. lz@(LZWReadStream traits) next [| nextChar | nextChar: lz source next. ]. prototypes addPrototype: #LZWWriteStream derivedFrom: {PositionableWriteStream}. "A WriteStream which writes out data in an LZW-compressed form. The flush method actually causes the write to occur, since a dictionary needs to be built up first to encode the data." LZWWriteStream addSlot: #source valued: ReadStream clone. "The stream to which the compressed values are written." LZWReadStream addSlot: #strings valued: Trie newEmpty. "The set of sequences seen so far; the codes are stored at the leaves." LZWReadStream addSlot: #currentString.