annotate gcc/ada/libgnat/a-coinve.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT LIBRARY COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
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 --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 2004-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- This specification is derived from the Ada Reference Manual for use with --
kono
parents:
diff changeset
12 -- GNAT. The copyright notice above, and the license provisions that follow --
kono
parents:
diff changeset
13 -- apply solely to the contents of the part following the private keyword. --
kono
parents:
diff changeset
14 -- --
kono
parents:
diff changeset
15 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
16 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
17 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
18 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
19 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
20 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
23 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
24 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
25 -- --
kono
parents:
diff changeset
26 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
27 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
28 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
29 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
30 -- --
kono
parents:
diff changeset
31 -- This unit was originally developed by Matthew J Heaney. --
kono
parents:
diff changeset
32 ------------------------------------------------------------------------------
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 with Ada.Iterator_Interfaces;
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 with Ada.Containers.Helpers;
kono
parents:
diff changeset
37 private with Ada.Finalization;
kono
parents:
diff changeset
38 private with Ada.Streams;
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 generic
kono
parents:
diff changeset
41 type Index_Type is range <>;
kono
parents:
diff changeset
42 type Element_Type (<>) is private;
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 with function "=" (Left, Right : Element_Type) return Boolean is <>;
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 package Ada.Containers.Indefinite_Vectors is
kono
parents:
diff changeset
47 pragma Annotate (CodePeer, Skip_Analysis);
kono
parents:
diff changeset
48 pragma Preelaborate;
kono
parents:
diff changeset
49 pragma Remote_Types;
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 subtype Extended_Index is Index_Type'Base
kono
parents:
diff changeset
52 range Index_Type'First - 1 ..
kono
parents:
diff changeset
53 Index_Type'Min (Index_Type'Base'Last - 1, Index_Type'Last) + 1;
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 No_Index : constant Extended_Index := Extended_Index'First;
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 type Vector is tagged private
kono
parents:
diff changeset
58 with
kono
parents:
diff changeset
59 Constant_Indexing => Constant_Reference,
kono
parents:
diff changeset
60 Variable_Indexing => Reference,
kono
parents:
diff changeset
61 Default_Iterator => Iterate,
kono
parents:
diff changeset
62 Iterator_Element => Element_Type;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 pragma Preelaborable_Initialization (Vector);
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 type Cursor is private;
kono
parents:
diff changeset
67 pragma Preelaborable_Initialization (Cursor);
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 Empty_Vector : constant Vector;
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 No_Element : constant Cursor;
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 function Has_Element (Position : Cursor) return Boolean;
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 package Vector_Iterator_Interfaces is new
kono
parents:
diff changeset
76 Ada.Iterator_Interfaces (Cursor, Has_Element);
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 overriding function "=" (Left, Right : Vector) return Boolean;
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 function To_Vector (Length : Count_Type) return Vector;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 function To_Vector
kono
parents:
diff changeset
83 (New_Item : Element_Type;
kono
parents:
diff changeset
84 Length : Count_Type) return Vector;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 function "&" (Left, Right : Vector) return Vector;
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 function "&" (Left : Vector; Right : Element_Type) return Vector;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 function "&" (Left : Element_Type; Right : Vector) return Vector;
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 function "&" (Left, Right : Element_Type) return Vector;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 function Capacity (Container : Vector) return Count_Type;
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 procedure Reserve_Capacity
kono
parents:
diff changeset
97 (Container : in out Vector;
kono
parents:
diff changeset
98 Capacity : Count_Type);
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 function Length (Container : Vector) return Count_Type;
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 procedure Set_Length
kono
parents:
diff changeset
103 (Container : in out Vector;
kono
parents:
diff changeset
104 Length : Count_Type);
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 function Is_Empty (Container : Vector) return Boolean;
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 procedure Clear (Container : in out Vector);
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 type Constant_Reference_Type
kono
parents:
diff changeset
111 (Element : not null access constant Element_Type) is private
kono
parents:
diff changeset
112 with
kono
parents:
diff changeset
113 Implicit_Dereference => Element;
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 type Reference_Type (Element : not null access Element_Type) is private
kono
parents:
diff changeset
116 with
kono
parents:
diff changeset
117 Implicit_Dereference => Element;
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 function Constant_Reference
kono
parents:
diff changeset
120 (Container : aliased Vector;
kono
parents:
diff changeset
121 Position : Cursor) return Constant_Reference_Type;
kono
parents:
diff changeset
122 pragma Inline (Constant_Reference);
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 function Reference
kono
parents:
diff changeset
125 (Container : aliased in out Vector;
kono
parents:
diff changeset
126 Position : Cursor) return Reference_Type;
kono
parents:
diff changeset
127 pragma Inline (Reference);
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 function Constant_Reference
kono
parents:
diff changeset
130 (Container : aliased Vector;
kono
parents:
diff changeset
131 Index : Index_Type) return Constant_Reference_Type;
kono
parents:
diff changeset
132 pragma Inline (Constant_Reference);
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 function Reference
kono
parents:
diff changeset
135 (Container : aliased in out Vector;
kono
parents:
diff changeset
136 Index : Index_Type) return Reference_Type;
kono
parents:
diff changeset
137 pragma Inline (Reference);
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 function To_Cursor
kono
parents:
diff changeset
140 (Container : Vector;
kono
parents:
diff changeset
141 Index : Extended_Index) return Cursor;
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 function To_Index (Position : Cursor) return Extended_Index;
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 function Element
kono
parents:
diff changeset
146 (Container : Vector;
kono
parents:
diff changeset
147 Index : Index_Type) return Element_Type;
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 function Element (Position : Cursor) return Element_Type;
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 procedure Replace_Element
kono
parents:
diff changeset
152 (Container : in out Vector;
kono
parents:
diff changeset
153 Index : Index_Type;
kono
parents:
diff changeset
154 New_Item : Element_Type);
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 procedure Replace_Element
kono
parents:
diff changeset
157 (Container : in out Vector;
kono
parents:
diff changeset
158 Position : Cursor;
kono
parents:
diff changeset
159 New_Item : Element_Type);
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 procedure Query_Element
kono
parents:
diff changeset
162 (Container : Vector;
kono
parents:
diff changeset
163 Index : Index_Type;
kono
parents:
diff changeset
164 Process : not null access procedure (Element : Element_Type));
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 procedure Query_Element
kono
parents:
diff changeset
167 (Position : Cursor;
kono
parents:
diff changeset
168 Process : not null access procedure (Element : Element_Type));
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 procedure Update_Element
kono
parents:
diff changeset
171 (Container : in out Vector;
kono
parents:
diff changeset
172 Index : Index_Type;
kono
parents:
diff changeset
173 Process : not null access procedure (Element : in out Element_Type));
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 procedure Update_Element
kono
parents:
diff changeset
176 (Container : in out Vector;
kono
parents:
diff changeset
177 Position : Cursor;
kono
parents:
diff changeset
178 Process : not null access procedure (Element : in out Element_Type));
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 procedure Assign (Target : in out Vector; Source : Vector);
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 function Copy (Source : Vector; Capacity : Count_Type := 0) return Vector;
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 procedure Move (Target : in out Vector; Source : in out Vector);
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 procedure Insert
kono
parents:
diff changeset
187 (Container : in out Vector;
kono
parents:
diff changeset
188 Before : Extended_Index;
kono
parents:
diff changeset
189 New_Item : Vector);
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 procedure Insert
kono
parents:
diff changeset
192 (Container : in out Vector;
kono
parents:
diff changeset
193 Before : Cursor;
kono
parents:
diff changeset
194 New_Item : Vector);
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 procedure Insert
kono
parents:
diff changeset
197 (Container : in out Vector;
kono
parents:
diff changeset
198 Before : Cursor;
kono
parents:
diff changeset
199 New_Item : Vector;
kono
parents:
diff changeset
200 Position : out Cursor);
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 procedure Insert
kono
parents:
diff changeset
203 (Container : in out Vector;
kono
parents:
diff changeset
204 Before : Extended_Index;
kono
parents:
diff changeset
205 New_Item : Element_Type;
kono
parents:
diff changeset
206 Count : Count_Type := 1);
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 procedure Insert
kono
parents:
diff changeset
209 (Container : in out Vector;
kono
parents:
diff changeset
210 Before : Cursor;
kono
parents:
diff changeset
211 New_Item : Element_Type;
kono
parents:
diff changeset
212 Count : Count_Type := 1);
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 procedure Insert
kono
parents:
diff changeset
215 (Container : in out Vector;
kono
parents:
diff changeset
216 Before : Cursor;
kono
parents:
diff changeset
217 New_Item : Element_Type;
kono
parents:
diff changeset
218 Position : out Cursor;
kono
parents:
diff changeset
219 Count : Count_Type := 1);
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221 procedure Prepend
kono
parents:
diff changeset
222 (Container : in out Vector;
kono
parents:
diff changeset
223 New_Item : Vector);
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 procedure Prepend
kono
parents:
diff changeset
226 (Container : in out Vector;
kono
parents:
diff changeset
227 New_Item : Element_Type;
kono
parents:
diff changeset
228 Count : Count_Type := 1);
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 procedure Append
kono
parents:
diff changeset
231 (Container : in out Vector;
kono
parents:
diff changeset
232 New_Item : Vector);
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 procedure Append
kono
parents:
diff changeset
235 (Container : in out Vector;
kono
parents:
diff changeset
236 New_Item : Element_Type;
kono
parents:
diff changeset
237 Count : Count_Type := 1);
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 procedure Insert_Space
kono
parents:
diff changeset
240 (Container : in out Vector;
kono
parents:
diff changeset
241 Before : Extended_Index;
kono
parents:
diff changeset
242 Count : Count_Type := 1);
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 procedure Insert_Space
kono
parents:
diff changeset
245 (Container : in out Vector;
kono
parents:
diff changeset
246 Before : Cursor;
kono
parents:
diff changeset
247 Position : out Cursor;
kono
parents:
diff changeset
248 Count : Count_Type := 1);
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 procedure Delete
kono
parents:
diff changeset
251 (Container : in out Vector;
kono
parents:
diff changeset
252 Index : Extended_Index;
kono
parents:
diff changeset
253 Count : Count_Type := 1);
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 procedure Delete
kono
parents:
diff changeset
256 (Container : in out Vector;
kono
parents:
diff changeset
257 Position : in out Cursor;
kono
parents:
diff changeset
258 Count : Count_Type := 1);
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 procedure Delete_First
kono
parents:
diff changeset
261 (Container : in out Vector;
kono
parents:
diff changeset
262 Count : Count_Type := 1);
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 procedure Delete_Last
kono
parents:
diff changeset
265 (Container : in out Vector;
kono
parents:
diff changeset
266 Count : Count_Type := 1);
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 procedure Reverse_Elements (Container : in out Vector);
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 procedure Swap (Container : in out Vector; I, J : Index_Type);
kono
parents:
diff changeset
271
kono
parents:
diff changeset
272 procedure Swap (Container : in out Vector; I, J : Cursor);
kono
parents:
diff changeset
273
kono
parents:
diff changeset
274 function First_Index (Container : Vector) return Index_Type;
kono
parents:
diff changeset
275
kono
parents:
diff changeset
276 function First (Container : Vector) return Cursor;
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278 function First_Element (Container : Vector) return Element_Type;
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 function Last_Index (Container : Vector) return Extended_Index;
kono
parents:
diff changeset
281
kono
parents:
diff changeset
282 function Last (Container : Vector) return Cursor;
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 function Last_Element (Container : Vector) return Element_Type;
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286 function Next (Position : Cursor) return Cursor;
kono
parents:
diff changeset
287
kono
parents:
diff changeset
288 procedure Next (Position : in out Cursor);
kono
parents:
diff changeset
289
kono
parents:
diff changeset
290 function Previous (Position : Cursor) return Cursor;
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 procedure Previous (Position : in out Cursor);
kono
parents:
diff changeset
293
kono
parents:
diff changeset
294 function Find_Index
kono
parents:
diff changeset
295 (Container : Vector;
kono
parents:
diff changeset
296 Item : Element_Type;
kono
parents:
diff changeset
297 Index : Index_Type := Index_Type'First) return Extended_Index;
kono
parents:
diff changeset
298
kono
parents:
diff changeset
299 function Find
kono
parents:
diff changeset
300 (Container : Vector;
kono
parents:
diff changeset
301 Item : Element_Type;
kono
parents:
diff changeset
302 Position : Cursor := No_Element) return Cursor;
kono
parents:
diff changeset
303
kono
parents:
diff changeset
304 function Reverse_Find_Index
kono
parents:
diff changeset
305 (Container : Vector;
kono
parents:
diff changeset
306 Item : Element_Type;
kono
parents:
diff changeset
307 Index : Index_Type := Index_Type'Last) return Extended_Index;
kono
parents:
diff changeset
308
kono
parents:
diff changeset
309 function Reverse_Find
kono
parents:
diff changeset
310 (Container : Vector;
kono
parents:
diff changeset
311 Item : Element_Type;
kono
parents:
diff changeset
312 Position : Cursor := No_Element) return Cursor;
kono
parents:
diff changeset
313
kono
parents:
diff changeset
314 function Contains
kono
parents:
diff changeset
315 (Container : Vector;
kono
parents:
diff changeset
316 Item : Element_Type) return Boolean;
kono
parents:
diff changeset
317
kono
parents:
diff changeset
318 procedure Iterate
kono
parents:
diff changeset
319 (Container : Vector;
kono
parents:
diff changeset
320 Process : not null access procedure (Position : Cursor));
kono
parents:
diff changeset
321
kono
parents:
diff changeset
322 function Iterate (Container : Vector)
kono
parents:
diff changeset
323 return Vector_Iterator_Interfaces.Reversible_Iterator'class;
kono
parents:
diff changeset
324
kono
parents:
diff changeset
325 function Iterate
kono
parents:
diff changeset
326 (Container : Vector;
kono
parents:
diff changeset
327 Start : Cursor)
kono
parents:
diff changeset
328 return Vector_Iterator_Interfaces.Reversible_Iterator'class;
kono
parents:
diff changeset
329
kono
parents:
diff changeset
330 procedure Reverse_Iterate
kono
parents:
diff changeset
331 (Container : Vector;
kono
parents:
diff changeset
332 Process : not null access procedure (Position : Cursor));
kono
parents:
diff changeset
333
kono
parents:
diff changeset
334 generic
kono
parents:
diff changeset
335 with function "<" (Left, Right : Element_Type) return Boolean is <>;
kono
parents:
diff changeset
336 package Generic_Sorting is
kono
parents:
diff changeset
337
kono
parents:
diff changeset
338 function Is_Sorted (Container : Vector) return Boolean;
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 procedure Sort (Container : in out Vector);
kono
parents:
diff changeset
341
kono
parents:
diff changeset
342 procedure Merge (Target : in out Vector; Source : in out Vector);
kono
parents:
diff changeset
343
kono
parents:
diff changeset
344 end Generic_Sorting;
kono
parents:
diff changeset
345
kono
parents:
diff changeset
346 private
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 pragma Inline (Append);
kono
parents:
diff changeset
349 pragma Inline (First_Index);
kono
parents:
diff changeset
350 pragma Inline (Last_Index);
kono
parents:
diff changeset
351 pragma Inline (Element);
kono
parents:
diff changeset
352 pragma Inline (First_Element);
kono
parents:
diff changeset
353 pragma Inline (Last_Element);
kono
parents:
diff changeset
354 pragma Inline (Query_Element);
kono
parents:
diff changeset
355 pragma Inline (Update_Element);
kono
parents:
diff changeset
356 pragma Inline (Replace_Element);
kono
parents:
diff changeset
357 pragma Inline (Is_Empty);
kono
parents:
diff changeset
358 pragma Inline (Contains);
kono
parents:
diff changeset
359 pragma Inline (Next);
kono
parents:
diff changeset
360 pragma Inline (Previous);
kono
parents:
diff changeset
361
kono
parents:
diff changeset
362 use Ada.Containers.Helpers;
kono
parents:
diff changeset
363 package Implementation is new Generic_Implementation;
kono
parents:
diff changeset
364 use Implementation;
kono
parents:
diff changeset
365
kono
parents:
diff changeset
366 type Element_Access is access Element_Type;
kono
parents:
diff changeset
367
kono
parents:
diff changeset
368 type Elements_Array is array (Index_Type range <>) of Element_Access;
kono
parents:
diff changeset
369 function "=" (L, R : Elements_Array) return Boolean is abstract;
kono
parents:
diff changeset
370
kono
parents:
diff changeset
371 type Elements_Type (Last : Extended_Index) is limited record
kono
parents:
diff changeset
372 EA : Elements_Array (Index_Type'First .. Last);
kono
parents:
diff changeset
373 end record;
kono
parents:
diff changeset
374
kono
parents:
diff changeset
375 type Elements_Access is access all Elements_Type;
kono
parents:
diff changeset
376
kono
parents:
diff changeset
377 use Finalization;
kono
parents:
diff changeset
378 use Streams;
kono
parents:
diff changeset
379
kono
parents:
diff changeset
380 type Vector is new Controlled with record
kono
parents:
diff changeset
381 Elements : Elements_Access := null;
kono
parents:
diff changeset
382 Last : Extended_Index := No_Index;
kono
parents:
diff changeset
383 TC : aliased Tamper_Counts;
kono
parents:
diff changeset
384 end record;
kono
parents:
diff changeset
385
kono
parents:
diff changeset
386 overriding procedure Adjust (Container : in out Vector);
kono
parents:
diff changeset
387 overriding procedure Finalize (Container : in out Vector);
kono
parents:
diff changeset
388
kono
parents:
diff changeset
389 procedure Write
kono
parents:
diff changeset
390 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
391 Container : Vector);
kono
parents:
diff changeset
392
kono
parents:
diff changeset
393 for Vector'Write use Write;
kono
parents:
diff changeset
394
kono
parents:
diff changeset
395 procedure Read
kono
parents:
diff changeset
396 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
397 Container : out Vector);
kono
parents:
diff changeset
398
kono
parents:
diff changeset
399 for Vector'Read use Read;
kono
parents:
diff changeset
400
kono
parents:
diff changeset
401 type Vector_Access is access all Vector;
kono
parents:
diff changeset
402 for Vector_Access'Storage_Size use 0;
kono
parents:
diff changeset
403
kono
parents:
diff changeset
404 type Cursor is record
kono
parents:
diff changeset
405 Container : Vector_Access;
kono
parents:
diff changeset
406 Index : Index_Type := Index_Type'First;
kono
parents:
diff changeset
407 end record;
kono
parents:
diff changeset
408
kono
parents:
diff changeset
409 procedure Read
kono
parents:
diff changeset
410 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
411 Position : out Cursor);
kono
parents:
diff changeset
412
kono
parents:
diff changeset
413 for Cursor'Read use Read;
kono
parents:
diff changeset
414
kono
parents:
diff changeset
415 procedure Write
kono
parents:
diff changeset
416 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
417 Position : Cursor);
kono
parents:
diff changeset
418
kono
parents:
diff changeset
419 for Cursor'Write use Write;
kono
parents:
diff changeset
420
kono
parents:
diff changeset
421 subtype Reference_Control_Type is Implementation.Reference_Control_Type;
kono
parents:
diff changeset
422 -- It is necessary to rename this here, so that the compiler can find it
kono
parents:
diff changeset
423
kono
parents:
diff changeset
424 type Constant_Reference_Type
kono
parents:
diff changeset
425 (Element : not null access constant Element_Type) is
kono
parents:
diff changeset
426 record
kono
parents:
diff changeset
427 Control : Reference_Control_Type :=
kono
parents:
diff changeset
428 raise Program_Error with "uninitialized reference";
kono
parents:
diff changeset
429 -- The RM says, "The default initialization of an object of
kono
parents:
diff changeset
430 -- type Constant_Reference_Type or Reference_Type propagates
kono
parents:
diff changeset
431 -- Program_Error."
kono
parents:
diff changeset
432 end record;
kono
parents:
diff changeset
433
kono
parents:
diff changeset
434 procedure Write
kono
parents:
diff changeset
435 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
436 Item : Constant_Reference_Type);
kono
parents:
diff changeset
437
kono
parents:
diff changeset
438 for Constant_Reference_Type'Write use Write;
kono
parents:
diff changeset
439
kono
parents:
diff changeset
440 procedure Read
kono
parents:
diff changeset
441 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
442 Item : out Constant_Reference_Type);
kono
parents:
diff changeset
443
kono
parents:
diff changeset
444 for Constant_Reference_Type'Read use Read;
kono
parents:
diff changeset
445
kono
parents:
diff changeset
446 type Reference_Type
kono
parents:
diff changeset
447 (Element : not null access Element_Type) is
kono
parents:
diff changeset
448 record
kono
parents:
diff changeset
449 Control : Reference_Control_Type :=
kono
parents:
diff changeset
450 raise Program_Error with "uninitialized reference";
kono
parents:
diff changeset
451 -- The RM says, "The default initialization of an object of
kono
parents:
diff changeset
452 -- type Constant_Reference_Type or Reference_Type propagates
kono
parents:
diff changeset
453 -- Program_Error."
kono
parents:
diff changeset
454 end record;
kono
parents:
diff changeset
455
kono
parents:
diff changeset
456 procedure Write
kono
parents:
diff changeset
457 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
458 Item : Reference_Type);
kono
parents:
diff changeset
459
kono
parents:
diff changeset
460 for Reference_Type'Write use Write;
kono
parents:
diff changeset
461
kono
parents:
diff changeset
462 procedure Read
kono
parents:
diff changeset
463 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
464 Item : out Reference_Type);
kono
parents:
diff changeset
465
kono
parents:
diff changeset
466 for Reference_Type'Read use Read;
kono
parents:
diff changeset
467
kono
parents:
diff changeset
468 -- Three operations are used to optimize in the expansion of "for ... of"
kono
parents:
diff changeset
469 -- loops: the Next(Cursor) procedure in the visible part, and the following
kono
parents:
diff changeset
470 -- Pseudo_Reference and Get_Element_Access functions. See Exp_Ch5 for
kono
parents:
diff changeset
471 -- details.
kono
parents:
diff changeset
472
kono
parents:
diff changeset
473 function Pseudo_Reference
kono
parents:
diff changeset
474 (Container : aliased Vector'Class) return Reference_Control_Type;
kono
parents:
diff changeset
475 pragma Inline (Pseudo_Reference);
kono
parents:
diff changeset
476 -- Creates an object of type Reference_Control_Type pointing to the
kono
parents:
diff changeset
477 -- container, and increments the Lock. Finalization of this object will
kono
parents:
diff changeset
478 -- decrement the Lock.
kono
parents:
diff changeset
479
kono
parents:
diff changeset
480 function Get_Element_Access
kono
parents:
diff changeset
481 (Position : Cursor) return not null Element_Access;
kono
parents:
diff changeset
482 -- Returns a pointer to the element designated by Position.
kono
parents:
diff changeset
483
kono
parents:
diff changeset
484 No_Element : constant Cursor := Cursor'(null, Index_Type'First);
kono
parents:
diff changeset
485
kono
parents:
diff changeset
486 Empty_Vector : constant Vector := (Controlled with others => <>);
kono
parents:
diff changeset
487
kono
parents:
diff changeset
488 type Iterator is new Limited_Controlled and
kono
parents:
diff changeset
489 Vector_Iterator_Interfaces.Reversible_Iterator with
kono
parents:
diff changeset
490 record
kono
parents:
diff changeset
491 Container : Vector_Access;
kono
parents:
diff changeset
492 Index : Index_Type'Base;
kono
parents:
diff changeset
493 end record
kono
parents:
diff changeset
494 with Disable_Controlled => not T_Check;
kono
parents:
diff changeset
495
kono
parents:
diff changeset
496 overriding procedure Finalize (Object : in out Iterator);
kono
parents:
diff changeset
497
kono
parents:
diff changeset
498 overriding function First (Object : Iterator) return Cursor;
kono
parents:
diff changeset
499 overriding function Last (Object : Iterator) return Cursor;
kono
parents:
diff changeset
500
kono
parents:
diff changeset
501 overriding function Next
kono
parents:
diff changeset
502 (Object : Iterator;
kono
parents:
diff changeset
503 Position : Cursor) return Cursor;
kono
parents:
diff changeset
504
kono
parents:
diff changeset
505 overriding function Previous
kono
parents:
diff changeset
506 (Object : Iterator;
kono
parents:
diff changeset
507 Position : Cursor) return Cursor;
kono
parents:
diff changeset
508
kono
parents:
diff changeset
509 end Ada.Containers.Indefinite_Vectors;