* config/rs6000/rs6000.c (rs6000_option_override_internal): Do not
[official-gcc.git] / gcc / ada / a-cobove.ads
blob932aafb886b9052f69af802584a25a2b56fc7de4
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 _ V E C T O R 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.Streams;
38 generic
39 type Index_Type is range <>;
40 type Element_Type is private;
42 with function "=" (Left, Right : Element_Type) return Boolean is <>;
44 package Ada.Containers.Bounded_Vectors is
45 pragma Pure;
46 pragma Remote_Types;
48 subtype Extended_Index is Index_Type'Base
49 range Index_Type'First - 1 ..
50 Index_Type'Min (Index_Type'Base'Last - 1, Index_Type'Last) + 1;
52 No_Index : constant Extended_Index := Extended_Index'First;
54 type Vector (Capacity : Count_Type) is tagged private with
55 Constant_Indexing => Constant_Reference,
56 Variable_Indexing => Reference,
57 Default_Iterator => Iterate,
58 Iterator_Element => Element_Type;
60 pragma Preelaborable_Initialization (Vector);
62 type Cursor is private;
63 pragma Preelaborable_Initialization (Cursor);
65 Empty_Vector : constant Vector;
67 No_Element : constant Cursor;
69 function Has_Element (Position : Cursor) return Boolean;
71 package Vector_Iterator_Interfaces is new
72 Ada.Iterator_Interfaces (Cursor, Has_Element);
74 overriding function "=" (Left, Right : Vector) return Boolean;
76 function To_Vector (Length : Count_Type) return Vector;
78 function To_Vector
79 (New_Item : Element_Type;
80 Length : Count_Type) return Vector;
82 function "&" (Left, Right : Vector) return Vector;
84 function "&" (Left : Vector; Right : Element_Type) return Vector;
86 function "&" (Left : Element_Type; Right : Vector) return Vector;
88 function "&" (Left, Right : Element_Type) return Vector;
90 function Capacity (Container : Vector) return Count_Type;
92 procedure Reserve_Capacity
93 (Container : in out Vector;
94 Capacity : Count_Type);
96 function Length (Container : Vector) return Count_Type;
98 procedure Set_Length
99 (Container : in out Vector;
100 Length : Count_Type);
102 function Is_Empty (Container : Vector) return Boolean;
104 procedure Clear (Container : in out Vector);
106 function To_Cursor
107 (Container : Vector;
108 Index : Extended_Index) return Cursor;
110 function To_Index (Position : Cursor) return Extended_Index;
112 function Element
113 (Container : Vector;
114 Index : Index_Type) return Element_Type;
116 function Element (Position : Cursor) return Element_Type;
118 procedure Replace_Element
119 (Container : in out Vector;
120 Index : Index_Type;
121 New_Item : Element_Type);
123 procedure Replace_Element
124 (Container : in out Vector;
125 Position : Cursor;
126 New_Item : Element_Type);
128 procedure Query_Element
129 (Container : Vector;
130 Index : Index_Type;
131 Process : not null access procedure (Element : Element_Type));
133 procedure Query_Element
134 (Position : Cursor;
135 Process : not null access procedure (Element : Element_Type));
137 procedure Update_Element
138 (Container : in out Vector;
139 Index : Index_Type;
140 Process : not null access procedure (Element : in out Element_Type));
142 procedure Update_Element
143 (Container : in out Vector;
144 Position : Cursor;
145 Process : not null access procedure (Element : in out Element_Type));
147 type Constant_Reference_Type
148 (Element : not null access constant Element_Type) is
149 private
150 with
151 Implicit_Dereference => Element;
153 type Reference_Type (Element : not null access Element_Type) is private
154 with
155 Implicit_Dereference => Element;
157 function Constant_Reference
158 (Container : aliased Vector;
159 Position : Cursor) return Constant_Reference_Type;
161 function Reference
162 (Container : aliased in out Vector;
163 Position : Cursor) return Reference_Type;
165 function Constant_Reference
166 (Container : aliased Vector;
167 Index : Index_Type) return Constant_Reference_Type;
169 function Reference
170 (Container : aliased in out Vector;
171 Index : Index_Type) return Reference_Type;
173 procedure Assign (Target : in out Vector; Source : Vector);
175 function Copy (Source : Vector; Capacity : Count_Type := 0) return Vector;
177 procedure Move (Target : in out Vector; Source : in out Vector);
179 procedure Insert
180 (Container : in out Vector;
181 Before : Extended_Index;
182 New_Item : Vector);
184 procedure Insert
185 (Container : in out Vector;
186 Before : Cursor;
187 New_Item : Vector);
189 procedure Insert
190 (Container : in out Vector;
191 Before : Cursor;
192 New_Item : Vector;
193 Position : out Cursor);
195 procedure Insert
196 (Container : in out Vector;
197 Before : Extended_Index;
198 New_Item : Element_Type;
199 Count : Count_Type := 1);
201 procedure Insert
202 (Container : in out Vector;
203 Before : Cursor;
204 New_Item : Element_Type;
205 Count : Count_Type := 1);
207 procedure Insert
208 (Container : in out Vector;
209 Before : Cursor;
210 New_Item : Element_Type;
211 Position : out Cursor;
212 Count : Count_Type := 1);
214 procedure Insert
215 (Container : in out Vector;
216 Before : Extended_Index;
217 Count : Count_Type := 1);
219 procedure Insert
220 (Container : in out Vector;
221 Before : Cursor;
222 Position : out Cursor;
223 Count : Count_Type := 1);
225 procedure Prepend
226 (Container : in out Vector;
227 New_Item : Vector);
229 procedure Prepend
230 (Container : in out Vector;
231 New_Item : Element_Type;
232 Count : Count_Type := 1);
234 procedure Append
235 (Container : in out Vector;
236 New_Item : Vector);
238 procedure Append
239 (Container : in out Vector;
240 New_Item : Element_Type;
241 Count : Count_Type := 1);
243 procedure Insert_Space
244 (Container : in out Vector;
245 Before : Extended_Index;
246 Count : Count_Type := 1);
248 procedure Insert_Space
249 (Container : in out Vector;
250 Before : Cursor;
251 Position : out Cursor;
252 Count : Count_Type := 1);
254 procedure Delete
255 (Container : in out Vector;
256 Index : Extended_Index;
257 Count : Count_Type := 1);
259 procedure Delete
260 (Container : in out Vector;
261 Position : in out Cursor;
262 Count : Count_Type := 1);
264 procedure Delete_First
265 (Container : in out Vector;
266 Count : Count_Type := 1);
268 procedure Delete_Last
269 (Container : in out Vector;
270 Count : Count_Type := 1);
272 procedure Reverse_Elements (Container : in out Vector);
274 procedure Swap (Container : in out Vector; I, J : Index_Type);
276 procedure Swap (Container : in out Vector; I, J : Cursor);
278 function First_Index (Container : Vector) return Index_Type;
280 function First (Container : Vector) return Cursor;
282 function First_Element (Container : Vector) return Element_Type;
284 function Last_Index (Container : Vector) return Extended_Index;
286 function Last (Container : Vector) return Cursor;
288 function Last_Element (Container : Vector) return Element_Type;
290 function Next (Position : Cursor) return Cursor;
292 procedure Next (Position : in out Cursor);
294 function Previous (Position : Cursor) return Cursor;
296 procedure Previous (Position : in out Cursor);
298 function Find_Index
299 (Container : Vector;
300 Item : Element_Type;
301 Index : Index_Type := Index_Type'First) return Extended_Index;
303 function Find
304 (Container : Vector;
305 Item : Element_Type;
306 Position : Cursor := No_Element) return Cursor;
308 function Reverse_Find_Index
309 (Container : Vector;
310 Item : Element_Type;
311 Index : Index_Type := Index_Type'Last) return Extended_Index;
313 function Reverse_Find
314 (Container : Vector;
315 Item : Element_Type;
316 Position : Cursor := No_Element) return Cursor;
318 function Contains
319 (Container : Vector;
320 Item : Element_Type) return Boolean;
322 procedure Iterate
323 (Container : Vector;
324 Process : not null access procedure (Position : Cursor));
326 procedure Reverse_Iterate
327 (Container : Vector;
328 Process : not null access procedure (Position : Cursor));
330 function Iterate
331 (Container : Vector)
332 return Vector_Iterator_Interfaces.Reversible_Iterator'Class;
334 function Iterate
335 (Container : Vector;
336 Start : Cursor)
337 return Vector_Iterator_Interfaces.Reversible_Iterator'class;
339 generic
340 with function "<" (Left, Right : Element_Type) return Boolean is <>;
341 package Generic_Sorting is
343 function Is_Sorted (Container : Vector) return Boolean;
345 procedure Sort (Container : in out Vector);
347 procedure Merge (Target : in out Vector; Source : in out Vector);
349 end Generic_Sorting;
351 private
353 pragma Inline (First_Index);
354 pragma Inline (Last_Index);
355 pragma Inline (Element);
356 pragma Inline (First_Element);
357 pragma Inline (Last_Element);
358 pragma Inline (Query_Element);
359 pragma Inline (Update_Element);
360 pragma Inline (Replace_Element);
361 pragma Inline (Is_Empty);
362 pragma Inline (Contains);
363 pragma Inline (Next);
364 pragma Inline (Previous);
366 use Ada.Streams;
368 type Elements_Array is array (Count_Type range <>) of aliased Element_Type;
369 function "=" (L, R : Elements_Array) return Boolean is abstract;
371 type Vector (Capacity : Count_Type) is tagged record
372 Elements : Elements_Array (1 .. Capacity) := (others => <>);
373 Last : Extended_Index := No_Index;
374 Busy : Natural := 0;
375 Lock : Natural := 0;
376 end record;
378 procedure Write
379 (Stream : not null access Root_Stream_Type'Class;
380 Container : Vector);
382 for Vector'Write use Write;
384 procedure Read
385 (Stream : not null access Root_Stream_Type'Class;
386 Container : out Vector);
388 for Vector'Read use Read;
390 type Vector_Access is access all Vector;
391 for Vector_Access'Storage_Size use 0;
393 type Cursor is record
394 Container : Vector_Access;
395 Index : Index_Type := Index_Type'First;
396 end record;
398 procedure Write
399 (Stream : not null access Root_Stream_Type'Class;
400 Position : Cursor);
402 for Cursor'Write use Write;
404 procedure Read
405 (Stream : not null access Root_Stream_Type'Class;
406 Position : out Cursor);
408 for Cursor'Read use Read;
410 type Constant_Reference_Type
411 (Element : not null access constant Element_Type) is null record;
413 procedure Read
414 (Stream : not null access Root_Stream_Type'Class;
415 Item : out Constant_Reference_Type);
417 for Constant_Reference_Type'Read use Read;
419 procedure Write
420 (Stream : not null access Root_Stream_Type'Class;
421 Item : Constant_Reference_Type);
423 for Constant_Reference_Type'Write use Write;
425 type Reference_Type
426 (Element : not null access Element_Type) is null record;
428 procedure Read
429 (Stream : not null access Root_Stream_Type'Class;
430 Item : out Reference_Type);
432 for Reference_Type'Read use Read;
434 procedure Write
435 (Stream : not null access Root_Stream_Type'Class;
436 Item : Reference_Type);
438 for Reference_Type'Write use Write;
440 Empty_Vector : constant Vector := (Capacity => 0, others => <>);
442 No_Element : constant Cursor := Cursor'(null, Index_Type'First);
444 end Ada.Containers.Bounded_Vectors;