]> gcc.gnu.org Git - gcc.git/blame - gcc/ada/libgnat/a-coinve.ads
doc: Mark up __cxa_atexit as @code.
[gcc.git] / gcc / ada / libgnat / a-coinve.ads
CommitLineData
4c2d6a70
AC
1------------------------------------------------------------------------------
2-- --
3-- GNAT LIBRARY COMPONENTS --
4-- --
8704d4b3 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 --
4c2d6a70
AC
6-- --
7-- S p e c --
8-- --
06c565cc 9-- Copyright (C) 2004-2024, Free Software Foundation, Inc. --
4c2d6a70
AC
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- --
748086b7 17-- ware Foundation; either version 3, or (at your option) any later ver- --
4c2d6a70
AC
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 --
748086b7
JJ
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/>. --
4c2d6a70
AC
30-- --
31-- This unit was originally developed by Matthew J Heaney. --
32------------------------------------------------------------------------------
33
3e24afaa 34with Ada.Iterator_Interfaces;
4c2d6a70 35
1f8f3e6e 36with Ada.Containers.Helpers;
3c24c853
MH
37private with Ada.Finalization;
38private with Ada.Streams;
20922782 39private with Ada.Strings.Text_Buffers;
3c24c853 40
4c2d6a70
AC
41generic
42 type Index_Type is range <>;
4c2d6a70
AC
43 type Element_Type (<>) is private;
44
45 with function "=" (Left, Right : Element_Type) return Boolean is <>;
46
3221be14
YM
47package Ada.Containers.Indefinite_Vectors with
48 SPARK_Mode => Off
49is
6031f544 50 pragma Annotate (CodePeer, Skip_Analysis);
009186e0 51 pragma Preelaborate;
f97ccb3a 52 pragma Remote_Types;
4c2d6a70
AC
53
54 subtype Extended_Index is Index_Type'Base
55 range Index_Type'First - 1 ..
d43d5ef7 56 Index_Type'Min (Index_Type'Base'Last - 1, Index_Type'Last) + 1;
4c2d6a70
AC
57
58 No_Index : constant Extended_Index := Extended_Index'First;
59
3e24afaa
AC
60 type Vector is tagged private
61 with
62 Constant_Indexing => Constant_Reference,
63 Variable_Indexing => Reference,
64 Default_Iterator => Iterate,
fe3463cc 65 Iterator_Element => Element_Type,
9ec20f1f 66 Aggregate => (Empty => Empty,
3e05da68 67 Add_Unnamed => Append,
fe3463cc
ES
68 New_Indexed => New_Vector,
69 Assign_Indexed => Replace_Element);
3e24afaa 70
9b832db5 71 pragma Preelaborable_Initialization (Vector);
4c2d6a70
AC
72
73 type Cursor is private;
9b832db5 74 pragma Preelaborable_Initialization (Cursor);
4c2d6a70
AC
75
76 Empty_Vector : constant Vector;
77
78 No_Element : constant Cursor;
3e24afaa 79
3bb4836f
ES
80 function Empty (Capacity : Count_Type := 10) return Vector;
81
3c24c853 82 function Has_Element (Position : Cursor) return Boolean;
3e24afaa
AC
83
84 package Vector_Iterator_Interfaces is new
85 Ada.Iterator_Interfaces (Cursor, Has_Element);
4c2d6a70 86
fa969310 87 overriding function "=" (Left, Right : Vector) return Boolean;
2368f04e 88
fe3463cc
ES
89 function New_Vector (First, Last : Index_Type) return Vector
90 with Pre => First = Index_Type'First;
91
4c2d6a70
AC
92 function To_Vector (Length : Count_Type) return Vector;
93
94 function To_Vector
95 (New_Item : Element_Type;
96 Length : Count_Type) return Vector;
97
98 function "&" (Left, Right : Vector) return Vector;
99
100 function "&" (Left : Vector; Right : Element_Type) return Vector;
101
102 function "&" (Left : Element_Type; Right : Vector) return Vector;
103
104 function "&" (Left, Right : Element_Type) return Vector;
105
4c2d6a70
AC
106 function Capacity (Container : Vector) return Count_Type;
107
108 procedure Reserve_Capacity
109 (Container : in out Vector;
110 Capacity : Count_Type);
111
112 function Length (Container : Vector) return Count_Type;
113
2368f04e
MH
114 procedure Set_Length
115 (Container : in out Vector;
116 Length : Count_Type);
117
4c2d6a70
AC
118 function Is_Empty (Container : Vector) return Boolean;
119
120 procedure Clear (Container : in out Vector);
121
3e24afaa
AC
122 type Constant_Reference_Type
123 (Element : not null access constant Element_Type) is private
124 with
125 Implicit_Dereference => Element;
126
3e24afaa
AC
127 type Reference_Type (Element : not null access Element_Type) is private
128 with
129 Implicit_Dereference => Element;
130
3e24afaa 131 function Constant_Reference
c9423ca3
AC
132 (Container : aliased Vector;
133 Position : Cursor) return Constant_Reference_Type;
794b9b72 134 pragma Inline (Constant_Reference);
3e24afaa 135
c9423ca3
AC
136 function Reference
137 (Container : aliased in out Vector;
138 Position : Cursor) return Reference_Type;
794b9b72 139 pragma Inline (Reference);
3e24afaa 140
c9423ca3
AC
141 function Constant_Reference
142 (Container : aliased Vector;
143 Index : Index_Type) return Constant_Reference_Type;
794b9b72 144 pragma Inline (Constant_Reference);
3e24afaa 145
c9423ca3
AC
146 function Reference
147 (Container : aliased in out Vector;
148 Index : Index_Type) return Reference_Type;
794b9b72 149 pragma Inline (Reference);
3e24afaa 150
4c2d6a70
AC
151 function To_Cursor
152 (Container : Vector;
153 Index : Extended_Index) return Cursor;
154
155 function To_Index (Position : Cursor) return Extended_Index;
156
157 function Element
158 (Container : Vector;
159 Index : Index_Type) return Element_Type;
160
161 function Element (Position : Cursor) return Element_Type;
162
2368f04e
MH
163 procedure Replace_Element
164 (Container : in out Vector;
165 Index : Index_Type;
166 New_Item : Element_Type);
167
168 procedure Replace_Element
169 (Container : in out Vector;
170 Position : Cursor;
171 New_Item : Element_Type);
172
4c2d6a70
AC
173 procedure Query_Element
174 (Container : Vector;
175 Index : Index_Type;
176 Process : not null access procedure (Element : Element_Type));
177
178 procedure Query_Element
179 (Position : Cursor;
180 Process : not null access procedure (Element : Element_Type));
181
182 procedure Update_Element
2368f04e 183 (Container : in out Vector;
4c2d6a70
AC
184 Index : Index_Type;
185 Process : not null access procedure (Element : in out Element_Type));
186
187 procedure Update_Element
2368f04e
MH
188 (Container : in out Vector;
189 Position : Cursor;
190 Process : not null access procedure (Element : in out Element_Type));
4c2d6a70 191
a31945d7
AC
192 procedure Assign (Target : in out Vector; Source : Vector);
193
194 function Copy (Source : Vector; Capacity : Count_Type := 0) return Vector;
195
4c2d6a70
AC
196 procedure Move (Target : in out Vector; Source : in out Vector);
197
3e05da68 198 procedure Insert_Vector
4c2d6a70
AC
199 (Container : in out Vector;
200 Before : Extended_Index;
201 New_Item : Vector);
202
203 procedure Insert
3e05da68
BD
204 (Container : in out Vector;
205 Before : Extended_Index;
206 New_Item : Vector) renames Insert_Vector;
207 -- Retained for now for compatibility; AI12-0400 will remove this.
208
209 procedure Insert_Vector
4c2d6a70
AC
210 (Container : in out Vector;
211 Before : Cursor;
212 New_Item : Vector);
213
214 procedure Insert
3e05da68
BD
215 (Container : in out Vector;
216 Before : Cursor;
217 New_Item : Vector) renames Insert_Vector;
218 -- Retained for now for compatibility; AI12-0400 will remove this.
219
220 procedure Insert_Vector
4c2d6a70
AC
221 (Container : in out Vector;
222 Before : Cursor;
223 New_Item : Vector;
224 Position : out Cursor);
225
3e05da68
BD
226 procedure Insert
227 (Container : in out Vector;
228 Before : Cursor;
229 New_Item : Vector;
230 Position : out Cursor) renames Insert_Vector;
231 -- Retained for now for compatibility; AI12-0400 will remove this.
232
4c2d6a70
AC
233 procedure Insert
234 (Container : in out Vector;
235 Before : Extended_Index;
236 New_Item : Element_Type;
237 Count : Count_Type := 1);
238
239 procedure Insert
240 (Container : in out Vector;
241 Before : Cursor;
242 New_Item : Element_Type;
243 Count : Count_Type := 1);
244
245 procedure Insert
246 (Container : in out Vector;
247 Before : Cursor;
248 New_Item : Element_Type;
249 Position : out Cursor;
250 Count : Count_Type := 1);
251
3e05da68 252 procedure Prepend_Vector
4c2d6a70
AC
253 (Container : in out Vector;
254 New_Item : Vector);
255
3e05da68
BD
256 procedure Prepend
257 (Container : in out Vector;
258 New_Item : Vector) renames Prepend_Vector;
259 -- Retained for now for compatibility; AI12-0400 will remove this.
260
4c2d6a70
AC
261 procedure Prepend
262 (Container : in out Vector;
263 New_Item : Element_Type;
264 Count : Count_Type := 1);
265
3e05da68 266 procedure Append_Vector
4c2d6a70
AC
267 (Container : in out Vector;
268 New_Item : Vector);
269
3e05da68
BD
270 procedure Append
271 (Container : in out Vector;
272 New_Item : Vector) renames Append_Vector;
273 -- Retained for now for compatibility; AI12-0400 will remove this.
274
4c2d6a70
AC
275 procedure Append
276 (Container : in out Vector;
277 New_Item : Element_Type;
3e05da68 278 Count : Count_Type);
4c2d6a70 279
3e05da68
BD
280 procedure Append (Container : in out Vector;
281 New_Item : Element_Type);
fe3463cc 282
4c2d6a70
AC
283 procedure Insert_Space
284 (Container : in out Vector;
285 Before : Extended_Index;
286 Count : Count_Type := 1);
287
288 procedure Insert_Space
289 (Container : in out Vector;
290 Before : Cursor;
291 Position : out Cursor;
292 Count : Count_Type := 1);
293
4c2d6a70
AC
294 procedure Delete
295 (Container : in out Vector;
8704d4b3 296 Index : Extended_Index;
4c2d6a70
AC
297 Count : Count_Type := 1);
298
299 procedure Delete
300 (Container : in out Vector;
301 Position : in out Cursor;
302 Count : Count_Type := 1);
303
304 procedure Delete_First
305 (Container : in out Vector;
306 Count : Count_Type := 1);
307
308 procedure Delete_Last
309 (Container : in out Vector;
310 Count : Count_Type := 1);
311
2368f04e
MH
312 procedure Reverse_Elements (Container : in out Vector);
313
314 procedure Swap (Container : in out Vector; I, J : Index_Type);
315
316 procedure Swap (Container : in out Vector; I, J : Cursor);
317
4c2d6a70
AC
318 function First_Index (Container : Vector) return Index_Type;
319
320 function First (Container : Vector) return Cursor;
321
322 function First_Element (Container : Vector) return Element_Type;
323
324 function Last_Index (Container : Vector) return Extended_Index;
325
326 function Last (Container : Vector) return Cursor;
327
328 function Last_Element (Container : Vector) return Element_Type;
329
2368f04e 330 function Next (Position : Cursor) return Cursor;
8704d4b3 331
2368f04e 332 procedure Next (Position : in out Cursor);
8704d4b3 333
2368f04e 334 function Previous (Position : Cursor) return Cursor;
8704d4b3 335
2368f04e 336 procedure Previous (Position : in out Cursor);
4c2d6a70
AC
337
338 function Find_Index
339 (Container : Vector;
340 Item : Element_Type;
341 Index : Index_Type := Index_Type'First) return Extended_Index;
342
343 function Find
344 (Container : Vector;
345 Item : Element_Type;
2368f04e 346 Position : Cursor := No_Element) return Cursor;
4c2d6a70
AC
347
348 function Reverse_Find_Index
349 (Container : Vector;
350 Item : Element_Type;
351 Index : Index_Type := Index_Type'Last) return Extended_Index;
352
2368f04e
MH
353 function Reverse_Find
354 (Container : Vector;
355 Item : Element_Type;
356 Position : Cursor := No_Element) return Cursor;
4c2d6a70
AC
357
358 function Contains
359 (Container : Vector;
360 Item : Element_Type) return Boolean;
361
4c2d6a70
AC
362 procedure Iterate
363 (Container : Vector;
364 Process : not null access procedure (Position : Cursor));
365
3e24afaa
AC
366 function Iterate (Container : Vector)
367 return Vector_Iterator_Interfaces.Reversible_Iterator'class;
368
690943fc
RD
369 function Iterate
370 (Container : Vector;
371 Start : Cursor)
3e24afaa
AC
372 return Vector_Iterator_Interfaces.Reversible_Iterator'class;
373
4c2d6a70
AC
374 procedure Reverse_Iterate
375 (Container : Vector;
376 Process : not null access procedure (Position : Cursor));
377
2368f04e
MH
378 generic
379 with function "<" (Left, Right : Element_Type) return Boolean is <>;
380 package Generic_Sorting is
381
382 function Is_Sorted (Container : Vector) return Boolean;
383
384 procedure Sort (Container : in out Vector);
385
386 procedure Merge (Target : in out Vector; Source : in out Vector);
387
388 end Generic_Sorting;
389
4c2d6a70
AC
390private
391
e9f97e79 392 pragma Inline (Append);
4c2d6a70
AC
393 pragma Inline (First_Index);
394 pragma Inline (Last_Index);
395 pragma Inline (Element);
396 pragma Inline (First_Element);
397 pragma Inline (Last_Element);
398 pragma Inline (Query_Element);
399 pragma Inline (Update_Element);
400 pragma Inline (Replace_Element);
e9f97e79 401 pragma Inline (Is_Empty);
4c2d6a70 402 pragma Inline (Contains);
f97ccb3a
BD
403 pragma Inline (Next);
404 pragma Inline (Previous);
4c2d6a70 405
b7737d1d 406 use Ada.Containers.Helpers;
e9f97e79
AC
407 package Implementation is new Generic_Implementation;
408 use Implementation;
409
4c2d6a70
AC
410 type Element_Access is access Element_Type;
411
f97ccb3a
BD
412 type Elements_Array is array (Index_Type range <>) of Element_Access;
413 function "=" (L, R : Elements_Array) return Boolean is abstract;
4c2d6a70 414
e9f97e79 415 type Elements_Type (Last : Extended_Index) is limited record
f97ccb3a
BD
416 EA : Elements_Array (Index_Type'First .. Last);
417 end record;
4c2d6a70 418
e9f97e79
AC
419 type Elements_Access is access all Elements_Type;
420
421 use Finalization;
422 use Streams;
4c2d6a70 423
e9f97e79
AC
424 type Vector is new Controlled with record
425 Elements : Elements_Access := null;
4c2d6a70 426 Last : Extended_Index := No_Index;
e9f97e79 427 TC : aliased Tamper_Counts;
26349b6d
BD
428 end record with Put_Image => Put_Image;
429
430 procedure Put_Image
20922782 431 (S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; V : Vector);
4c2d6a70 432
607d0635 433 overriding procedure Adjust (Container : in out Vector);
607d0635 434 overriding procedure Finalize (Container : in out Vector);
4c2d6a70 435
4c2d6a70 436 procedure Write
dc6b9ba2 437 (Stream : not null access Root_Stream_Type'Class;
4c2d6a70
AC
438 Container : Vector);
439
440 for Vector'Write use Write;
441
442 procedure Read
dc6b9ba2 443 (Stream : not null access Root_Stream_Type'Class;
4c2d6a70
AC
444 Container : out Vector);
445
446 for Vector'Read use Read;
447
ef992452 448 type Vector_Access is access all Vector;
4c2d6a70
AC
449 for Vector_Access'Storage_Size use 0;
450
451 type Cursor is record
452 Container : Vector_Access;
453 Index : Index_Type := Index_Type'First;
454 end record;
455
3c24c853
MH
456 procedure Read
457 (Stream : not null access Root_Stream_Type'Class;
458 Position : out Cursor);
459
460 for Cursor'Read use Read;
461
462 procedure Write
463 (Stream : not null access Root_Stream_Type'Class;
464 Position : Cursor);
465
466 for Cursor'Write use Write;
467
e9f97e79
AC
468 subtype Reference_Control_Type is Implementation.Reference_Control_Type;
469 -- It is necessary to rename this here, so that the compiler can find it
794b9b72 470
3c24c853 471 type Constant_Reference_Type
794b9b72
AC
472 (Element : not null access constant Element_Type) is
473 record
db222ead
AC
474 Control : Reference_Control_Type :=
475 raise Program_Error with "uninitialized reference";
476 -- The RM says, "The default initialization of an object of
477 -- type Constant_Reference_Type or Reference_Type propagates
478 -- Program_Error."
794b9b72 479 end record;
3c24c853
MH
480
481 procedure Write
482 (Stream : not null access Root_Stream_Type'Class;
483 Item : Constant_Reference_Type);
484
485 for Constant_Reference_Type'Write use Write;
486
487 procedure Read
488 (Stream : not null access Root_Stream_Type'Class;
489 Item : out Constant_Reference_Type);
490
491 for Constant_Reference_Type'Read use Read;
492
493 type Reference_Type
794b9b72
AC
494 (Element : not null access Element_Type) is
495 record
db222ead
AC
496 Control : Reference_Control_Type :=
497 raise Program_Error with "uninitialized reference";
498 -- The RM says, "The default initialization of an object of
499 -- type Constant_Reference_Type or Reference_Type propagates
500 -- Program_Error."
794b9b72 501 end record;
3c24c853
MH
502
503 procedure Write
504 (Stream : not null access Root_Stream_Type'Class;
505 Item : Reference_Type);
506
507 for Reference_Type'Write use Write;
508
509 procedure Read
510 (Stream : not null access Root_Stream_Type'Class;
511 Item : out Reference_Type);
512
513 for Reference_Type'Read use Read;
514
7ce2938c
BD
515 -- See Ada.Containers.Vectors for documentation on the following
516
517 procedure _Next (Position : in out Cursor) renames Next;
518 procedure _Previous (Position : in out Cursor) renames Previous;
e9f97e79
AC
519
520 function Pseudo_Reference
521 (Container : aliased Vector'Class) return Reference_Control_Type;
522 pragma Inline (Pseudo_Reference);
523 -- Creates an object of type Reference_Control_Type pointing to the
524 -- container, and increments the Lock. Finalization of this object will
525 -- decrement the Lock.
526
527 function Get_Element_Access
528 (Position : Cursor) return not null Element_Access;
529 -- Returns a pointer to the element designated by Position.
7d2e68b3 530
4c2d6a70
AC
531 No_Element : constant Cursor := Cursor'(null, Index_Type'First);
532
e9f97e79
AC
533 Empty_Vector : constant Vector := (Controlled with others => <>);
534
e2441021
AC
535 type Iterator is new Limited_Controlled and
536 Vector_Iterator_Interfaces.Reversible_Iterator with
537 record
538 Container : Vector_Access;
539 Index : Index_Type'Base;
e9f97e79
AC
540 end record
541 with Disable_Controlled => not T_Check;
e2441021
AC
542
543 overriding procedure Finalize (Object : in out Iterator);
544
545 overriding function First (Object : Iterator) return Cursor;
546 overriding function Last (Object : Iterator) return Cursor;
547
548 overriding function Next
549 (Object : Iterator;
550 Position : Cursor) return Cursor;
551
552 overriding function Previous
553 (Object : Iterator;
554 Position : Cursor) return Cursor;
555
4c2d6a70 556end Ada.Containers.Indefinite_Vectors;
This page took 5.387056 seconds and 6 git commands to generate.