{ Программ тестирования работы словаря для метода Лемпеля-Зива } program DicTest; USES xCrt, LZTests, ComTypes, LZTypes, LZBase, LZDic0, LZDic; var Dic:tLZDictionary; procedure WriteFragment(Code:tIndex); forward; procedure WriteFragments(const ADic:tLZDictionary); var i:tIndex; begin for i:=Succ(cRootIndex) to Pred(ADic.DicDataPtr^.Descriptors.FirstFree) do begin if ADic.DicDataPtr^.Successors^[i]=cNilIndex then begin write(i,': "'); WriteFragment(i); Write('", '); end; end; end; procedure WriteCode(ACode:tIndex); type tFlag=(fNewCode, fIncCodeLength); tFlags= set of tFlag; const Flags:tFlags=[]; const bs:set of Byte=[]; begin if fNewCode in Flags then begin Exclude(Flags,fNewCode); write(ACode); if ACode in bs then write('Error!'); Include(bs,ACode); end else if fIncCodeLength in Flags then begin Exclude(Flags,fIncCodeLength); write(ACode); end else begin NormVideo; case ACode of cCode_ResetDictionary: begin TextColor(Yellow); write('r'); Include(Flags,fNewCode); bs:=[]; end; cCode_IncCodeLength: begin TextColor(LightBlue); write('i'); Include(Flags,fIncCodeLength); end; cCode_NewByte: begin TextColor(Yellow); write('n'); Include(Flags,fNewCode); end; else begin write(ACode); end; end; end; end; procedure WriteCodes(const Codes:tLZCodesArray; n:tCodesIndex); var i:tCodesIndex; c:tIndex; const bs:set of Byte=[]; begin i:=0; while iHigh(tCodesIndex) then begin write('!',n); RunError(201); end; WriteCodes(Codes,n); i:=0; while (iHigh(tCodesIndex) then begin write('!',n); RunError(201); end; WriteCodes(Codes,n); i:=0; while (i0 then begin j:=0; write('('); while (j