OSDN Git Service

More improvements to sparc VIS vec_init code generation.
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-cborma.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT LIBRARY COMPONENTS                          --
4 --                                                                          --
5 --   A D A . C O N T A I N E R S . B O U N D E D _ O R D E R E D _ M A P S  --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 2004-2011, Free Software Foundation, Inc.         --
10 --                                                                          --
11 -- This specification is derived from the Ada Reference Manual for use with --
12 -- GNAT. The copyright notice above, and the license provisions that follow --
13 -- apply solely to the  contents of the part following the private keyword. --
14 --                                                                          --
15 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
16 -- terms of the  GNU General Public License as published  by the Free Soft- --
17 -- ware  Foundation;  either version 3,  or (at your option) any later ver- --
18 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
19 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
20 -- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
21 --                                                                          --
22 -- As a special exception under Section 7 of GPL version 3, you are granted --
23 -- additional permissions described in the GCC Runtime Library Exception,   --
24 -- version 3.1, as published by the Free Software Foundation.               --
25 --                                                                          --
26 -- You should have received a copy of the GNU General Public License and    --
27 -- a copy of the GCC Runtime Library Exception along with this program;     --
28 -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
29 -- <http://www.gnu.org/licenses/>.                                          --
30 --                                                                          --
31 -- This unit was originally developed by Matthew J Heaney.                  --
32 ------------------------------------------------------------------------------
33
34 private with Ada.Containers.Red_Black_Trees;
35
36 with Ada.Streams; use Ada.Streams;
37 with Ada.Iterator_Interfaces;
38
39 generic
40    type Key_Type is private;
41    type Element_Type is private;
42
43    with function "<" (Left, Right : Key_Type) return Boolean is <>;
44    with function "=" (Left, Right : Element_Type) return Boolean is <>;
45
46 package Ada.Containers.Bounded_Ordered_Maps is
47    pragma Pure;
48    pragma Remote_Types;
49
50    function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
51
52    type Map (Capacity : Count_Type) is tagged private with
53       constant_Indexing => Constant_Reference,
54       Variable_Indexing => Reference,
55       Default_Iterator  => Iterate,
56       Iterator_Element  => Element_Type;
57
58    pragma Preelaborable_Initialization (Map);
59
60    type Cursor is private;
61    pragma Preelaborable_Initialization (Cursor);
62
63    Empty_Map : constant Map;
64
65    No_Element : constant Cursor;
66
67    function Has_Element (Position : Cursor) return Boolean;
68
69    package Map_Iterator_Interfaces is new
70      Ada.Iterator_Interfaces (Cursor, Has_Element);
71
72    function "=" (Left, Right : Map) return Boolean;
73
74    function Length (Container : Map) return Count_Type;
75
76    function Is_Empty (Container : Map) return Boolean;
77
78    procedure Clear (Container : in out Map);
79
80    function Key (Position : Cursor) return Key_Type;
81
82    function Element (Position : Cursor) return Element_Type;
83
84    procedure Replace_Element
85      (Container : in out Map;
86       Position  : Cursor;
87       New_Item  : Element_Type);
88
89    procedure Query_Element
90      (Position : Cursor;
91       Process  : not null access
92                    procedure (Key : Key_Type; Element : Element_Type));
93
94    procedure Update_Element
95      (Container : in out Map;
96       Position  : Cursor;
97       Process   : not null access
98                     procedure (Key : Key_Type; Element : in out Element_Type));
99
100    procedure Assign (Target : in out Map; Source : Map);
101
102    function Copy (Source : Map; Capacity : Count_Type := 0) return Map;
103
104    procedure Move (Target : in out Map; Source : in out Map);
105
106    procedure Insert
107      (Container : in out Map;
108       Key       : Key_Type;
109       New_Item  : Element_Type;
110       Position  : out Cursor;
111       Inserted  : out Boolean);
112
113    procedure Insert
114      (Container : in out Map;
115       Key       : Key_Type;
116       Position  : out Cursor;
117       Inserted  : out Boolean);
118
119    procedure Insert
120      (Container : in out Map;
121       Key       : Key_Type;
122       New_Item  : Element_Type);
123
124    procedure Include
125      (Container : in out Map;
126       Key       : Key_Type;
127       New_Item  : Element_Type);
128
129    procedure Replace
130      (Container : in out Map;
131       Key       : Key_Type;
132       New_Item  : Element_Type);
133
134    procedure Exclude (Container : in out Map; Key : Key_Type);
135
136    procedure Delete (Container : in out Map; Key : Key_Type);
137
138    procedure Delete (Container : in out Map; Position : in out Cursor);
139
140    procedure Delete_First (Container : in out Map);
141
142    procedure Delete_Last (Container : in out Map);
143
144    function First (Container : Map) return Cursor;
145
146    function First_Element (Container : Map) return Element_Type;
147
148    function First_Key (Container : Map) return Key_Type;
149
150    function Last (Container : Map) return Cursor;
151
152    function Last_Element (Container : Map) return Element_Type;
153
154    function Last_Key (Container : Map) return Key_Type;
155
156    function Next (Position : Cursor) return Cursor;
157
158    procedure Next (Position : in out Cursor);
159
160    function Previous (Position : Cursor) return Cursor;
161
162    procedure Previous (Position : in out Cursor);
163
164    function Find (Container : Map; Key : Key_Type) return Cursor;
165
166    function Element (Container : Map; Key : Key_Type) return Element_Type;
167
168    function Floor (Container : Map; Key : Key_Type) return Cursor;
169
170    function Ceiling (Container : Map; Key : Key_Type) return Cursor;
171
172    function Contains (Container : Map; Key : Key_Type) return Boolean;
173
174    function "<" (Left, Right : Cursor) return Boolean;
175
176    function ">" (Left, Right : Cursor) return Boolean;
177
178    function "<" (Left : Cursor; Right : Key_Type) return Boolean;
179
180    function ">" (Left : Cursor; Right : Key_Type) return Boolean;
181
182    function "<" (Left : Key_Type; Right : Cursor) return Boolean;
183
184    function ">" (Left : Key_Type; Right : Cursor) return Boolean;
185
186    type Constant_Reference_Type
187       (Element : not null access constant Element_Type) is private
188    with
189       Implicit_Dereference => Element;
190
191    procedure Read
192      (Stream : not null access Root_Stream_Type'Class;
193       Item   : out Constant_Reference_Type);
194
195    for Constant_Reference_Type'Read use Read;
196
197    procedure Write
198      (Stream : not null access Root_Stream_Type'Class;
199       Item   : Constant_Reference_Type);
200
201    for Constant_Reference_Type'Write use Write;
202
203    type Reference_Type (Element : not null access Element_Type) is private
204    with
205       Implicit_Dereference => Element;
206
207    procedure Read
208      (Stream : not null access Root_Stream_Type'Class;
209       Item   : out Reference_Type);
210
211    for Reference_Type'Read use Read;
212
213    procedure Write
214      (Stream : not null access Root_Stream_Type'Class;
215       Item   : Reference_Type);
216
217    for Reference_Type'Write use Write;
218
219    function Constant_Reference
220      (Container : Map;
221       Key       : Key_Type)    --  SHOULD BE ALIASED ???
222       return Constant_Reference_Type;
223
224    function Reference (Container : Map; Key : Key_Type) return Reference_Type;
225
226    procedure Iterate
227      (Container : Map;
228       Process   : not null access procedure (Position : Cursor));
229
230    function Iterate
231      (Container : Map) return Map_Iterator_Interfaces.Forward_Iterator'class;
232
233    function Iterate
234      (Container : Map;
235       Start     : Cursor)
236       return Map_Iterator_Interfaces.Reversible_Iterator'class;
237
238    procedure Reverse_Iterate
239      (Container : Map;
240       Process   : not null access procedure (Position : Cursor));
241
242 private
243
244    pragma Inline (Next);
245    pragma Inline (Previous);
246
247    type Node_Type is record
248       Parent  : Count_Type;
249       Left    : Count_Type;
250       Right   : Count_Type;
251       Color   : Red_Black_Trees.Color_Type := Red_Black_Trees.Red;
252       Key     : Key_Type;
253       Element : Element_Type;
254    end record;
255
256    package Tree_Types is
257      new Red_Black_Trees.Generic_Bounded_Tree_Types (Node_Type);
258
259    type Map (Capacity : Count_Type) is
260      new Tree_Types.Tree_Type (Capacity) with null record;
261
262    type Map_Access is access all Map;
263    for Map_Access'Storage_Size use 0;
264
265    use Red_Black_Trees;
266    use Tree_Types;
267
268    type Cursor is record
269       Container : Map_Access;
270       Node      : Count_Type := 0;
271    end record;
272
273    procedure Write
274      (Stream : not null access Root_Stream_Type'Class;
275       Item   : Cursor);
276
277    for Cursor'Write use Write;
278
279    procedure Read
280      (Stream : not null access Root_Stream_Type'Class;
281       Item   : out Cursor);
282
283    for Cursor'Read use Read;
284
285    No_Element : constant Cursor := Cursor'(null, 0);
286
287    procedure Write
288      (Stream    : not null access Root_Stream_Type'Class;
289       Container : Map);
290
291    for Map'Write use Write;
292
293    procedure Read
294      (Stream    : not null access Root_Stream_Type'Class;
295       Container : out Map);
296
297    for Map'Read use Read;
298
299    type Constant_Reference_Type
300       (Element : not null access constant Element_Type) is null record;
301
302    type Reference_Type
303       (Element : not null access Element_Type) is null record;
304
305    Empty_Map : constant Map := Map'(Tree_Type with Capacity => 0);
306
307 end Ada.Containers.Bounded_Ordered_Maps;