aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/a-cborma.ads
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2011-08-29 14:19:32 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2011-08-29 16:19:32 +0200
commita6dd3a540a25276f642c8aa22d97643e98dfd171 (patch)
treeb5fe93abb86053d3a44b4175d1842263cdd40c03 /gcc/ada/a-cborma.ads
parentc54796e0c4a857f0c796c50b9c295d75bf7cb600 (diff)
downloadgcc-a6dd3a540a25276f642c8aa22d97643e98dfd171.zip
gcc-a6dd3a540a25276f642c8aa22d97643e98dfd171.tar.gz
gcc-a6dd3a540a25276f642c8aa22d97643e98dfd171.tar.bz2
a-cbhama.adb, [...]: Add iterator machinery to container packages.
2011-08-29 Ed Schonberg <schonberg@adacore.com> * a-cbhama.adb, a-cbhama.ads, a-cborma.adb, a-cborma.ads, a-cobove.adb, a-cobove.ads, a-coorma.adb, a-coorma.ads: Add iterator machinery to container packages. From-SVN: r178242
Diffstat (limited to 'gcc/ada/a-cborma.ads')
-rw-r--r--gcc/ada/a-cborma.ads70
1 files changed, 65 insertions, 5 deletions
diff --git a/gcc/ada/a-cborma.ads b/gcc/ada/a-cborma.ads
index 74dac98..6be9777 100644
--- a/gcc/ada/a-cborma.ads
+++ b/gcc/ada/a-cborma.ads
@@ -32,7 +32,8 @@
------------------------------------------------------------------------------
private with Ada.Containers.Red_Black_Trees;
-private with Ada.Streams;
+with Ada.Streams; use Ada.Streams;
+with Ada.Iterator_Interfaces;
generic
type Key_Type is private;
@@ -47,7 +48,13 @@ package Ada.Containers.Bounded_Ordered_Maps is
function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
- type Map (Capacity : Count_Type) is tagged private;
+ type Map (Capacity : Count_Type) 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;
@@ -56,6 +63,10 @@ package Ada.Containers.Bounded_Ordered_Maps is
Empty_Map : constant Map;
No_Element : constant Cursor;
+ function Has_Element (Position : Cursor) return Boolean;
+
+ package Map_Iterator_Interfaces is new
+ Ada.Iterator_Interfaces (Cursor, Has_Element);
function "=" (Left, Right : Map) return Boolean;
@@ -159,8 +170,6 @@ package Ada.Containers.Bounded_Ordered_Maps is
function Contains (Container : Map; Key : Key_Type) return Boolean;
- function Has_Element (Position : Cursor) return Boolean;
-
function "<" (Left, Right : Cursor) return Boolean;
function ">" (Left, Right : Cursor) return Boolean;
@@ -173,10 +182,56 @@ package Ada.Containers.Bounded_Ordered_Maps is
function ">" (Left : Key_Type; Right : Cursor) return Boolean;
+ 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 : 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));
+ function Iterate (Container : Map)
+ return Map_Iterator_Interfaces.Forward_Iterator'class;
+
+ function Iterate (Container : Map; Start : Cursor)
+ return Map_Iterator_Interfaces.Reversible_Iterator'class;
+
procedure Reverse_Iterate
(Container : Map;
Process : not null access procedure (Position : Cursor));
@@ -206,7 +261,6 @@ private
use Red_Black_Trees;
use Tree_Types;
- use Ada.Streams;
type Cursor is record
Container : Map_Access;
@@ -239,6 +293,12 @@ private
for Map'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_Map : constant Map := Map'(Tree_Type with Capacity => 0);
end Ada.Containers.Bounded_Ordered_Maps;