summaryrefslogtreecommitdiff
path: root/gcc/ada/a-cohama.adb
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-30 12:37:06 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-30 12:37:06 +0000
commit73e4df1deaadb719c7649ac0957573ceca55f842 (patch)
tree975a7ced6842710d01af3678a4a9051684a1bce8 /gcc/ada/a-cohama.adb
parentba60c66472a4a63105c930d419641f75f4d70264 (diff)
downloadgcc-73e4df1deaadb719c7649ac0957573ceca55f842.tar.gz
2011-08-30 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 178289 using svnmerge. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@178293 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-cohama.adb')
-rw-r--r--gcc/ada/a-cohama.adb92
1 files changed, 92 insertions, 0 deletions
diff --git a/gcc/ada/a-cohama.adb b/gcc/ada/a-cohama.adb
index 65247241939..c06ba9e35e4 100644
--- a/gcc/ada/a-cohama.adb
+++ b/gcc/ada/a-cohama.adb
@@ -37,6 +37,18 @@ pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Keys);
package body Ada.Containers.Hashed_Maps is
+ type Iterator is new
+ Map_Iterator_Interfaces.Forward_Iterator with record
+ Container : Map_Access;
+ Node : Node_Access;
+ end record;
+
+ overriding function First (Object : Iterator) return Cursor;
+
+ overriding function Next
+ (Object : Iterator;
+ Position : Cursor) return Cursor;
+
-----------------------
-- Local Subprograms --
-----------------------
@@ -362,6 +374,17 @@ package body Ada.Containers.Hashed_Maps is
return Cursor'(Container'Unchecked_Access, Node);
end First;
+ function First (Object : Iterator) return Cursor is
+ M : constant Map_Access := Object.Container;
+ N : constant Node_Access := HT_Ops.First (M.HT);
+ begin
+ if N = null then
+ return No_Element;
+ end if;
+
+ return Cursor'(Object.Container.all'Unchecked_Access, N);
+ end First;
+
----------
-- Free --
----------
@@ -578,6 +601,15 @@ package body Ada.Containers.Hashed_Maps is
B := B - 1;
end Iterate;
+ function Iterate
+ (Container : Map) return Map_Iterator_Interfaces.Forward_Iterator'class
+ is
+ Node : constant Node_Access := HT_Ops.First (Container.HT);
+ It : constant Iterator := (Container'Unrestricted_Access, Node);
+ begin
+ return It;
+ end Iterate;
+
---------
-- Key --
---------
@@ -650,6 +682,18 @@ package body Ada.Containers.Hashed_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, Next (Position).Node);
+ end if;
+ end Next;
+
-------------------
-- Query_Element --
-------------------
@@ -716,6 +760,38 @@ package body Ada.Containers.Hashed_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 Constant_Reference (Container : Map; Key : Key_Type)
+ return Constant_Reference_Type is
+ begin
+ return (Element => Container.Element (Key)'Unrestricted_Access);
+ end Constant_Reference;
+
+ function Reference (Container : Map; Key : Key_Type)
+ return Reference_Type is
+ begin
+ return (Element => Container.Element (Key)'Unrestricted_Access);
+ end Reference;
+
---------------
-- Read_Node --
---------------
@@ -939,6 +1015,22 @@ package body Ada.Containers.Hashed_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;
+
----------------
-- Write_Node --
----------------