* libgfortran.h (support_fpu_underflow_control,
[official-gcc.git] / gcc / ada / a-coinve.ads
blob2c841671af422c5a6aa2956db63a9ec6f4f821bc
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT LIBRARY COMPONENTS --
4 -- --
5 -- A D A . C O N T A I N E R S . I N D E F I N I T E _ V E C T O R S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2004-2013, 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.Finalization;
37 private with Ada.Streams;
39 generic
40 type Index_Type is range <>;
41 type Element_Type (<>) is private;
43 with function "=" (Left, Right : Element_Type) return Boolean is <>;
45 package Ada.Containers.Indefinite_Vectors is
46 pragma Preelaborate;
47 pragma Remote_Types;
49 subtype Extended_Index is Index_Type'Base
50 range Index_Type'First - 1 ..
51 Index_Type'Min (Index_Type'Base'Last - 1, Index_Type'Last) + 1;
53 No_Index : constant Extended_Index := Extended_Index'First;
55 type Vector is tagged private
56 with
57 Constant_Indexing => Constant_Reference,
58 Variable_Indexing => Reference,
59 Default_Iterator => Iterate,
60 Iterator_Element => Element_Type;
62 pragma Preelaborable_Initialization (Vector);
64 type Cursor is private;
65 pragma Preelaborable_Initialization (Cursor);
67 Empty_Vector : constant Vector;
69 No_Element : constant Cursor;
71 function Has_Element (Position : Cursor) return Boolean;
73 package Vector_Iterator_Interfaces is new
74 Ada.Iterator_Interfaces (Cursor, Has_Element);
76 overriding function "=" (Left, Right : Vector) return Boolean;
78 function To_Vector (Length : Count_Type) return Vector;
80 function To_Vector
81 (New_Item : Element_Type;
82 Length : Count_Type) return Vector;
84 function "&" (Left, Right : Vector) return Vector;
86 function "&" (Left : Vector; Right : Element_Type) return Vector;
88 function "&" (Left : Element_Type; Right : Vector) return Vector;
90 function "&" (Left, Right : Element_Type) return Vector;
92 function Capacity (Container : Vector) return Count_Type;
94 procedure Reserve_Capacity
95 (Container : in out Vector;
96 Capacity : Count_Type);
98 function Length (Container : Vector) return Count_Type;
100 procedure Set_Length
101 (Container : in out Vector;
102 Length : Count_Type);
104 function Is_Empty (Container : Vector) return Boolean;
106 procedure Clear (Container : in out Vector);
108 type Constant_Reference_Type
109 (Element : not null access constant Element_Type) is private
110 with
111 Implicit_Dereference => Element;
113 type Reference_Type (Element : not null access Element_Type) is private
114 with
115 Implicit_Dereference => Element;
117 function Constant_Reference
118 (Container : aliased Vector;
119 Position : Cursor) return Constant_Reference_Type;
120 pragma Inline (Constant_Reference);
122 function Reference
123 (Container : aliased in out Vector;
124 Position : Cursor) return Reference_Type;
125 pragma Inline (Reference);
127 function Constant_Reference
128 (Container : aliased Vector;
129 Index : Index_Type) return Constant_Reference_Type;
130 pragma Inline (Constant_Reference);
132 function Reference
133 (Container : aliased in out Vector;
134 Index : Index_Type) return Reference_Type;
135 pragma Inline (Reference);
137 function To_Cursor
138 (Container : Vector;
139 Index : Extended_Index) return Cursor;
141 function To_Index (Position : Cursor) return Extended_Index;
143 function Element
144 (Container : Vector;
145 Index : Index_Type) return Element_Type;
147 function Element (Position : Cursor) return Element_Type;
149 procedure Replace_Element
150 (Container : in out Vector;
151 Index : Index_Type;
152 New_Item : Element_Type);
154 procedure Replace_Element
155 (Container : in out Vector;
156 Position : Cursor;
157 New_Item : Element_Type);
159 procedure Query_Element
160 (Container : Vector;
161 Index : Index_Type;
162 Process : not null access procedure (Element : Element_Type));
164 procedure Query_Element
165 (Position : Cursor;
166 Process : not null access procedure (Element : Element_Type));
168 procedure Update_Element
169 (Container : in out Vector;
170 Index : Index_Type;
171 Process : not null access procedure (Element : in out Element_Type));
173 procedure Update_Element
174 (Container : in out Vector;
175 Position : Cursor;
176 Process : not null access procedure (Element : in out Element_Type));
178 procedure Assign (Target : in out Vector; Source : Vector);
180 function Copy (Source : Vector; Capacity : Count_Type := 0) return Vector;
182 procedure Move (Target : in out Vector; Source : in out Vector);
184 procedure Insert
185 (Container : in out Vector;
186 Before : Extended_Index;
187 New_Item : Vector);
189 procedure Insert
190 (Container : in out Vector;
191 Before : Cursor;
192 New_Item : Vector);
194 procedure Insert
195 (Container : in out Vector;
196 Before : Cursor;
197 New_Item : Vector;
198 Position : out Cursor);
200 procedure Insert
201 (Container : in out Vector;
202 Before : Extended_Index;
203 New_Item : Element_Type;
204 Count : Count_Type := 1);
206 procedure Insert
207 (Container : in out Vector;
208 Before : Cursor;
209 New_Item : Element_Type;
210 Count : Count_Type := 1);
212 procedure Insert
213 (Container : in out Vector;
214 Before : Cursor;
215 New_Item : Element_Type;
216 Position : out Cursor;
217 Count : Count_Type := 1);
219 procedure Prepend
220 (Container : in out Vector;
221 New_Item : Vector);
223 procedure Prepend
224 (Container : in out Vector;
225 New_Item : Element_Type;
226 Count : Count_Type := 1);
228 procedure Append
229 (Container : in out Vector;
230 New_Item : Vector);
232 procedure Append
233 (Container : in out Vector;
234 New_Item : Element_Type;
235 Count : Count_Type := 1);
237 procedure Insert_Space
238 (Container : in out Vector;
239 Before : Extended_Index;
240 Count : Count_Type := 1);
242 procedure Insert_Space
243 (Container : in out Vector;
244 Before : Cursor;
245 Position : out Cursor;
246 Count : Count_Type := 1);
248 procedure Delete
249 (Container : in out Vector;
250 Index : Extended_Index;
251 Count : Count_Type := 1);
253 procedure Delete
254 (Container : in out Vector;
255 Position : in out Cursor;
256 Count : Count_Type := 1);
258 procedure Delete_First
259 (Container : in out Vector;
260 Count : Count_Type := 1);
262 procedure Delete_Last
263 (Container : in out Vector;
264 Count : Count_Type := 1);
266 procedure Reverse_Elements (Container : in out Vector);
268 procedure Swap (Container : in out Vector; I, J : Index_Type);
270 procedure Swap (Container : in out Vector; I, J : Cursor);
272 function First_Index (Container : Vector) return Index_Type;
274 function First (Container : Vector) return Cursor;
276 function First_Element (Container : Vector) return Element_Type;
278 function Last_Index (Container : Vector) return Extended_Index;
280 function Last (Container : Vector) return Cursor;
282 function Last_Element (Container : Vector) return Element_Type;
284 function Next (Position : Cursor) return Cursor;
286 procedure Next (Position : in out Cursor);
288 function Previous (Position : Cursor) return Cursor;
290 procedure Previous (Position : in out Cursor);
292 function Find_Index
293 (Container : Vector;
294 Item : Element_Type;
295 Index : Index_Type := Index_Type'First) return Extended_Index;
297 function Find
298 (Container : Vector;
299 Item : Element_Type;
300 Position : Cursor := No_Element) return Cursor;
302 function Reverse_Find_Index
303 (Container : Vector;
304 Item : Element_Type;
305 Index : Index_Type := Index_Type'Last) return Extended_Index;
307 function Reverse_Find
308 (Container : Vector;
309 Item : Element_Type;
310 Position : Cursor := No_Element) return Cursor;
312 function Contains
313 (Container : Vector;
314 Item : Element_Type) return Boolean;
316 procedure Iterate
317 (Container : Vector;
318 Process : not null access procedure (Position : Cursor));
320 function Iterate (Container : Vector)
321 return Vector_Iterator_Interfaces.Reversible_Iterator'class;
323 function Iterate
324 (Container : Vector;
325 Start : Cursor)
326 return Vector_Iterator_Interfaces.Reversible_Iterator'class;
328 procedure Reverse_Iterate
329 (Container : Vector;
330 Process : not null access procedure (Position : Cursor));
332 generic
333 with function "<" (Left, Right : Element_Type) return Boolean is <>;
334 package Generic_Sorting is
336 function Is_Sorted (Container : Vector) return Boolean;
338 procedure Sort (Container : in out Vector);
340 procedure Merge (Target : in out Vector; Source : in out Vector);
342 end Generic_Sorting;
344 private
346 pragma Inline (First_Index);
347 pragma Inline (Last_Index);
348 pragma Inline (Element);
349 pragma Inline (First_Element);
350 pragma Inline (Last_Element);
351 pragma Inline (Query_Element);
352 pragma Inline (Update_Element);
353 pragma Inline (Replace_Element);
354 pragma Inline (Contains);
355 pragma Inline (Next);
356 pragma Inline (Previous);
358 type Element_Access is access Element_Type;
360 type Elements_Array is array (Index_Type range <>) of Element_Access;
361 function "=" (L, R : Elements_Array) return Boolean is abstract;
363 type Elements_Type (Last : Index_Type) is limited record
364 EA : Elements_Array (Index_Type'First .. Last);
365 end record;
367 type Elements_Access is access Elements_Type;
369 type Vector is new Ada.Finalization.Controlled with record
370 Elements : Elements_Access;
371 Last : Extended_Index := No_Index;
372 Busy : Natural := 0;
373 Lock : Natural := 0;
374 end record;
376 overriding procedure Adjust (Container : in out Vector);
378 overriding procedure Finalize (Container : in out Vector);
380 use Ada.Finalization;
381 use Ada.Streams;
383 procedure Write
384 (Stream : not null access Root_Stream_Type'Class;
385 Container : Vector);
387 for Vector'Write use Write;
389 procedure Read
390 (Stream : not null access Root_Stream_Type'Class;
391 Container : out Vector);
393 for Vector'Read use Read;
395 type Vector_Access is access all Vector;
396 for Vector_Access'Storage_Size use 0;
398 type Cursor is record
399 Container : Vector_Access;
400 Index : Index_Type := Index_Type'First;
401 end record;
403 procedure Read
404 (Stream : not null access Root_Stream_Type'Class;
405 Position : out Cursor);
407 for Cursor'Read use Read;
409 procedure Write
410 (Stream : not null access Root_Stream_Type'Class;
411 Position : Cursor);
413 for Cursor'Write use Write;
415 type Reference_Control_Type is
416 new Controlled with record
417 Container : Vector_Access;
418 end record;
420 overriding procedure Adjust (Control : in out Reference_Control_Type);
421 pragma Inline (Adjust);
423 overriding procedure Finalize (Control : in out Reference_Control_Type);
424 pragma Inline (Finalize);
426 type Constant_Reference_Type
427 (Element : not null access constant Element_Type) is
428 record
429 Control : Reference_Control_Type;
430 end record;
432 procedure Write
433 (Stream : not null access Root_Stream_Type'Class;
434 Item : Constant_Reference_Type);
436 for Constant_Reference_Type'Write use Write;
438 procedure Read
439 (Stream : not null access Root_Stream_Type'Class;
440 Item : out Constant_Reference_Type);
442 for Constant_Reference_Type'Read use Read;
444 type Reference_Type
445 (Element : not null access Element_Type) is
446 record
447 Control : Reference_Control_Type;
448 end record;
450 procedure Write
451 (Stream : not null access Root_Stream_Type'Class;
452 Item : Reference_Type);
454 for Reference_Type'Write use Write;
456 procedure Read
457 (Stream : not null access Root_Stream_Type'Class;
458 Item : out Reference_Type);
460 for Reference_Type'Read use Read;
462 Empty_Vector : constant Vector := (Controlled with null, No_Index, 0, 0);
464 No_Element : constant Cursor := Cursor'(null, Index_Type'First);
466 type Iterator is new Limited_Controlled and
467 Vector_Iterator_Interfaces.Reversible_Iterator with
468 record
469 Container : Vector_Access;
470 Index : Index_Type'Base;
471 end record;
473 overriding procedure Finalize (Object : in out Iterator);
475 overriding function First (Object : Iterator) return Cursor;
476 overriding function Last (Object : Iterator) return Cursor;
478 overriding function Next
479 (Object : Iterator;
480 Position : Cursor) return Cursor;
482 overriding function Previous
483 (Object : Iterator;
484 Position : Cursor) return Cursor;
486 end Ada.Containers.Indefinite_Vectors;