Index: src/natools-smaz-tools.adb ================================================================== --- src/natools-smaz-tools.adb +++ src/natools-smaz-tools.adb @@ -917,18 +917,19 @@ function Worst_Index (Dict : in Dictionary; Counts : in Dictionary_Counts; - Method : in Methods.Enum) + Method : in Methods.Enum; + First, Last : in Ada.Streams.Stream_Element) return Ada.Streams.Stream_Element is - Result : Ada.Streams.Stream_Element := 0; - Worst_Score : Score_Value := Score (Dict, Counts, 0, Method); + Result : Ada.Streams.Stream_Element := First; + Worst_Score : Score_Value := Score (Dict, Counts, First, Method); S : Score_Value; begin - for I in 1 .. Dict.Dict_Last loop + for I in First + 1 .. Last loop S := Score (Dict, Counts, I, Method); if S < Worst_Score then Result := I; Worst_Score := S; Index: src/natools-smaz-tools.ads ================================================================== --- src/natools-smaz-tools.ads +++ src/natools-smaz-tools.ads @@ -204,16 +204,26 @@ 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 Methods.Enum; + First, Last : in Ada.Streams.Stream_Element) + return Ada.Streams.Stream_Element + with Pre => Last in First .. Dict.Dict_Last; + -- Return the element with worst score in the whole directionary + function Worst_Index (Dict : in Dictionary; Counts : in Dictionary_Counts; Method : in Methods.Enum) - return Ada.Streams.Stream_Element; - -- Return the element with worst score + return Ada.Streams.Stream_Element + is (Worst_Index (Dict, Counts, Method, 0, Dict.Dict_Last)); + -- Return the element with worst score in the whole directionary type Score_Value is range 0 .. 2 ** 31 - 1; function Score_Encoded