1generic 2 type Component is private; 3 type List_Index is range <>; 4 type List is array (List_Index range <>) of Component; 5 Default_Value : Component; 6 -- with function "=" (Left, Right : List) return Boolean is <>; 7 8package Equal8_Pkg is 9 10 pragma Pure; 11 12 Maximum_Length : constant List_Index := List_Index'Last; 13 14 subtype Natural_Index is List_Index'Base range 0 .. Maximum_Length; 15 type Sequence (Capacity : Natural_Index) is private; 16 -- from zero to Capacity. 17 18 function Value (This : Sequence) return List; 19 -- Returns the content of this sequence. The value returned is the 20 -- "logical" value in that only that slice which is currently assigned 21 -- is returned, as opposed to the entire physical representation. 22 23 overriding 24 function "=" (Left, Right : Sequence) return Boolean with 25 Inline; 26 27 function "=" (Left : Sequence; Right : List) return Boolean with 28 Inline; 29 30private 31 type Sequence (Capacity : Natural_Index) is record 32 Current_Length : Natural_Index := 0; 33 Content : List (1 .. Capacity) := (others => Default_Value); 34 end record; 35 36 ----------- 37 -- Value -- 38 ----------- 39 40 function Value (This : Sequence) return List is 41 (This.Content (1 .. This.Current_Length)); 42 43 --------- 44 -- "=" -- 45 --------- 46 47 overriding 48 function "=" (Left, Right : Sequence) return Boolean is 49 (Value (Left) = Value (Right)); 50 51 --------- 52 -- "=" -- 53 --------- 54 55 function "=" (Left : Sequence; Right : List) return Boolean is 56 (Value (Left) = Right); 57end Equal8_Pkg; 58 59