* g++.dg/cpp0x/constexpr-53094-2.C: Ignore non-standard ABI
[official-gcc.git] / gcc / ada / a-cborma.ads
blob6ade3e6c4749ff0d82631265e5b118043a04fa2b
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-2012, 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 ------------------------------------------------------------------------------
34 with Ada.Iterator_Interfaces;
36 private with Ada.Containers.Red_Black_Trees;
37 private with Ada.Streams;
39 generic
40 type Key_Type is private;
41 type Element_Type is private;
43 with function "<" (Left, Right : Key_Type) return Boolean is <>;
44 with function "=" (Left, Right : Element_Type) return Boolean is <>;
46 package Ada.Containers.Bounded_Ordered_Maps is
47 pragma Pure;
48 pragma Remote_Types;
50 function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
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;
58 pragma Preelaborable_Initialization (Map);
60 type Cursor is private;
61 pragma Preelaborable_Initialization (Cursor);
63 Empty_Map : constant Map;
65 No_Element : constant Cursor;
67 function Has_Element (Position : Cursor) return Boolean;
69 package Map_Iterator_Interfaces is new
70 Ada.Iterator_Interfaces (Cursor, Has_Element);
72 function "=" (Left, Right : Map) return Boolean;
74 function Length (Container : Map) return Count_Type;
76 function Is_Empty (Container : Map) return Boolean;
78 procedure Clear (Container : in out Map);
80 function Key (Position : Cursor) return Key_Type;
82 function Element (Position : Cursor) return Element_Type;
84 procedure Replace_Element
85 (Container : in out Map;
86 Position : Cursor;
87 New_Item : Element_Type);
89 procedure Query_Element
90 (Position : Cursor;
91 Process : not null access
92 procedure (Key : Key_Type; Element : Element_Type));
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));
100 type Constant_Reference_Type
101 (Element : not null access constant Element_Type) is private
102 with
103 Implicit_Dereference => Element;
105 type Reference_Type (Element : not null access Element_Type) is private
106 with
107 Implicit_Dereference => Element;
109 function Constant_Reference
110 (Container : aliased Map;
111 Position : Cursor) return Constant_Reference_Type;
113 function Reference
114 (Container : aliased in out Map;
115 Position : Cursor) return Reference_Type;
117 function Constant_Reference
118 (Container : aliased Map;
119 Key : Key_Type) return Constant_Reference_Type;
121 function Reference
122 (Container : aliased in out Map;
123 Key : Key_Type) return Reference_Type;
125 procedure Assign (Target : in out Map; Source : Map);
127 function Copy (Source : Map; Capacity : Count_Type := 0) return Map;
129 procedure Move (Target : in out Map; Source : in out Map);
131 procedure Insert
132 (Container : in out Map;
133 Key : Key_Type;
134 New_Item : Element_Type;
135 Position : out Cursor;
136 Inserted : out Boolean);
138 procedure Insert
139 (Container : in out Map;
140 Key : Key_Type;
141 Position : out Cursor;
142 Inserted : out Boolean);
144 procedure Insert
145 (Container : in out Map;
146 Key : Key_Type;
147 New_Item : Element_Type);
149 procedure Include
150 (Container : in out Map;
151 Key : Key_Type;
152 New_Item : Element_Type);
154 procedure Replace
155 (Container : in out Map;
156 Key : Key_Type;
157 New_Item : Element_Type);
159 procedure Exclude (Container : in out Map; Key : Key_Type);
161 procedure Delete (Container : in out Map; Key : Key_Type);
163 procedure Delete (Container : in out Map; Position : in out Cursor);
165 procedure Delete_First (Container : in out Map);
167 procedure Delete_Last (Container : in out Map);
169 function First (Container : Map) return Cursor;
171 function First_Element (Container : Map) return Element_Type;
173 function First_Key (Container : Map) return Key_Type;
175 function Last (Container : Map) return Cursor;
177 function Last_Element (Container : Map) return Element_Type;
179 function Last_Key (Container : Map) return Key_Type;
181 function Next (Position : Cursor) return Cursor;
183 procedure Next (Position : in out Cursor);
185 function Previous (Position : Cursor) return Cursor;
187 procedure Previous (Position : in out Cursor);
189 function Find (Container : Map; Key : Key_Type) return Cursor;
191 function Element (Container : Map; Key : Key_Type) return Element_Type;
193 function Floor (Container : Map; Key : Key_Type) return Cursor;
195 function Ceiling (Container : Map; Key : Key_Type) return Cursor;
197 function Contains (Container : Map; Key : Key_Type) return Boolean;
199 function "<" (Left, Right : Cursor) return Boolean;
201 function ">" (Left, Right : Cursor) return Boolean;
203 function "<" (Left : Cursor; Right : Key_Type) return Boolean;
205 function ">" (Left : Cursor; Right : Key_Type) return Boolean;
207 function "<" (Left : Key_Type; Right : Cursor) return Boolean;
209 function ">" (Left : Key_Type; Right : Cursor) return Boolean;
211 procedure Iterate
212 (Container : Map;
213 Process : not null access procedure (Position : Cursor));
215 procedure Reverse_Iterate
216 (Container : Map;
217 Process : not null access procedure (Position : Cursor));
219 function Iterate
220 (Container : Map)
221 return Map_Iterator_Interfaces.Reversible_Iterator'Class;
223 function Iterate
224 (Container : Map;
225 Start : Cursor)
226 return Map_Iterator_Interfaces.Reversible_Iterator'Class;
228 private
230 pragma Inline (Next);
231 pragma Inline (Previous);
233 type Node_Type is record
234 Parent : Count_Type;
235 Left : Count_Type;
236 Right : Count_Type;
237 Color : Red_Black_Trees.Color_Type := Red_Black_Trees.Red;
238 Key : Key_Type;
239 Element : aliased Element_Type;
240 end record;
242 package Tree_Types is
243 new Red_Black_Trees.Generic_Bounded_Tree_Types (Node_Type);
245 type Map (Capacity : Count_Type) is
246 new Tree_Types.Tree_Type (Capacity) with null record;
248 use Red_Black_Trees;
249 use Tree_Types;
250 use Ada.Streams;
252 procedure Write
253 (Stream : not null access Root_Stream_Type'Class;
254 Container : Map);
256 for Map'Write use Write;
258 procedure Read
259 (Stream : not null access Root_Stream_Type'Class;
260 Container : out Map);
262 for Map'Read use Read;
264 type Map_Access is access all Map;
265 for Map_Access'Storage_Size use 0;
267 type Cursor is record
268 Container : Map_Access;
269 Node : Count_Type := 0;
270 end record;
272 procedure Write
273 (Stream : not null access Root_Stream_Type'Class;
274 Item : Cursor);
276 for Cursor'Write use Write;
278 procedure Read
279 (Stream : not null access Root_Stream_Type'Class;
280 Item : out Cursor);
282 for Cursor'Read use Read;
284 type Constant_Reference_Type
285 (Element : not null access constant Element_Type) is null record;
287 procedure Read
288 (Stream : not null access Root_Stream_Type'Class;
289 Item : out Constant_Reference_Type);
291 for Constant_Reference_Type'Read use Read;
293 procedure Write
294 (Stream : not null access Root_Stream_Type'Class;
295 Item : Constant_Reference_Type);
297 for Constant_Reference_Type'Write use Write;
299 type Reference_Type
300 (Element : not null access Element_Type) is null record;
302 procedure Read
303 (Stream : not null access Root_Stream_Type'Class;
304 Item : out Reference_Type);
306 for Reference_Type'Read use Read;
308 procedure Write
309 (Stream : not null access Root_Stream_Type'Class;
310 Item : Reference_Type);
312 for Reference_Type'Write use Write;
314 Empty_Map : constant Map := Map'(Tree_Type with Capacity => 0);
316 No_Element : constant Cursor := Cursor'(null, 0);
318 end Ada.Containers.Bounded_Ordered_Maps;