OSDN Git Service

More improvements to sparc VIS vec_init code generation.
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-ciorma.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT LIBRARY COMPONENTS                          --
4 --                                                                          --
5 --                 ADA.CONTAINERS.INDEFINITE_ORDERED_MAPS                   --
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 with Ada.Iterator_Interfaces;
35 private with Ada.Containers.Red_Black_Trees;
36 private with Ada.Finalization;
37 private with Ada.Streams;
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.Indefinite_Ordered_Maps is
47    pragma Preelaborate;
48    pragma Remote_Types;
49
50    function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
51
52    type Map is tagged private
53    with 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    function Has_Element (Position : Cursor) return Boolean;
67
68    package Map_Iterator_Interfaces is new
69      Ada.Iterator_Interfaces (Cursor, Has_Element);
70
71    function "=" (Left, Right : Map) return Boolean;
72
73    function Length (Container : Map) return Count_Type;
74
75    function Is_Empty (Container : Map) return Boolean;
76
77    procedure Clear (Container : in out Map);
78
79    function Key (Position : Cursor) return Key_Type;
80
81    function Element (Position : Cursor) return Element_Type;
82
83    procedure Replace_Element
84      (Container : in out Map;
85       Position  : Cursor;
86       New_Item  : Element_Type);
87
88    procedure Query_Element
89      (Position : Cursor;
90       Process  : not null access procedure (Key     : Key_Type;
91                                             Element : Element_Type));
92
93    procedure Update_Element
94      (Container : in out Map;
95       Position  : Cursor;
96       Process   : not null access procedure (Key     : Key_Type;
97                                              Element : in out Element_Type));
98
99    procedure Assign (Target : in out Map; Source : Map);
100
101    function Copy (Source : Map) return Map;
102
103    procedure Move (Target : in out Map; Source : in out Map);
104
105    procedure Insert
106      (Container : in out Map;
107       Key       : Key_Type;
108       New_Item  : Element_Type;
109       Position  : out Cursor;
110       Inserted  : out Boolean);
111
112    procedure Insert
113      (Container : in out Map;
114       Key       : Key_Type;
115       New_Item  : Element_Type);
116
117    procedure Include
118      (Container : in out Map;
119       Key       : Key_Type;
120       New_Item  : Element_Type);
121
122    procedure Replace
123      (Container : in out Map;
124       Key       : Key_Type;
125       New_Item  : Element_Type);
126
127    procedure Exclude (Container : in out Map; Key : Key_Type);
128
129    procedure Delete (Container : in out Map; Key : Key_Type);
130
131    procedure Delete (Container : in out Map; Position : in out Cursor);
132
133    procedure Delete_First (Container : in out Map);
134
135    procedure Delete_Last (Container : in out Map);
136
137    function First (Container : Map) return Cursor;
138
139    function First_Element (Container : Map) return Element_Type;
140
141    function First_Key (Container : Map) return Key_Type;
142
143    function Last (Container : Map) return Cursor;
144
145    function Last_Element (Container : Map) return Element_Type;
146
147    function Last_Key (Container : Map) return Key_Type;
148
149    function Next (Position : Cursor) return Cursor;
150
151    procedure Next (Position : in out Cursor);
152
153    function Previous (Position : Cursor) return Cursor;
154
155    procedure Previous (Position : in out Cursor);
156
157    function Find (Container : Map; Key : Key_Type) return Cursor;
158
159    function Element (Container : Map; Key : Key_Type) return Element_Type;
160
161    function Floor (Container : Map; Key : Key_Type) return Cursor;
162
163    function Ceiling (Container : Map; Key : Key_Type) return Cursor;
164
165    function Contains (Container : Map; Key : Key_Type) return Boolean;
166
167    function "<" (Left, Right : Cursor) return Boolean;
168
169    function ">" (Left, Right : Cursor) return Boolean;
170
171    function "<" (Left : Cursor; Right : Key_Type) return Boolean;
172
173    function ">" (Left : Cursor; Right : Key_Type) return Boolean;
174
175    function "<" (Left : Key_Type; Right : Cursor) return Boolean;
176
177    function ">" (Left : Key_Type; Right : Cursor) return Boolean;
178
179    type Constant_Reference_Type
180       (Element : not null access constant Element_Type) is private
181    with
182       Implicit_Dereference => Element;
183
184    type Reference_Type (Element : not null access Element_Type) is private
185    with
186       Implicit_Dereference => Element;
187
188    function Constant_Reference
189      (Container : Map;
190       Key       : Key_Type) return Constant_Reference_Type;
191
192    function Reference
193      (Container : Map;
194        Key      : Key_Type) return Reference_Type;
195
196    procedure Iterate
197      (Container : Map;
198       Process   : not null access procedure (Position : Cursor));
199
200    procedure Reverse_Iterate
201      (Container : Map;
202       Process   : not null access procedure (Position : Cursor));
203
204    function Iterate
205      (Container : Map)
206       return Map_Iterator_Interfaces.Forward_Iterator'class;
207
208    function Iterate
209      (Container : Map;
210       Start     : Cursor)
211       return Map_Iterator_Interfaces.Reversible_Iterator'class;
212
213 private
214
215    pragma Inline (Next);
216    pragma Inline (Previous);
217
218    type Node_Type;
219    type Node_Access is access Node_Type;
220
221    type Key_Access is access Key_Type;
222    type Element_Access is access Element_Type;
223
224    type Node_Type is limited record
225       Parent  : Node_Access;
226       Left    : Node_Access;
227       Right   : Node_Access;
228       Color   : Red_Black_Trees.Color_Type := Red_Black_Trees.Red;
229       Key     : Key_Access;
230       Element : Element_Access;
231    end record;
232
233    package Tree_Types is new Red_Black_Trees.Generic_Tree_Types
234      (Node_Type,
235       Node_Access);
236
237    type Map is new Ada.Finalization.Controlled with record
238       Tree : Tree_Types.Tree_Type;
239    end record;
240
241    overriding procedure Adjust (Container : in out Map);
242
243    overriding procedure Finalize (Container : in out Map) renames Clear;
244
245    use Red_Black_Trees;
246    use Tree_Types;
247    use Ada.Finalization;
248    use Ada.Streams;
249
250    type Map_Access is access all Map;
251    for Map_Access'Storage_Size use 0;
252
253    type Cursor is record
254       Container : Map_Access;
255       Node      : Node_Access;
256    end record;
257
258    procedure Write
259      (Stream : not null access Root_Stream_Type'Class;
260       Item   : Cursor);
261
262    for Cursor'Write use Write;
263
264    procedure Read
265      (Stream : not null access Root_Stream_Type'Class;
266       Item   : out Cursor);
267
268    for Cursor'Read use Read;
269
270    No_Element : constant Cursor := Cursor'(null, null);
271
272    procedure Write
273      (Stream    : not null access Root_Stream_Type'Class;
274       Container : Map);
275
276    for Map'Write use Write;
277
278    procedure Read
279      (Stream    : not null access Root_Stream_Type'Class;
280       Container : out Map);
281
282    for Map'Read use Read;
283
284    type Constant_Reference_Type
285       (Element : not null access constant Element_Type) is null record;
286
287    procedure Read
288      (Stream : not null access Root_Stream_Type'Class;
289       Item   : out Constant_Reference_Type);
290
291    for Constant_Reference_Type'Read use Read;
292
293    procedure Write
294      (Stream : not null access Root_Stream_Type'Class;
295       Item   : Constant_Reference_Type);
296
297    for Constant_Reference_Type'Write use Write;
298
299    type Reference_Type
300       (Element : not null access Element_Type) is null record;
301
302    procedure Read
303      (Stream : not null access Root_Stream_Type'Class;
304       Item   : out Reference_Type);
305
306    for Reference_Type'Read use Read;
307
308    procedure Write
309      (Stream : not null access Root_Stream_Type'Class;
310       Item   : Reference_Type);
311
312    for Reference_Type'Write use Write;
313
314    Empty_Map : constant Map :=
315                  (Controlled with Tree => (First  => null,
316                                            Last   => null,
317                                            Root   => null,
318                                            Length => 0,
319                                            Busy   => 0,
320                                            Lock   => 0));
321
322 end Ada.Containers.Indefinite_Ordered_Maps;