diff options
Diffstat (limited to 'gcc/ada/a-ciorma.adb')
-rw-r--r-- | gcc/ada/a-ciorma.adb | 140 |
1 files changed, 139 insertions, 1 deletions
diff --git a/gcc/ada/a-ciorma.adb b/gcc/ada/a-ciorma.adb index 9cfcd3f5a80..c30abd08046 100644 --- a/gcc/ada/a-ciorma.adb +++ b/gcc/ada/a-ciorma.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2004-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 2004-2011, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -37,6 +37,24 @@ pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Keys); package body Ada.Containers.Indefinite_Ordered_Maps is + type Iterator is new + Map_Iterator_Interfaces.Reversible_Iterator with record + Container : Map_Access; + Node : Node_Access; + end record; + + overriding function First (Object : Iterator) return Cursor; + + overriding function Last (Object : Iterator) return Cursor; + + overriding function Next + (Object : Iterator; + Position : Cursor) return Cursor; + + overriding function Previous + (Object : Iterator; + Position : Cursor) return Cursor; + ----------------------------- -- Node Access Subprograms -- ----------------------------- @@ -305,6 +323,17 @@ package body Ada.Containers.Indefinite_Ordered_Maps is return Node.Color; end Color; + ------------------------ + -- Constant_Reference -- + ------------------------ + + function Constant_Reference + (Container : Map; + Key : Key_Type) return Constant_Reference_Type + is + begin return (Element => Container.Element (Key)'Unrestricted_Access); + end Constant_Reference; + -------------- -- Contains -- -------------- @@ -503,6 +532,18 @@ package body Ada.Containers.Indefinite_Ordered_Maps is return Cursor'(Container'Unrestricted_Access, T.First); end First; + function First (Object : Iterator) return Cursor is + M : constant Map_Access := Object.Container; + N : constant Node_Access := M.Tree.First; + + begin + if N = null then + return No_Element; + else + return Cursor'(Object.Container.all'Unchecked_Access, N); + end if; + end First; + ------------------- -- First_Element -- ------------------- @@ -810,6 +851,24 @@ package body Ada.Containers.Indefinite_Ordered_Maps is B := B - 1; end Iterate; + function Iterate + (Container : Map) return Map_Iterator_Interfaces.Forward_Iterator'class + is + Node : constant Node_Access := Container.Tree.First; + It : constant Iterator := (Container'Unrestricted_Access, Node); + + begin + return It; + end Iterate; + + function Iterate (Container : Map; Start : Cursor) + return Map_Iterator_Interfaces.Reversible_Iterator'class + is + It : constant Iterator := (Container'Unrestricted_Access, Start.Node); + begin + return It; + end Iterate; + --------- -- Key -- --------- @@ -847,6 +906,17 @@ package body Ada.Containers.Indefinite_Ordered_Maps is return Cursor'(Container'Unrestricted_Access, T.Last); end Last; + function Last (Object : Iterator) return Cursor is + M : constant Map_Access := Object.Container; + N : constant Node_Access := M.Tree.Last; + begin + if N = null then + return No_Element; + else + return Cursor'(Object.Container.all'Unchecked_Access, N); + end if; + end Last; + ------------------ -- Last_Element -- ------------------ @@ -941,6 +1011,18 @@ package body Ada.Containers.Indefinite_Ordered_Maps is Position := Next (Position); end Next; + function Next + (Object : Iterator; + Position : Cursor) return Cursor + is + begin + if Position.Node = null then + return No_Element; + else + return (Object.Container, Tree_Operations.Next (Position.Node)); + end if; + end Next; + ------------ -- Parent -- ------------ @@ -984,6 +1066,18 @@ package body Ada.Containers.Indefinite_Ordered_Maps is Position := Previous (Position); end Previous; + function Previous + (Object : Iterator; + Position : Cursor) return Cursor + is + begin + if Position.Node = null then + return No_Element; + else + return (Object.Container, Tree_Operations.Previous (Position.Node)); + end if; + end Previous; + ------------------- -- Query_Element -- ------------------- @@ -1084,6 +1178,35 @@ package body Ada.Containers.Indefinite_Ordered_Maps is raise Program_Error with "attempt to stream map cursor"; end Read; + procedure Read + (Stream : not null access Root_Stream_Type'Class; + Item : out Reference_Type) + is + begin + raise Program_Error with "attempt to stream reference"; + end Read; + + procedure Read + (Stream : not null access Root_Stream_Type'Class; + Item : out Constant_Reference_Type) + is + begin + raise Program_Error with "attempt to stream reference"; + end Read; + + --------------- + -- Reference -- + --------------- + + function Reference + (Container : Map; + Key : Key_Type) + return Reference_Type + is + begin + return (Element => Container.Element (Key)'Unrestricted_Access); + end Reference; + ------------- -- Replace -- ------------- @@ -1359,4 +1482,19 @@ package body Ada.Containers.Indefinite_Ordered_Maps is raise Program_Error with "attempt to stream map cursor"; end Write; + procedure Write + (Stream : not null access Root_Stream_Type'Class; + Item : Reference_Type) + is + begin + raise Program_Error with "attempt to stream reference"; + end Write; + + procedure Write + (Stream : not null access Root_Stream_Type'Class; + Item : Constant_Reference_Type) + is + begin + raise Program_Error with "attempt to stream reference"; + end Write; end Ada.Containers.Indefinite_Ordered_Maps; |