summaryrefslogtreecommitdiffstats
path: root/gcc/ada/a-cbhase.ads
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-27 10:11:01 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-27 10:11:01 +0000
commit7f7bd971c4e7da64838f25a1a1aced592fd5c471 (patch)
treec7ec0579749b721790ac4965474b2502ccf80d84 /gcc/ada/a-cbhase.ads
parentca70dcca983ba4626baa6adc39db954e7ad62556 (diff)
downloadppe42-gcc-7f7bd971c4e7da64838f25a1a1aced592fd5c471.tar.gz
ppe42-gcc-7f7bd971c4e7da64838f25a1a1aced592fd5c471.zip
2011-09-27 Ed Schonberg <schonberg@adacore.com>
* a-cbhase.adb, a-cbhase.ads, a-cborse.adb, a-cborse.ads, a-cihase.adb, a-cihase.ads, a-ciorse.adb, a-ciorse.ads, a-coorse.adb, a-coorse.ads: Add iterator machinery to bounded sets and indefinite sets. * a-coorma.ads: Minor reformmating. * einfo.ads: Improve the comment describing the Directly_Designated_Type function. * a-ciorma.adb, a-ciorma.ads: Add iterator machinery to indefinite ordered maps. * gcc-interface/Makefile.in, gcc-interface/Make-lang.in: Update dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179260 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-cbhase.ads')
-rw-r--r--gcc/ada/a-cbhase.ads62
1 files changed, 57 insertions, 5 deletions
diff --git a/gcc/ada/a-cbhase.ads b/gcc/ada/a-cbhase.ads
index 711c0116963..c72b8ab8597 100644
--- a/gcc/ada/a-cbhase.ads
+++ b/gcc/ada/a-cbhase.ads
@@ -31,6 +31,7 @@
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
+with Ada.Iterator_Interfaces;
private with Ada.Containers.Hash_Tables;
private with Ada.Streams;
@@ -48,7 +49,11 @@ package Ada.Containers.Bounded_Hashed_Sets is
pragma Pure;
pragma Remote_Types;
- type Set (Capacity : Count_Type; Modulus : Hash_Type) is tagged private;
+ type Set (Capacity : Count_Type; Modulus : Hash_Type) is tagged private
+ with Constant_Indexing => Constant_Reference,
+ Default_Iterator => Iterate,
+ Iterator_Element => Element_Type;
+
pragma Preelaborable_Initialization (Set);
type Cursor is private;
@@ -62,6 +67,12 @@ package Ada.Containers.Bounded_Hashed_Sets 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 Set_Iterator_Interfaces is new
+ Ada.Iterator_Interfaces (Cursor, Has_Element);
+
function "=" (Left, Right : Set) return Boolean;
-- For each element in Left, set equality attempts to find the equal
-- element in Right; if a search fails, then set equality immediately
@@ -129,7 +140,16 @@ package Ada.Containers.Bounded_Hashed_Sets is
(Position : Cursor;
Process : not null access procedure (Element : Element_Type));
-- Calls Process with the element (having only a constant view) of the node
- -- designed by the cursor.
+ -- designated by the cursor.
+
+ type Constant_Reference_Type
+ (Element : not null access constant Element_Type) is private
+ with Implicit_Dereference => Element;
+
+ function Constant_Reference
+ (Container : aliased Set;
+ Position : Cursor)
+ return Constant_Reference_Type;
procedure Assign (Target : in out Set; Source : Set);
-- If Target denotes the same object as Source, then the operation has no
@@ -314,9 +334,6 @@ package Ada.Containers.Bounded_Hashed_Sets is
function Contains (Container : Set; Item : Element_Type) return Boolean;
-- Equivalent to Find (Container, Item) /= No_Element
- function Has_Element (Position : Cursor) return Boolean;
- -- Equivalent to Position /= No_Element
-
function Equivalent_Elements (Left, Right : Cursor) return Boolean;
-- Returns the result of calling Equivalent_Elements with the elements of
-- the nodes designated by cursors Left and Right.
@@ -338,6 +355,9 @@ package Ada.Containers.Bounded_Hashed_Sets is
Process : not null access procedure (Position : Cursor));
-- Calls Process for each node in the set
+ function Iterate (Container : Set)
+ return Set_Iterator_Interfaces.Forward_Iterator'Class;
+
generic
type Key_Type (<>) is private;
@@ -406,6 +426,23 @@ package Ada.Containers.Bounded_Hashed_Sets is
-- completes. Otherwise, the node is removed from the map and
-- Program_Error is raised.
+ type Reference_Type (Element : not null access Element_Type) is private
+ with Implicit_Dereference => Element;
+
+ function Reference_Preserving_Key
+ (Container : aliased in out Set;
+ Position : Cursor)
+ return Reference_Type;
+
+ function Reference_Preserving_Key
+ (Container : aliased in out Set;
+ Key : Key_Type)
+ return Reference_Type;
+
+ private
+ type Reference_Type (Element : not null access Element_Type)
+ is null record;
+
end Generic_Keys;
private
@@ -466,6 +503,21 @@ private
for Set'Read use Read;
+ type Constant_Reference_Type
+ (Element : not null access constant Element_Type) is null record;
+
+ 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;
+
Empty_Set : constant Set :=
(Hash_Table_Type with Capacity => 0, Modulus => 0);
OpenPOWER on IntegriCloud