]> gcc.gnu.org Git - gcc.git/blame - gcc/ada/a-coinve.ads
a-rbtgso.adb, [...]: New files.
[gcc.git] / gcc / ada / a-coinve.ads
CommitLineData
4c2d6a70
AC
1------------------------------------------------------------------------------
2-- --
3-- GNAT LIBRARY COMPONENTS --
4-- --
5-- ADA.CONTAINERS.INDEFINITE_VECTORS --
6-- --
7-- S p e c --
8-- --
9-- Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, --
24-- MA 02111-1307, 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------------------------------------------------------------------------------
35
36with Ada.Finalization;
37with Ada.Streams;
38
39generic
40 type Index_Type is range <>;
41
42 type Element_Type (<>) is private;
43
44 with function "=" (Left, Right : Element_Type) return Boolean is <>;
45
46package Ada.Containers.Indefinite_Vectors is
47pragma Preelaborate (Indefinite_Vectors);
48
49 subtype Extended_Index is Index_Type'Base
50 range Index_Type'First - 1 ..
51 Index_Type'Last +
52 Boolean'Pos (Index_Type'Base'Last > Index_Type'Last);
53
54 No_Index : constant Extended_Index := Extended_Index'First;
55
56 subtype Index_Subtype is Index_Type;
57
58 type Vector is tagged private;
59
60 type Cursor is private;
61
62 Empty_Vector : constant Vector;
63
64 No_Element : constant Cursor;
65
66 function To_Vector (Length : Count_Type) return Vector;
67
68 function To_Vector
69 (New_Item : Element_Type;
70 Length : Count_Type) return Vector;
71
72 function "&" (Left, Right : Vector) return Vector;
73
74 function "&" (Left : Vector; Right : Element_Type) return Vector;
75
76 function "&" (Left : Element_Type; Right : Vector) return Vector;
77
78 function "&" (Left, Right : Element_Type) return Vector;
79
80 function "=" (Left, Right : Vector) return Boolean;
81
82 function Capacity (Container : Vector) return Count_Type;
83
84 procedure Reserve_Capacity
85 (Container : in out Vector;
86 Capacity : Count_Type);
87
88 function Length (Container : Vector) return Count_Type;
89
90 function Is_Empty (Container : Vector) return Boolean;
91
92 procedure Clear (Container : in out Vector);
93
94 function To_Cursor
95 (Container : Vector;
96 Index : Extended_Index) return Cursor;
97
98 function To_Index (Position : Cursor) return Extended_Index;
99
100 function Element
101 (Container : Vector;
102 Index : Index_Type) return Element_Type;
103
104 function Element (Position : Cursor) return Element_Type;
105
106 procedure Query_Element
107 (Container : Vector;
108 Index : Index_Type;
109 Process : not null access procedure (Element : Element_Type));
110
111 procedure Query_Element
112 (Position : Cursor;
113 Process : not null access procedure (Element : Element_Type));
114
115 procedure Update_Element
116 (Container : Vector;
117 Index : Index_Type;
118 Process : not null access procedure (Element : in out Element_Type));
119
120 procedure Update_Element
121 (Position : Cursor;
122 Process : not null access procedure (Element : in out Element_Type));
123
124 procedure Replace_Element
125 (Container : Vector;
126 Index : Index_Type;
127 By : Element_Type);
128
129 procedure Replace_Element
130 (Position : Cursor;
131 By : Element_Type);
132
133 procedure Assign (Target : in out Vector; Source : Vector);
134
135 procedure Move (Target : in out Vector; Source : in out Vector);
136
137 procedure Insert
138 (Container : in out Vector;
139 Before : Extended_Index;
140 New_Item : Vector);
141
142 procedure Insert
143 (Container : in out Vector;
144 Before : Cursor;
145 New_Item : Vector);
146
147 procedure Insert
148 (Container : in out Vector;
149 Before : Cursor;
150 New_Item : Vector;
151 Position : out Cursor);
152
153 procedure Insert
154 (Container : in out Vector;
155 Before : Extended_Index;
156 New_Item : Element_Type;
157 Count : Count_Type := 1);
158
159 procedure Insert
160 (Container : in out Vector;
161 Before : Cursor;
162 New_Item : Element_Type;
163 Count : Count_Type := 1);
164
165 procedure Insert
166 (Container : in out Vector;
167 Before : Cursor;
168 New_Item : Element_Type;
169 Position : out Cursor;
170 Count : Count_Type := 1);
171
172 procedure Prepend
173 (Container : in out Vector;
174 New_Item : Vector);
175
176 procedure Prepend
177 (Container : in out Vector;
178 New_Item : Element_Type;
179 Count : Count_Type := 1);
180
181 procedure Append
182 (Container : in out Vector;
183 New_Item : Vector);
184
185 procedure Append
186 (Container : in out Vector;
187 New_Item : Element_Type;
188 Count : Count_Type := 1);
189
190 procedure Insert_Space
191 (Container : in out Vector;
192 Before : Extended_Index;
193 Count : Count_Type := 1);
194
195 procedure Insert_Space
196 (Container : in out Vector;
197 Before : Cursor;
198 Position : out Cursor;
199 Count : Count_Type := 1);
200
201 procedure Set_Length
202 (Container : in out Vector;
203 Length : Count_Type);
204
205 procedure Delete
206 (Container : in out Vector;
207 Index : Extended_Index; -- TODO: verify
208 Count : Count_Type := 1);
209
210 procedure Delete
211 (Container : in out Vector;
212 Position : in out Cursor;
213 Count : Count_Type := 1);
214
215 procedure Delete_First
216 (Container : in out Vector;
217 Count : Count_Type := 1);
218
219 procedure Delete_Last
220 (Container : in out Vector;
221 Count : Count_Type := 1);
222
223 function First_Index (Container : Vector) return Index_Type;
224
225 function First (Container : Vector) return Cursor;
226
227 function First_Element (Container : Vector) return Element_Type;
228
229 function Last_Index (Container : Vector) return Extended_Index;
230
231 function Last (Container : Vector) return Cursor;
232
233 function Last_Element (Container : Vector) return Element_Type;
234
235 procedure Swap (Container : Vector; I, J : Index_Type);
236
237 procedure Swap (I, J : Cursor);
238
239 generic
240 with function "<" (Left, Right : Element_Type) return Boolean is <>;
241 procedure Generic_Sort (Container : Vector);
242
243 function Find_Index
244 (Container : Vector;
245 Item : Element_Type;
246 Index : Index_Type := Index_Type'First) return Extended_Index;
247
248 function Find
249 (Container : Vector;
250 Item : Element_Type;
251 Position : Cursor := No_Element) return Cursor;
252
253 function Reverse_Find_Index
254 (Container : Vector;
255 Item : Element_Type;
256 Index : Index_Type := Index_Type'Last) return Extended_Index;
257
258 function Reverse_Find (Container : Vector;
259 Item : Element_Type;
260 Position : Cursor := No_Element)
261 return Cursor;
262
263 function Contains
264 (Container : Vector;
265 Item : Element_Type) return Boolean;
266
267 function Next (Position : Cursor) return Cursor;
268
269 function Previous (Position : Cursor) return Cursor;
270
271 procedure Next (Position : in out Cursor);
272
273 procedure Previous (Position : in out Cursor);
274
275 function Has_Element (Position : Cursor) return Boolean;
276
277 procedure Iterate
278 (Container : Vector;
279 Process : not null access procedure (Position : Cursor));
280
281 procedure Reverse_Iterate
282 (Container : Vector;
283 Process : not null access procedure (Position : Cursor));
284
285private
286
287 pragma Inline (First_Index);
288 pragma Inline (Last_Index);
289 pragma Inline (Element);
290 pragma Inline (First_Element);
291 pragma Inline (Last_Element);
292 pragma Inline (Query_Element);
293 pragma Inline (Update_Element);
294 pragma Inline (Replace_Element);
295 pragma Inline (Contains);
296
297 type Element_Access is access Element_Type;
298
299 type Elements_Type is array (Index_Type range <>) of Element_Access;
300
301 function "=" (L, R : Elements_Type) return Boolean is abstract;
302
303 type Elements_Access is access Elements_Type;
304
305 use Ada.Finalization;
306
307 type Vector is new Controlled with record
308 Elements : Elements_Access;
309 Last : Extended_Index := No_Index;
310 end record;
311
312 procedure Adjust (Container : in out Vector);
313
314 procedure Finalize (Container : in out Vector);
315
316 use Ada.Streams;
317
318 procedure Write
319 (Stream : access Root_Stream_Type'Class;
320 Container : Vector);
321
322 for Vector'Write use Write;
323
324 procedure Read
325 (Stream : access Root_Stream_Type'Class;
326 Container : out Vector);
327
328 for Vector'Read use Read;
329
330 Empty_Vector : constant Vector := Vector'(Controlled with null, No_Index);
331
332 type Vector_Access is access constant Vector;
333 for Vector_Access'Storage_Size use 0;
334
335 type Cursor is record
336 Container : Vector_Access;
337 Index : Index_Type := Index_Type'First;
338 end record;
339
340 No_Element : constant Cursor := Cursor'(null, Index_Type'First);
341
342end Ada.Containers.Indefinite_Vectors;
343
This page took 0.064514 seconds and 5 git commands to generate.