finalizeEncoding method

List<int> finalizeEncoding ()

Treats the remaining _praefix if existing and returns the encoded numbers and resets the algorithm.

Implementation

List<int> finalizeEncoding() {
  if (_isPatternContainedInCodebook(_praefix)) {
    _result.add(getCodeWord(_praefix));
    _reset();
  } else {
    if (_isCodebookFull()) {
      _result.add(blank);
      _reset();
    }

    _result.add(_nextCodeWord);
    _reset();
  }

  _praefix = "";
  _output = _result;
  _result = [];

  return _output;
}