Maybe the following improved example will help.
Here is simple illustration for RLLZ, to be complete:
Reduced Length LZ (RLLZ)
(A very compact LZ. Made possible by deferred literals output.)
aacbcdeaabc <- input source
012345678910 <- index
Compress:
Encode all duplicated strings first:
Very simple:
(<size of string>, <string>, <number of "next" occurrences of string>), [positions in file or block (no match lengths needed)],
:
aa: (2, aa, 1), [0, 7]
bc: (2, bc, 1), [3, 9]
Better:
aa: (2, aa, 1-1=0), [0, 7]
bc: (2, bc, 1-1=0), [3, 9]
Encode end of string code stream: (0, , );
Encode literals last: [cde].
Decompress:
Decode all strings first;
Read/Get literals. (The literals are then inserted into the holes. Whatever the size of those holes randomly positioned in the write buffer, they are filled by the literals.)
The strings and literals are nicely in their correct order or sequences. Write to actual file.