575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
|
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
|
-
+
|
Max_Dict_Size : in Positive;
Updated : out Boolean)
is
pragma Unreferenced (Min_Dict_Size);
pragma Unreferenced (Max_Dict_Size);
use type Ada.Streams.Stream_Element_Offset;
New_Position : String_Lists.Cursor;
No_Longer_Pending : String_Lists.Cursor;
Log_Message : Ada.Strings.Unbounded.Unbounded_String;
Original : constant Dictionary := Dict.Element;
Worst_Index : constant Dictionary_Entry
:= Worst_Element
(Original, Counts, Method, First, Last_Code (Original));
Worst_Value : constant String
:= Dict_Entry (Original, Worst_Index);
|
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
|
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
|
-
+
+
-
+
+
+
|
Evaluate_Dictionary
(Job_Count, New_Dict, Input_Texts, New_Score, New_Counts);
if New_Score < Score then
Dict := Holders.To_Holder (New_Dict);
Score := New_Score;
Counts := New_Counts;
New_Position := Position;
No_Longer_Pending := Position;
Updated := True;
Log_Message := Ada.Strings.Unbounded.To_Unbounded_String
("Removing"
& Worst_Count'Img & "x "
& Natools.String_Escapes.C_Escape_Hex (Worst_Value, True)
& ", adding"
& Counts (Last_Code (New_Dict))'Img & "x "
& Natools.String_Escapes.C_Escape_Hex (Word, True)
& ", size"
& Score'Img
& " ("
& Ada.Streams.Stream_Element_Offset'Image
(Score - Old_Score)
& ')');
end if;
end;
end loop;
if Updated then
if String_Lists.Has_Element (No_Longer_Pending) then
Pending_Words.Delete (New_Position);
Pending_Words.Delete (No_Longer_Pending);
end if;
Pending_Words.Append (Worst_Value);
Ada.Text_IO.Put_Line
(Ada.Text_IO.Current_Error,
Ada.Strings.Unbounded.To_String (Log_Message));
end if;
end Optimization_Round;
|