Makefile.in: Rebuilt.
[official-gcc.git] / gcc / ada / a-coinve.ads
blob317dc75366e2c8c51bd3b4b2f23fd4cec1371206
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-2006, 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 <>;
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;
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 is tagged private;
55 pragma Preelaborable_Initialization (Vector);
57 type Cursor is private;
58 pragma Preelaborable_Initialization (Cursor);
60 Empty_Vector : constant Vector;
62 No_Element : constant Cursor;
64 function "=" (Left, Right : Vector) return Boolean;
66 function To_Vector (Length : Count_Type) return Vector;
68 function To_Vector
69 (New_Item : Element_Type;
70 Length : Count_Type) return Vector;
72 function "&" (Left, Right : Vector) return Vector;
74 function "&" (Left : Vector; Right : Element_Type) return Vector;
76 function "&" (Left : Element_Type; Right : Vector) return Vector;
78 function "&" (Left, Right : Element_Type) return Vector;
80 function Capacity (Container : Vector) return Count_Type;
82 procedure Reserve_Capacity
83 (Container : in out Vector;
84 Capacity : Count_Type);
86 function Length (Container : Vector) return Count_Type;
88 procedure Set_Length
89 (Container : in out Vector;
90 Length : Count_Type);
92 function Is_Empty (Container : Vector) return Boolean;
94 procedure Clear (Container : in out Vector);
96 function To_Cursor
97 (Container : Vector;
98 Index : Extended_Index) return Cursor;
100 function To_Index (Position : Cursor) return Extended_Index;
102 function Element
103 (Container : Vector;
104 Index : Index_Type) return Element_Type;
106 function Element (Position : Cursor) return Element_Type;
108 procedure Replace_Element
109 (Container : in out Vector;
110 Index : Index_Type;
111 New_Item : Element_Type);
113 procedure Replace_Element
114 (Container : in out Vector;
115 Position : Cursor;
116 New_Item : Element_Type);
118 procedure Query_Element
119 (Container : Vector;
120 Index : Index_Type;
121 Process : not null access procedure (Element : Element_Type));
123 procedure Query_Element
124 (Position : Cursor;
125 Process : not null access procedure (Element : Element_Type));
127 procedure Update_Element
128 (Container : in out Vector;
129 Index : Index_Type;
130 Process : not null access procedure (Element : in out Element_Type));
132 procedure Update_Element
133 (Container : in out Vector;
134 Position : Cursor;
135 Process : not null access procedure (Element : in out Element_Type));
137 procedure Move (Target : in out Vector; Source : in out Vector);
139 procedure Insert
140 (Container : in out Vector;
141 Before : Extended_Index;
142 New_Item : Vector);
144 procedure Insert
145 (Container : in out Vector;
146 Before : Cursor;
147 New_Item : Vector);
149 procedure Insert
150 (Container : in out Vector;
151 Before : Cursor;
152 New_Item : Vector;
153 Position : out Cursor);
155 procedure Insert
156 (Container : in out Vector;
157 Before : Extended_Index;
158 New_Item : Element_Type;
159 Count : Count_Type := 1);
161 procedure Insert
162 (Container : in out Vector;
163 Before : Cursor;
164 New_Item : Element_Type;
165 Count : Count_Type := 1);
167 procedure Insert
168 (Container : in out Vector;
169 Before : Cursor;
170 New_Item : Element_Type;
171 Position : out Cursor;
172 Count : Count_Type := 1);
174 procedure Prepend
175 (Container : in out Vector;
176 New_Item : Vector);
178 procedure Prepend
179 (Container : in out Vector;
180 New_Item : Element_Type;
181 Count : Count_Type := 1);
183 procedure Append
184 (Container : in out Vector;
185 New_Item : Vector);
187 procedure Append
188 (Container : in out Vector;
189 New_Item : Element_Type;
190 Count : Count_Type := 1);
192 procedure Insert_Space
193 (Container : in out Vector;
194 Before : Extended_Index;
195 Count : Count_Type := 1);
197 procedure Insert_Space
198 (Container : in out Vector;
199 Before : Cursor;
200 Position : out Cursor;
201 Count : Count_Type := 1);
203 procedure Delete
204 (Container : in out Vector;
205 Index : Extended_Index;
206 Count : Count_Type := 1);
208 procedure Delete
209 (Container : in out Vector;
210 Position : in out Cursor;
211 Count : Count_Type := 1);
213 procedure Delete_First
214 (Container : in out Vector;
215 Count : Count_Type := 1);
217 procedure Delete_Last
218 (Container : in out Vector;
219 Count : Count_Type := 1);
221 procedure Reverse_Elements (Container : in out Vector);
223 procedure Swap (Container : in out Vector; I, J : Index_Type);
225 procedure Swap (Container : in out Vector; I, J : Cursor);
227 function First_Index (Container : Vector) return Index_Type;
229 function First (Container : Vector) return Cursor;
231 function First_Element (Container : Vector) return Element_Type;
233 function Last_Index (Container : Vector) return Extended_Index;
235 function Last (Container : Vector) return Cursor;
237 function Last_Element (Container : Vector) return Element_Type;
239 function Next (Position : Cursor) return Cursor;
241 procedure Next (Position : in out Cursor);
243 function Previous (Position : Cursor) return Cursor;
245 procedure Previous (Position : in out Cursor);
247 function Find_Index
248 (Container : Vector;
249 Item : Element_Type;
250 Index : Index_Type := Index_Type'First) return Extended_Index;
252 function Find
253 (Container : Vector;
254 Item : Element_Type;
255 Position : Cursor := No_Element) return Cursor;
257 function Reverse_Find_Index
258 (Container : Vector;
259 Item : Element_Type;
260 Index : Index_Type := Index_Type'Last) return Extended_Index;
262 function Reverse_Find
263 (Container : Vector;
264 Item : Element_Type;
265 Position : Cursor := No_Element) return Cursor;
267 function Contains
268 (Container : Vector;
269 Item : Element_Type) return Boolean;
271 function Has_Element (Position : Cursor) return Boolean;
273 procedure Iterate
274 (Container : Vector;
275 Process : not null access procedure (Position : Cursor));
277 procedure Reverse_Iterate
278 (Container : Vector;
279 Process : not null access procedure (Position : Cursor));
281 generic
282 with function "<" (Left, Right : Element_Type) return Boolean is <>;
283 package Generic_Sorting is
285 function Is_Sorted (Container : Vector) return Boolean;
287 procedure Sort (Container : in out Vector);
289 procedure Merge (Target : in out Vector; Source : in out Vector);
291 end Generic_Sorting;
293 private
295 pragma Inline (First_Index);
296 pragma Inline (Last_Index);
297 pragma Inline (Element);
298 pragma Inline (First_Element);
299 pragma Inline (Last_Element);
300 pragma Inline (Query_Element);
301 pragma Inline (Update_Element);
302 pragma Inline (Replace_Element);
303 pragma Inline (Contains);
305 type Element_Access is access Element_Type;
307 type Elements_Type is array (Index_Type range <>) of Element_Access;
309 function "=" (L, R : Elements_Type) return Boolean is abstract;
311 type Elements_Access is access Elements_Type;
313 use Ada.Finalization;
315 type Vector is new Controlled with record
316 Elements : Elements_Access;
317 Last : Extended_Index := No_Index;
318 Busy : Natural := 0;
319 Lock : Natural := 0;
320 end record;
322 procedure Adjust (Container : in out Vector);
324 procedure Finalize (Container : in out Vector);
326 use Ada.Streams;
328 procedure Write
329 (Stream : not null access Root_Stream_Type'Class;
330 Container : Vector);
332 for Vector'Write use Write;
334 procedure Read
335 (Stream : not null access Root_Stream_Type'Class;
336 Container : out Vector);
338 for Vector'Read use Read;
340 Empty_Vector : constant Vector := (Controlled with null, No_Index, 0, 0);
342 type Vector_Access is access constant Vector;
343 for Vector_Access'Storage_Size use 0;
345 type Cursor is record
346 Container : Vector_Access;
347 Index : Index_Type := Index_Type'First;
348 end record;
350 procedure Write
351 (Stream : not null access Root_Stream_Type'Class;
352 Position : Cursor);
354 for Cursor'Write use Write;
356 procedure Read
357 (Stream : not null access Root_Stream_Type'Class;
358 Position : out Cursor);
360 for Cursor'Read use Read;
362 No_Element : constant Cursor := Cursor'(null, Index_Type'First);
364 end Ada.Containers.Indefinite_Vectors;