OSDN Git Service

* gcc-interface/decl.c (make_type_from_size) <INTEGER_TYPE>: Just copy
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-coinve.ads
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-2008, 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 ------------------------------------------------------------------------------
33
34 private with Ada.Finalization;
35 private with Ada.Streams;
36
37 generic
38    type Index_Type is range <>;
39    type Element_Type (<>) is private;
40
41    with function "=" (Left, Right : Element_Type) return Boolean is <>;
42
43 package Ada.Containers.Indefinite_Vectors is
44    pragma Preelaborate;
45    pragma Remote_Types;
46
47    subtype Extended_Index is Index_Type'Base
48      range Index_Type'First - 1 ..
49            Index_Type'Min (Index_Type'Base'Last - 1, Index_Type'Last) + 1;
50
51    No_Index : constant Extended_Index := Extended_Index'First;
52
53    type Vector is tagged private;
54    pragma Preelaborable_Initialization (Vector);
55
56    type Cursor is private;
57    pragma Preelaborable_Initialization (Cursor);
58
59    Empty_Vector : constant Vector;
60
61    No_Element : constant Cursor;
62
63    overriding function "=" (Left, Right : Vector) return Boolean;
64
65    function To_Vector (Length : Count_Type) return Vector;
66
67    function To_Vector
68      (New_Item : Element_Type;
69       Length   : Count_Type) return Vector;
70
71    function "&" (Left, Right : Vector) return Vector;
72
73    function "&" (Left : Vector; Right : Element_Type) return Vector;
74
75    function "&" (Left : Element_Type; Right : Vector) return Vector;
76
77    function "&" (Left, Right : Element_Type) return Vector;
78
79    function Capacity (Container : Vector) return Count_Type;
80
81    procedure Reserve_Capacity
82      (Container : in out Vector;
83       Capacity  : Count_Type);
84
85    function Length (Container : Vector) return Count_Type;
86
87    procedure Set_Length
88      (Container : in out Vector;
89       Length    : Count_Type);
90
91    function Is_Empty (Container : Vector) return Boolean;
92
93    procedure Clear (Container : in out Vector);
94
95    function To_Cursor
96      (Container : Vector;
97       Index     : Extended_Index) return Cursor;
98
99    function To_Index (Position : Cursor) return Extended_Index;
100
101    function Element
102      (Container : Vector;
103       Index     : Index_Type) return Element_Type;
104
105    function Element (Position : Cursor) return Element_Type;
106
107    procedure Replace_Element
108      (Container : in out Vector;
109       Index     : Index_Type;
110       New_Item  : Element_Type);
111
112    procedure Replace_Element
113      (Container : in out Vector;
114       Position  : Cursor;
115       New_Item  : Element_Type);
116
117    procedure Query_Element
118      (Container : Vector;
119       Index     : Index_Type;
120       Process   : not null access procedure (Element : Element_Type));
121
122    procedure Query_Element
123      (Position : Cursor;
124       Process  : not null access procedure (Element : Element_Type));
125
126    procedure Update_Element
127      (Container : in out Vector;
128       Index     : Index_Type;
129       Process   : not null access procedure (Element : in out Element_Type));
130
131    procedure Update_Element
132      (Container : in out Vector;
133       Position  : Cursor;
134       Process   : not null access procedure (Element : in out Element_Type));
135
136    procedure Move (Target : in out Vector; Source : in out Vector);
137
138    procedure Insert
139      (Container : in out Vector;
140       Before    : Extended_Index;
141       New_Item  : Vector);
142
143    procedure Insert
144      (Container : in out Vector;
145       Before    : Cursor;
146       New_Item  : Vector);
147
148    procedure Insert
149      (Container : in out Vector;
150       Before    : Cursor;
151       New_Item  : Vector;
152       Position  : out Cursor);
153
154    procedure Insert
155      (Container : in out Vector;
156       Before    : Extended_Index;
157       New_Item  : Element_Type;
158       Count     : Count_Type := 1);
159
160    procedure Insert
161      (Container : in out Vector;
162       Before    : Cursor;
163       New_Item  : Element_Type;
164       Count     : Count_Type := 1);
165
166    procedure Insert
167      (Container : in out Vector;
168       Before    : Cursor;
169       New_Item  : Element_Type;
170       Position  : out Cursor;
171       Count     : Count_Type := 1);
172
173    procedure Prepend
174      (Container : in out Vector;
175       New_Item  : Vector);
176
177    procedure Prepend
178      (Container : in out Vector;
179       New_Item  : Element_Type;
180       Count     : Count_Type := 1);
181
182    procedure Append
183      (Container : in out Vector;
184       New_Item  : Vector);
185
186    procedure Append
187      (Container : in out Vector;
188       New_Item  : Element_Type;
189       Count     : Count_Type := 1);
190
191    procedure Insert_Space
192      (Container : in out Vector;
193       Before    : Extended_Index;
194       Count     : Count_Type := 1);
195
196    procedure Insert_Space
197      (Container : in out Vector;
198       Before    : Cursor;
199       Position  : out Cursor;
200       Count     : Count_Type := 1);
201
202    procedure Delete
203      (Container : in out Vector;
204       Index     : Extended_Index;
205       Count     : Count_Type := 1);
206
207    procedure Delete
208      (Container : in out Vector;
209       Position  : in out Cursor;
210       Count     : Count_Type := 1);
211
212    procedure Delete_First
213      (Container : in out Vector;
214       Count     : Count_Type := 1);
215
216    procedure Delete_Last
217      (Container : in out Vector;
218       Count     : Count_Type := 1);
219
220    procedure Reverse_Elements (Container : in out Vector);
221
222    procedure Swap (Container : in out Vector; I, J : Index_Type);
223
224    procedure Swap (Container : in out Vector; I, J : Cursor);
225
226    function First_Index (Container : Vector) return Index_Type;
227
228    function First (Container : Vector) return Cursor;
229
230    function First_Element (Container : Vector) return Element_Type;
231
232    function Last_Index (Container : Vector) return Extended_Index;
233
234    function Last (Container : Vector) return Cursor;
235
236    function Last_Element (Container : Vector) return Element_Type;
237
238    function Next (Position : Cursor) return Cursor;
239
240    procedure Next (Position : in out Cursor);
241
242    function Previous (Position : Cursor) return Cursor;
243
244    procedure Previous (Position : in out Cursor);
245
246    function Find_Index
247      (Container : Vector;
248       Item      : Element_Type;
249       Index     : Index_Type := Index_Type'First) return Extended_Index;
250
251    function Find
252      (Container : Vector;
253       Item      : Element_Type;
254       Position  : Cursor := No_Element) return Cursor;
255
256    function Reverse_Find_Index
257      (Container : Vector;
258       Item      : Element_Type;
259       Index     : Index_Type := Index_Type'Last) return Extended_Index;
260
261    function Reverse_Find
262      (Container : Vector;
263       Item      : Element_Type;
264       Position  : Cursor := No_Element) return Cursor;
265
266    function Contains
267      (Container : Vector;
268       Item      : Element_Type) return Boolean;
269
270    function Has_Element (Position : Cursor) return Boolean;
271
272    procedure Iterate
273      (Container : Vector;
274       Process   : not null access procedure (Position : Cursor));
275
276    procedure Reverse_Iterate
277      (Container : Vector;
278       Process   : not null access procedure (Position : Cursor));
279
280    generic
281       with function "<" (Left, Right : Element_Type) return Boolean is <>;
282    package Generic_Sorting is
283
284       function Is_Sorted (Container : Vector) return Boolean;
285
286       procedure Sort (Container : in out Vector);
287
288       procedure Merge (Target : in out Vector; Source : in out Vector);
289
290    end Generic_Sorting;
291
292 private
293
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);
303    pragma Inline (Next);
304    pragma Inline (Previous);
305
306    type Element_Access is access Element_Type;
307
308    type Elements_Array is array (Index_Type range <>) of Element_Access;
309    function "=" (L, R : Elements_Array) return Boolean is abstract;
310
311    type Elements_Type (Last : Index_Type) is limited record
312       EA : Elements_Array (Index_Type'First .. Last);
313    end record;
314
315    type Elements_Access is access Elements_Type;
316
317    use Ada.Finalization;
318
319    type Vector is new Controlled with record
320       Elements : Elements_Access;
321       Last     : Extended_Index := No_Index;
322       Busy     : Natural := 0;
323       Lock     : Natural := 0;
324    end record;
325
326    overriding
327    procedure Adjust (Container : in out Vector);
328
329    overriding
330    procedure Finalize (Container : in out Vector);
331
332    use Ada.Streams;
333
334    procedure Write
335      (Stream    : not null access Root_Stream_Type'Class;
336       Container : Vector);
337
338    for Vector'Write use Write;
339
340    procedure Read
341      (Stream    : not null access Root_Stream_Type'Class;
342       Container : out Vector);
343
344    for Vector'Read use Read;
345
346    type Vector_Access is access constant Vector;
347    for Vector_Access'Storage_Size use 0;
348
349    type Cursor is record
350       Container : Vector_Access;
351       Index     : Index_Type := Index_Type'First;
352    end record;
353
354    procedure Write
355      (Stream   : not null access Root_Stream_Type'Class;
356       Position : Cursor);
357
358    for Cursor'Write use Write;
359
360    procedure Read
361      (Stream   : not null access Root_Stream_Type'Class;
362       Position : out Cursor);
363
364    for Cursor'Read use Read;
365
366    Empty_Vector : constant Vector := (Controlled with null, No_Index, 0, 0);
367
368    No_Element : constant Cursor := Cursor'(null, Index_Type'First);
369
370 end Ada.Containers.Indefinite_Vectors;