summaryrefslogtreecommitdiff
path: root/gcc/ada/a-cimutr.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-27 10:03:09 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-27 10:03:09 +0000
commit7607042e4aa29e9f31cbcf83556aa11748a4214f (patch)
tree119eb2e20370d17d8cd10aad56e8c0dc1560c851 /gcc/ada/a-cimutr.adb
parenta9f1c79b87642425547c6be2586b7d108f03799e (diff)
downloadgcc-7607042e4aa29e9f31cbcf83556aa11748a4214f.tar.gz
2011-09-27 Robert Dewar <dewar@adacore.com>
* a-comutr.ads: Minor reformatting. 2011-09-27 Ed Schonberg <schonberg@adacore.com> * a-cimutr.adb, a-cimutr.ads, a-cbmutr.adb, a-cbmutr.ads: Add children iterators to multiway trees. 2011-09-27 Yannick Moy <moy@adacore.com> * debug.adb (d.D): New option for strict Alfa mode. * opt.ads (Strict_Alfa_Mode): New flag to interpret compiler permissions as strictly as possible. * sem_ch3.adb (Signed_Integer_Type_Declaration): In non-strict Alfa mode, now, interpret ranges of base types like GNAT does; in strict mode, simply change the range of the implicit base Itype. * gnat1drv.adb: Update comments. Set Strict_Alfa_Mode. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179258 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-cimutr.adb')
-rw-r--r--gcc/ada/a-cimutr.adb75
1 files changed, 75 insertions, 0 deletions
diff --git a/gcc/ada/a-cimutr.adb b/gcc/ada/a-cimutr.adb
index 6b9d7b6b2f1..2fdc8a75469 100644
--- a/gcc/ada/a-cimutr.adb
+++ b/gcc/ada/a-cimutr.adb
@@ -39,11 +39,28 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
From_Root : Boolean;
end record;
+ type Child_Iterator is new Tree_Iterator_Interfaces.Reversible_Iterator with
+ record
+ Container : Tree_Access;
+ Position : Cursor;
+ end record;
+
overriding function First (Object : Iterator) return Cursor;
overriding function Next
(Object : Iterator;
Position : Cursor) return Cursor;
+ overriding function First (Object : Child_Iterator) return Cursor;
+ overriding function Next
+ (Object : Child_Iterator;
+ Position : Cursor) return Cursor;
+
+ overriding function Previous
+ (Object : Child_Iterator;
+ Position : Cursor) return Cursor;
+
+ overriding function Last (Object : Child_Iterator) return Cursor;
+
-----------------------
-- Local Subprograms --
-----------------------
@@ -936,6 +953,11 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
return Object.Position;
end First;
+ function First (Object : Child_Iterator) return Cursor is
+ begin
+ return (Object.Container, Object.Position.Node.Children.First);
+ end First;
+
-----------------
-- First_Child --
-----------------
@@ -1369,6 +1391,16 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
end loop;
end Iterate_Children;
+ function Iterate_Children
+ (Container : Tree;
+ Parent : Cursor)
+ return Tree_Iterator_Interfaces.Reversible_Iterator'Class
+ is
+ pragma Unreferenced (Container);
+ begin
+ return Child_Iterator'(Parent.Container, Parent);
+ end Iterate_Children;
+
---------------------
-- Iterate_Subtree --
---------------------
@@ -1425,6 +1457,15 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
Iterate_Children (Container, Subtree, Process);
end Iterate_Subtree;
+ ----------
+ -- Last --
+ ----------
+
+ overriding function Last (Object : Child_Iterator) return Cursor is
+ begin
+ return (Object.Container, Object.Position.Node.Children.Last);
+ end Last;
+
----------------
-- Last_Child --
----------------
@@ -1551,6 +1592,21 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
end if;
end Next;
+ function Next
+ (Object : Child_Iterator;
+ Position : Cursor) return Cursor
+ is
+ C : constant Tree_Node_Access := Position.Node.Next;
+
+ begin
+ if C = null then
+ return No_Element;
+
+ else
+ return (Object.Container, C);
+ end if;
+ end Next;
+
------------------
-- Next_Sibling --
------------------
@@ -1673,6 +1729,25 @@ package body Ada.Containers.Indefinite_Multiway_Trees is
Container.Count := Container.Count + Count;
end Prepend_Child;
+ --------------
+ -- Previous --
+ --------------
+
+ overriding function Previous
+ (Object : Child_Iterator;
+ Position : Cursor) return Cursor
+ is
+ C : constant Tree_Node_Access := Position.Node.Prev;
+
+ begin
+ if C = null then
+ return No_Element;
+
+ else
+ return (Object.Container, C);
+ end if;
+ end Previous;
+
----------------------
-- Previous_Sibling --
----------------------