diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-29 14:07:24 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-29 14:07:24 +0000 |
commit | a17a5f8322a746a3b2028251e83ee178bf58eca5 (patch) | |
tree | ad2c626c4e1e4b8d2efe3dd7f4aedb0ad37a2408 /gcc/ada/a-cihama.ads | |
parent | a053db0dacfa6b670bc8f8e3f9dff1f24159db77 (diff) | |
download | gcc-a17a5f8322a746a3b2028251e83ee178bf58eca5.tar.gz |
2011-08-29 Ed Schonberg <schonberg@adacore.com>
* exp_ch5.adb (Expand_Iterator_Loop): Handle properly a loop over a
container of a derived type.
2011-08-29 Hristian Kirtchev <kirtchev@adacore.com>
* impunit.adb, s-stposu.adb, s-stposu.ads, exp_ch4.adb, s-finmas.adb,
s-finmas.ads: Revert previous change.
2011-08-29 Ed Schonberg <schonberg@adacore.com>
* a-cidlli.adb, a-cidlli.ads, a-cihama.adb, a-cihama.ads,
a-ciorse.adb, a-ciorse.ads: Add iterator machinery to containers.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178237 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-cihama.ads')
-rw-r--r-- | gcc/ada/a-cihama.ads | 72 |
1 files changed, 65 insertions, 7 deletions
diff --git a/gcc/ada/a-cihama.ads b/gcc/ada/a-cihama.ads index 8a27c7e2619..2e089677112 100644 --- a/gcc/ada/a-cihama.ads +++ b/gcc/ada/a-cihama.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2004-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 2004-2011, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- @@ -32,8 +32,9 @@ ------------------------------------------------------------------------------ private with Ada.Containers.Hash_Tables; -private with Ada.Streams; private with Ada.Finalization; +with Ada.Streams; use Ada.Streams; +with Ada.Iterator_Interfaces; generic type Key_Type (<>) is private; @@ -47,7 +48,13 @@ package Ada.Containers.Indefinite_Hashed_Maps is pragma Preelaborate; pragma Remote_Types; - type Map is tagged private; + type Map is tagged private + with + Constant_Indexing => Constant_Reference, + Variable_Indexing => Reference, + Default_Iterator => Iterate, + Iterator_Element => Element_Type; + pragma Preelaborable_Initialization (Map); type Cursor is private; @@ -61,6 +68,12 @@ package Ada.Containers.Indefinite_Hashed_Maps is -- Cursor objects declared without an initialization expression are -- initialized to the value No_Element. + function Has_Element (Position : Cursor) return Boolean; + -- Equivalent to Position /= No_Element + + package Map_Iterator_Interfaces is new + Ada.Iterator_Interfaces (Cursor, Has_Element); + overriding function "=" (Left, Right : Map) return Boolean; -- For each key/element pair in Left, equality attempts to find the key in -- Right; if a search fails the equality returns False. The search works by @@ -227,9 +240,6 @@ package Ada.Containers.Indefinite_Hashed_Maps is function Element (Container : Map; Key : Key_Type) return Element_Type; -- Equivalent to Element (Find (Container, Key)) - function Has_Element (Position : Cursor) return Boolean; - -- Equivalent to Position /= No_Element - function Equivalent_Keys (Left, Right : Cursor) return Boolean; -- Returns the result of calling Equivalent_Keys with the keys of the nodes -- designated by cursors Left and Right. @@ -242,11 +252,54 @@ package Ada.Containers.Indefinite_Hashed_Maps is -- Returns the result of calling Equivalent_Keys with key Left and the node -- designated by Right. + type Constant_Reference_Type + (Element : not null access constant Element_Type) is private + with + Implicit_Dereference => Element; + + procedure Write + (Stream : not null access Root_Stream_Type'Class; + Item : Constant_Reference_Type); + + for Constant_Reference_Type'Write use Write; + + procedure Read + (Stream : not null access Root_Stream_Type'Class; + Item : out Constant_Reference_Type); + + for Constant_Reference_Type'Read use Read; + + type Reference_Type (Element : not null access Element_Type) is private + with + Implicit_Dereference => Element; + + procedure Write + (Stream : not null access Root_Stream_Type'Class; + Item : Reference_Type); + + for Reference_Type'Write use Write; + + procedure Read + (Stream : not null access Root_Stream_Type'Class; + Item : out Reference_Type); + + for Reference_Type'Read use Read; + + function Constant_Reference + (Container : Map; Key : Key_Type) -- SHOULD BE ALIASED + return Constant_Reference_Type; + + function Reference (Container : Map; Key : Key_Type) + return Reference_Type; + procedure Iterate (Container : Map; Process : not null access procedure (Position : Cursor)); -- Calls Process for each node in the map + function Iterate (Container : Map) + return Map_Iterator_Interfaces.Forward_Iterator'class; + private pragma Inline ("="); pragma Inline (Length); @@ -283,7 +336,6 @@ private use HT_Types; use Ada.Finalization; - use Ada.Streams; overriding procedure Adjust (Container : in out Map); @@ -303,6 +355,12 @@ private for Cursor'Write use Write; + 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; + procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Cursor); |