* gimplify.c (find_single_pointer_decl_1): New static function.
[official-gcc.git] / gcc / ada / a-coinve.ads
blob6ccfda5f7faa8341a669f72ee00cfb56511c3a19
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-2005 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 with Ada.Finalization;
37 with Ada.Streams;
39 generic
40 type Index_Type is range <>;
42 type Element_Type (<>) is private;
44 with function "=" (Left, Right : Element_Type) return Boolean is <>;
46 package Ada.Containers.Indefinite_Vectors is
47 pragma Preelaborate;
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 subtype Index_Subtype is Index_Type;
57 type Vector is tagged private;
59 type Cursor is private;
61 Empty_Vector : constant Vector;
63 No_Element : constant Cursor;
65 function To_Vector (Length : Count_Type) return Vector;
67 function To_Vector
68 (New_Item : Element_Type;
69 Length : Count_Type) return Vector;
71 function "&" (Left, Right : Vector) return Vector;
73 function "&" (Left : Vector; Right : Element_Type) return Vector;
75 function "&" (Left : Element_Type; Right : Vector) return Vector;
77 function "&" (Left, Right : Element_Type) return Vector;
79 function "=" (Left, Right : Vector) return Boolean;
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 function Is_Empty (Container : Vector) return Boolean;
91 procedure Clear (Container : in out Vector);
93 function To_Cursor
94 (Container : Vector;
95 Index : Extended_Index) return Cursor;
97 function To_Index (Position : Cursor) return Extended_Index;
99 function Element
100 (Container : Vector;
101 Index : Index_Type) return Element_Type;
103 function Element (Position : Cursor) return Element_Type;
105 procedure Query_Element
106 (Container : Vector;
107 Index : Index_Type;
108 Process : not null access procedure (Element : Element_Type));
110 procedure Query_Element
111 (Position : Cursor;
112 Process : not null access procedure (Element : Element_Type));
114 procedure Update_Element
115 (Container : Vector;
116 Index : Index_Type;
117 Process : not null access procedure (Element : in out Element_Type));
119 procedure Update_Element
120 (Position : Cursor;
121 Process : not null access procedure (Element : in out Element_Type));
123 procedure Replace_Element
124 (Container : Vector;
125 Index : Index_Type;
126 By : Element_Type);
128 procedure Replace_Element
129 (Position : Cursor;
130 By : Element_Type);
132 procedure Assign (Target : in out Vector; Source : Vector);
134 procedure Move (Target : in out Vector; Source : in out Vector);
136 procedure Insert
137 (Container : in out Vector;
138 Before : Extended_Index;
139 New_Item : Vector);
141 procedure Insert
142 (Container : in out Vector;
143 Before : Cursor;
144 New_Item : Vector);
146 procedure Insert
147 (Container : in out Vector;
148 Before : Cursor;
149 New_Item : Vector;
150 Position : out Cursor);
152 procedure Insert
153 (Container : in out Vector;
154 Before : Extended_Index;
155 New_Item : Element_Type;
156 Count : Count_Type := 1);
158 procedure Insert
159 (Container : in out Vector;
160 Before : Cursor;
161 New_Item : Element_Type;
162 Count : Count_Type := 1);
164 procedure Insert
165 (Container : in out Vector;
166 Before : Cursor;
167 New_Item : Element_Type;
168 Position : out Cursor;
169 Count : Count_Type := 1);
171 procedure Prepend
172 (Container : in out Vector;
173 New_Item : Vector);
175 procedure Prepend
176 (Container : in out Vector;
177 New_Item : Element_Type;
178 Count : Count_Type := 1);
180 procedure Append
181 (Container : in out Vector;
182 New_Item : Vector);
184 procedure Append
185 (Container : in out Vector;
186 New_Item : Element_Type;
187 Count : Count_Type := 1);
189 procedure Insert_Space
190 (Container : in out Vector;
191 Before : Extended_Index;
192 Count : Count_Type := 1);
194 procedure Insert_Space
195 (Container : in out Vector;
196 Before : Cursor;
197 Position : out Cursor;
198 Count : Count_Type := 1);
200 procedure Set_Length
201 (Container : in out Vector;
202 Length : Count_Type);
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 function First_Index (Container : Vector) return Index_Type;
224 function First (Container : Vector) return Cursor;
226 function First_Element (Container : Vector) return Element_Type;
228 function Last_Index (Container : Vector) return Extended_Index;
230 function Last (Container : Vector) return Cursor;
232 function Last_Element (Container : Vector) return Element_Type;
234 procedure Swap (Container : Vector; I, J : Index_Type);
236 procedure Swap (I, J : Cursor);
238 generic
239 with function "<" (Left, Right : Element_Type) return Boolean is <>;
240 package Generic_Sorting is
242 function Is_Sorted (Container : Vector) return Boolean;
244 procedure Sort (Container : in out Vector);
246 procedure Merge (Target, Source : in out Vector);
248 end Generic_Sorting;
250 function Find_Index
251 (Container : Vector;
252 Item : Element_Type;
253 Index : Index_Type := Index_Type'First) return Extended_Index;
255 function Find
256 (Container : Vector;
257 Item : Element_Type;
258 Position : Cursor := No_Element) return Cursor;
260 function Reverse_Find_Index
261 (Container : Vector;
262 Item : Element_Type;
263 Index : Index_Type := Index_Type'Last) return Extended_Index;
265 function Reverse_Find (Container : Vector;
266 Item : Element_Type;
267 Position : Cursor := No_Element)
268 return Cursor;
270 function Contains
271 (Container : Vector;
272 Item : Element_Type) return Boolean;
274 function Next (Position : Cursor) return Cursor;
276 function Previous (Position : Cursor) return Cursor;
278 procedure Next (Position : in out Cursor);
280 procedure Previous (Position : in out Cursor);
282 function Has_Element (Position : Cursor) return Boolean;
284 procedure Iterate
285 (Container : Vector;
286 Process : not null access procedure (Position : Cursor));
288 procedure Reverse_Iterate
289 (Container : Vector;
290 Process : not null access procedure (Position : Cursor));
292 private
294 pragma Inline (First_Index);
295 pragma Inline (Last_Index);
296 pragma Inline (Element);
297 pragma Inline (First_Element);
298 pragma Inline (Last_Element);
299 pragma Inline (Query_Element);
300 pragma Inline (Update_Element);
301 pragma Inline (Replace_Element);
302 pragma Inline (Contains);
304 type Element_Access is access Element_Type;
306 type Elements_Type is array (Index_Type range <>) of Element_Access;
308 function "=" (L, R : Elements_Type) return Boolean is abstract;
310 type Elements_Access is access Elements_Type;
312 use Ada.Finalization;
314 type Vector is new Controlled with record
315 Elements : Elements_Access;
316 Last : Extended_Index := No_Index;
317 Busy : Natural := 0;
318 Lock : Natural := 0;
319 end record;
321 procedure Adjust (Container : in out Vector);
323 procedure Finalize (Container : in out Vector);
325 use Ada.Streams;
327 procedure Write
328 (Stream : access Root_Stream_Type'Class;
329 Container : Vector);
331 for Vector'Write use Write;
333 procedure Read
334 (Stream : access Root_Stream_Type'Class;
335 Container : out Vector);
337 for Vector'Read use Read;
339 Empty_Vector : constant Vector := (Controlled with null, No_Index, 0, 0);
341 type Vector_Access is access constant Vector;
342 for Vector_Access'Storage_Size use 0;
344 type Cursor is record
345 Container : Vector_Access;
346 Index : Index_Type := Index_Type'First;
347 end record;
349 No_Element : constant Cursor := Cursor'(null, Index_Type'First);
351 end Ada.Containers.Indefinite_Vectors;