LZW constructor

LZW(
  1. {List alphabet,
  2. int codeSize,
  3. bool debugDecoding: false,
  4. bool debugEncoding: false}
)

Instantiates a new LZW object.

alphabet is a list of symbols the input string can contain. No duplicates are allowed in this value. codeSize is the number of codewords allowed. cannot be smaller than alphabet.length + 2

Implementation

LZW({
  this.alphabet,
  this.codeSize,
  this.debugDecoding = false,
  this.debugEncoding = false,
}) {
  alphabet.sort((a, b) => a.compareTo(b));
  for (int i = 0; i < alphabet.length - 1; i++) {
    if (alphabet[i] == alphabet[i + 1]) {
      throw new FormatException("no duplicates in alphabet allowed!");
    }
  }

  _blank = alphabet.length;
  _reset();
}