diff options
Diffstat (limited to 'gcc/ada/a-cobove.ads')
-rw-r--r-- | gcc/ada/a-cobove.ads | 83 |
1 files changed, 76 insertions, 7 deletions
diff --git a/gcc/ada/a-cobove.ads b/gcc/ada/a-cobove.ads index 9fc7945da86..7c009c0352c 100644 --- a/gcc/ada/a-cobove.ads +++ b/gcc/ada/a-cobove.ads @@ -31,7 +31,8 @@ -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ -private with Ada.Streams; +with Ada.Streams; use Ada.Streams; +with Ada.Iterator_Interfaces; generic type Index_Type is range <>; @@ -49,7 +50,12 @@ package Ada.Containers.Bounded_Vectors is No_Index : constant Extended_Index := Extended_Index'First; - type Vector (Capacity : Count_Type) is tagged private; + type Vector (Capacity : Count_Type) is tagged private with + Constant_Indexing => Constant_Reference, + Variable_Indexing => Reference, + Default_Iterator => Iterate, + Iterator_Element => Element_Type; + pragma Preelaborable_Initialization (Vector); type Cursor is private; @@ -58,6 +64,10 @@ package Ada.Containers.Bounded_Vectors is Empty_Vector : constant Vector; No_Element : constant Cursor; + function Has_Element (Position : Cursor) return Boolean; + + package Vector_Iterator_Interfaces is new + Ada.Iterator_Interfaces (Cursor, Has_Element); overriding function "=" (Left, Right : Vector) return Boolean; @@ -281,8 +291,6 @@ package Ada.Containers.Bounded_Vectors is (Container : Vector; Item : Element_Type) return Boolean; - function Has_Element (Position : Cursor) return Boolean; - procedure Iterate (Container : Vector; Process : not null access procedure (Position : Cursor)); @@ -291,6 +299,63 @@ package Ada.Containers.Bounded_Vectors is (Container : Vector; Process : not null access procedure (Position : Cursor)); + function Iterate + (Container : Vector) + return Vector_Iterator_Interfaces.Reversible_Iterator'Class; + + function Iterate + (Container : Vector; + Start : Cursor) + return Vector_Iterator_Interfaces.Reversible_Iterator'class; + + type Constant_Reference_Type + (Element : not null access constant Element_Type) is + private + with + Implicit_Dereference => Element; + + procedure Read + (Stream : not null access Root_Stream_Type'Class; + Item : out Constant_Reference_Type); + + for Constant_Reference_Type'Read use Read; + + procedure Write + (Stream : not null access Root_Stream_Type'Class; + Item : Constant_Reference_Type); + + for Constant_Reference_Type'Write use Write; + + type Reference_Type (Element : not null access Element_Type) is private + with + Implicit_Dereference => Element; + + procedure Read + (Stream : not null access Root_Stream_Type'Class; + Item : out Reference_Type); + + for Reference_Type'Read use Read; + + procedure Write + (Stream : not null access Root_Stream_Type'Class; + Item : Reference_Type); + + for Reference_Type'Write use Write; + + function Constant_Reference + (Container : Vector; Position : Cursor) -- SHOULD BE ALIASED + return Constant_Reference_Type; + + function Constant_Reference + (Container : Vector; Position : Index_Type) + return Constant_Reference_Type; + + function Reference (Container : Vector; Position : Cursor) + return Reference_Type; + + function Reference (Container : Vector; Position : Index_Type) + return Reference_Type; + generic with function "<" (Left, Right : Element_Type) return Boolean is <>; package Generic_Sorting is @@ -318,7 +383,7 @@ private pragma Inline (Next); pragma Inline (Previous); - type Elements_Array is array (Count_Type range <>) of Element_Type; + type Elements_Array is array (Count_Type range <>) of aliased Element_Type; function "=" (L, R : Elements_Array) return Boolean is abstract; type Vector (Capacity : Count_Type) is tagged record @@ -328,8 +393,6 @@ private Lock : Natural := 0; end record; - use Ada.Streams; - procedure Write (Stream : not null access Root_Stream_Type'Class; Container : Vector); @@ -362,6 +425,12 @@ private for Cursor'Read use Read; + type Constant_Reference_Type + (Element : not null access constant Element_Type) is null record; + + type Reference_Type + (Element : not null access Element_Type) is null record; + Empty_Vector : constant Vector := (Capacity => 0, others => <>); No_Element : constant Cursor := Cursor'(null, Index_Type'First); |