Index: src/natools-smaz_generic-tools.adb ================================================================== --- src/natools-smaz_generic-tools.adb +++ src/natools-smaz_generic-tools.adb @@ -515,23 +515,22 @@ function Worst_Index (Dict : in Dictionary; Counts : in Dictionary_Counts; - Method : in Smaz_Tools.Methods.Enum) + Method : in Smaz_Tools.Methods.Enum; + First, Last : in Dictionary_Code) return Dictionary_Code is use type Smaz_Tools.Score_Value; - Result : Dictionary_Code := Dictionary_Code'First; + Result : Dictionary_Code := First; Worst_Score : Smaz_Tools.Score_Value := Score (Dict, Counts, Result, Method); S : Smaz_Tools.Score_Value; begin - for I in Dictionary_Code'Succ (Dictionary_Code'First) - .. Dict.Last_Code - loop + for I in Dictionary_Code'Succ (First) .. Last loop S := Score (Dict, Counts, I, Method); if S < Worst_Score then Result := I; Worst_Score := S; Index: src/natools-smaz_generic-tools.ads ================================================================== --- src/natools-smaz_generic-tools.ads +++ src/natools-smaz_generic-tools.ads @@ -123,16 +123,27 @@ Counts : in out Dictionary_Counts); -- Compress all strings of Corpus, returning the total number of -- compressed bytes and the number of uses for each dictionary -- element. + function Worst_Index + (Dict : in Dictionary; + Counts : in Dictionary_Counts; + Method : in Smaz_Tools.Methods.Enum; + First, Last : in Dictionary_Code) + return Dictionary_Code + with Pre => Last in First .. Dict.Last_Code; + -- Return the element from the given interval with worst score + function Worst_Index (Dict : in Dictionary; Counts : in Dictionary_Counts; Method : in Smaz_Tools.Methods.Enum) - return Dictionary_Code; - -- Return the element with worst score + return Dictionary_Code + is (Worst_Index (Dict, Counts, Method, + Dictionary_Code'First, Dict.Last_Code)); + -- Return the element with worst score in the whole directionary function Score_Encoded (Dict : in Dictionary; Counts : in Dictionary_Counts;