summaryrefslogtreecommitdiff
path: root/gcc/ada/a-cohase.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-23 13:32:44 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-23 13:32:44 +0000
commit2b89c55cc599a0c13e3514eeabd20d4893b235b2 (patch)
treee4cb2a009b5464c65617b77964d5b5b7ae9ba450 /gcc/ada/a-cohase.adb
parent4f5c3083fc525ff07099de9eb76a25986ca95762 (diff)
downloadgcc-2b89c55cc599a0c13e3514eeabd20d4893b235b2.tar.gz
2011-11-23 Matthew Heaney <heaney@adacore.com>
* a-coorse.ads, a-ciorse.ads, a-cborse.ads (Set_Iterator_Interfaces): Renamed from Ordered_Set_Iterator_Interfaces. * a-coorse.adb, a-ciorse.adb, a-cborse.adb (Iterator): Declared Iterator type as limited (First, Last): Cursor return value depends on iterator node value (Iterate): Use start position as iterator node value (Next, Previous): Forward to corresponding cursor-based operation. * a-cohase.ads, a-cohase.adb: Implemented forward iterator. * a-cihase.adb, a-cbhase.adb (Iterator): Removed unnecessary node component (First, Next): Forward call to corresponding cursor-based operation (Iterate): Representation of iterator no longer has node component 2011-11-23 Hristian Kirtchev <kirtchev@adacore.com> * exp_intr.adb (Expand_Unc_Deallocation): Ensure that the dereference has a proper type before the side effect removal mechanism kicks in. * sem_ch3.adb (Analyze_Subtype_Declaration): Handle a rare case where the base type of the subtype is a private itype created to act as the partial view of a constrained record type. This scenario manifests with equivalent class-wide types for records with unknown discriminants. 2011-11-23 Jerome Guitton <guitton@adacore.com> * s-osprim-vxworks.adb (Clock): Use Clock_RT_Ada. 2011-11-23 Thomas Quinot <quinot@adacore.com> * s-oscons-tmplt.c: Fix unbalanced preprocessor directives Minor reformatting/reorganization. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181666 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-cohase.adb')
-rw-r--r--gcc/ada/a-cohase.adb42
1 files changed, 41 insertions, 1 deletions
diff --git a/gcc/ada/a-cohase.adb b/gcc/ada/a-cohase.adb
index e0b2345234b..fadff195ff5 100644
--- a/gcc/ada/a-cohase.adb
+++ b/gcc/ada/a-cohase.adb
@@ -41,6 +41,17 @@ with System; use type System.Address;
package body Ada.Containers.Hashed_Sets is
+ type Iterator is limited new
+ Set_Iterator_Interfaces.Forward_Iterator with record
+ Container : Set_Access;
+ end record;
+
+ overriding function First (Object : Iterator) return Cursor;
+
+ overriding function Next
+ (Object : Iterator;
+ Position : Cursor) return Cursor;
+
-----------------------
-- Local Subprograms --
-----------------------
@@ -601,6 +612,11 @@ package body Ada.Containers.Hashed_Sets is
return Cursor'(Container'Unrestricted_Access, Node);
end First;
+ function First (Object : Iterator) return Cursor is
+ begin
+ return Object.Container.First;
+ end First;
+
----------
-- Free --
----------
@@ -920,6 +936,13 @@ package body Ada.Containers.Hashed_Sets is
B := B - 1;
end Iterate;
+ function Iterate
+ (Container : Set) return Set_Iterator_Interfaces.Forward_Iterator'Class
+ is
+ begin
+ return Iterator'(Container => Container'Unrestricted_Access);
+ end Iterate;
+
------------
-- Length --
------------
@@ -973,6 +996,23 @@ package body Ada.Containers.Hashed_Sets is
Position := Next (Position);
end Next;
+ function Next
+ (Object : Iterator;
+ Position : Cursor) return Cursor
+ is
+ begin
+ if Position.Container = null then
+ return No_Element;
+ end if;
+
+ if Position.Container /= Object.Container then
+ raise Program_Error with
+ "Position cursor of Next designates wrong set";
+ end if;
+
+ return Next (Position);
+ end Next;
+
-------------
-- Overlap --
-------------
@@ -1695,7 +1735,7 @@ package body Ada.Containers.Hashed_Sets is
begin
if Node = null then
- raise Constraint_Error with "key not in map";
+ raise Constraint_Error with "key not in map"; -- ??? "set"
end if;
return Node.Element;