* gcc.dg/compat/struct-layout-1_generate.c (dg_options): New. Moved
[official-gcc.git] / gcc / ada / a-coinve.ads
blob0026272d10523bff79582519106170df4a0645bc
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-2007, 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 2, 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. See the GNU General Public License --
21 -- for more details. You should have received a copy of the GNU General --
22 -- Public License distributed with GNAT; see file COPYING. If not, write --
23 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
24 -- Boston, MA 02110-1301, USA. --
25 -- --
26 -- As a special exception, if other files instantiate generics from this --
27 -- unit, or you link this unit with other files to produce an executable, --
28 -- this unit does not by itself cause the resulting executable to be --
29 -- covered by the GNU General Public License. This exception does not --
30 -- however invalidate any other reasons why the executable file might be --
31 -- covered by the GNU Public License. --
32 -- --
33 -- This unit was originally developed by Matthew J Heaney. --
34 ------------------------------------------------------------------------------
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 pragma Preelaborable_Initialization (Vector);
58 type Cursor is private;
59 pragma Preelaborable_Initialization (Cursor);
61 Empty_Vector : constant Vector;
63 No_Element : constant Cursor;
65 function "=" (Left, Right : Vector) return Boolean;
67 function To_Vector (Length : Count_Type) return Vector;
69 function To_Vector
70 (New_Item : Element_Type;
71 Length : Count_Type) return Vector;
73 function "&" (Left, Right : Vector) return Vector;
75 function "&" (Left : Vector; Right : Element_Type) return Vector;
77 function "&" (Left : Element_Type; Right : Vector) return Vector;
79 function "&" (Left, Right : Element_Type) return Vector;
81 function Capacity (Container : Vector) return Count_Type;
83 procedure Reserve_Capacity
84 (Container : in out Vector;
85 Capacity : Count_Type);
87 function Length (Container : Vector) return Count_Type;
89 procedure Set_Length
90 (Container : in out Vector;
91 Length : Count_Type);
93 function Is_Empty (Container : Vector) return Boolean;
95 procedure Clear (Container : in out Vector);
97 function To_Cursor
98 (Container : Vector;
99 Index : Extended_Index) return Cursor;
101 function To_Index (Position : Cursor) return Extended_Index;
103 function Element
104 (Container : Vector;
105 Index : Index_Type) return Element_Type;
107 function Element (Position : Cursor) return Element_Type;
109 procedure Replace_Element
110 (Container : in out Vector;
111 Index : Index_Type;
112 New_Item : Element_Type);
114 procedure Replace_Element
115 (Container : in out Vector;
116 Position : Cursor;
117 New_Item : Element_Type);
119 procedure Query_Element
120 (Container : Vector;
121 Index : Index_Type;
122 Process : not null access procedure (Element : Element_Type));
124 procedure Query_Element
125 (Position : Cursor;
126 Process : not null access procedure (Element : Element_Type));
128 procedure Update_Element
129 (Container : in out Vector;
130 Index : Index_Type;
131 Process : not null access procedure (Element : in out Element_Type));
133 procedure Update_Element
134 (Container : in out Vector;
135 Position : Cursor;
136 Process : not null access procedure (Element : in out Element_Type));
138 procedure Move (Target : in out Vector; Source : in out Vector);
140 procedure Insert
141 (Container : in out Vector;
142 Before : Extended_Index;
143 New_Item : Vector);
145 procedure Insert
146 (Container : in out Vector;
147 Before : Cursor;
148 New_Item : Vector);
150 procedure Insert
151 (Container : in out Vector;
152 Before : Cursor;
153 New_Item : Vector;
154 Position : out Cursor);
156 procedure Insert
157 (Container : in out Vector;
158 Before : Extended_Index;
159 New_Item : Element_Type;
160 Count : Count_Type := 1);
162 procedure Insert
163 (Container : in out Vector;
164 Before : Cursor;
165 New_Item : Element_Type;
166 Count : Count_Type := 1);
168 procedure Insert
169 (Container : in out Vector;
170 Before : Cursor;
171 New_Item : Element_Type;
172 Position : out Cursor;
173 Count : Count_Type := 1);
175 procedure Prepend
176 (Container : in out Vector;
177 New_Item : Vector);
179 procedure Prepend
180 (Container : in out Vector;
181 New_Item : Element_Type;
182 Count : Count_Type := 1);
184 procedure Append
185 (Container : in out Vector;
186 New_Item : Vector);
188 procedure Append
189 (Container : in out Vector;
190 New_Item : Element_Type;
191 Count : Count_Type := 1);
193 procedure Insert_Space
194 (Container : in out Vector;
195 Before : Extended_Index;
196 Count : Count_Type := 1);
198 procedure Insert_Space
199 (Container : in out Vector;
200 Before : Cursor;
201 Position : out Cursor;
202 Count : Count_Type := 1);
204 procedure Delete
205 (Container : in out Vector;
206 Index : Extended_Index;
207 Count : Count_Type := 1);
209 procedure Delete
210 (Container : in out Vector;
211 Position : in out Cursor;
212 Count : Count_Type := 1);
214 procedure Delete_First
215 (Container : in out Vector;
216 Count : Count_Type := 1);
218 procedure Delete_Last
219 (Container : in out Vector;
220 Count : Count_Type := 1);
222 procedure Reverse_Elements (Container : in out Vector);
224 procedure Swap (Container : in out Vector; I, J : Index_Type);
226 procedure Swap (Container : in out Vector; I, J : Cursor);
228 function First_Index (Container : Vector) return Index_Type;
230 function First (Container : Vector) return Cursor;
232 function First_Element (Container : Vector) return Element_Type;
234 function Last_Index (Container : Vector) return Extended_Index;
236 function Last (Container : Vector) return Cursor;
238 function Last_Element (Container : Vector) return Element_Type;
240 function Next (Position : Cursor) return Cursor;
242 procedure Next (Position : in out Cursor);
244 function Previous (Position : Cursor) return Cursor;
246 procedure Previous (Position : in out Cursor);
248 function Find_Index
249 (Container : Vector;
250 Item : Element_Type;
251 Index : Index_Type := Index_Type'First) return Extended_Index;
253 function Find
254 (Container : Vector;
255 Item : Element_Type;
256 Position : Cursor := No_Element) return Cursor;
258 function Reverse_Find_Index
259 (Container : Vector;
260 Item : Element_Type;
261 Index : Index_Type := Index_Type'Last) return Extended_Index;
263 function Reverse_Find
264 (Container : Vector;
265 Item : Element_Type;
266 Position : Cursor := No_Element) return Cursor;
268 function Contains
269 (Container : Vector;
270 Item : Element_Type) return Boolean;
272 function Has_Element (Position : Cursor) return Boolean;
274 procedure Iterate
275 (Container : Vector;
276 Process : not null access procedure (Position : Cursor));
278 procedure Reverse_Iterate
279 (Container : Vector;
280 Process : not null access procedure (Position : Cursor));
282 generic
283 with function "<" (Left, Right : Element_Type) return Boolean is <>;
284 package Generic_Sorting is
286 function Is_Sorted (Container : Vector) return Boolean;
288 procedure Sort (Container : in out Vector);
290 procedure Merge (Target : in out Vector; Source : in out Vector);
292 end Generic_Sorting;
294 private
296 pragma Inline (First_Index);
297 pragma Inline (Last_Index);
298 pragma Inline (Element);
299 pragma Inline (First_Element);
300 pragma Inline (Last_Element);
301 pragma Inline (Query_Element);
302 pragma Inline (Update_Element);
303 pragma Inline (Replace_Element);
304 pragma Inline (Contains);
305 pragma Inline (Next);
306 pragma Inline (Previous);
308 type Element_Access is access Element_Type;
310 type Elements_Array is array (Index_Type range <>) of Element_Access;
311 function "=" (L, R : Elements_Array) return Boolean is abstract;
313 type Elements_Type (Last : Index_Type) is limited record
314 EA : Elements_Array (Index_Type'First .. Last);
315 end record;
317 type Elements_Access is access Elements_Type;
319 use Ada.Finalization;
321 type Vector is new Controlled with record
322 Elements : Elements_Access;
323 Last : Extended_Index := No_Index;
324 Busy : Natural := 0;
325 Lock : Natural := 0;
326 end record;
328 overriding
329 procedure Adjust (Container : in out Vector);
331 overriding
332 procedure Finalize (Container : in out Vector);
334 use Ada.Streams;
336 procedure Write
337 (Stream : not null access Root_Stream_Type'Class;
338 Container : Vector);
340 for Vector'Write use Write;
342 procedure Read
343 (Stream : not null access Root_Stream_Type'Class;
344 Container : out Vector);
346 for Vector'Read use Read;
348 type Vector_Access is access constant Vector;
349 for Vector_Access'Storage_Size use 0;
351 type Cursor is record
352 Container : Vector_Access;
353 Index : Index_Type := Index_Type'First;
354 end record;
356 procedure Write
357 (Stream : not null access Root_Stream_Type'Class;
358 Position : Cursor);
360 for Cursor'Write use Write;
362 procedure Read
363 (Stream : not null access Root_Stream_Type'Class;
364 Position : out Cursor);
366 for Cursor'Read use Read;
368 Empty_Vector : constant Vector := (Controlled with null, No_Index, 0, 0);
370 No_Element : constant Cursor := Cursor'(null, Index_Type'First);
372 end Ada.Containers.Indefinite_Vectors;