annotate gcc/ada/libgnat/a-cborse.ads @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
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 . B O U N D E D _ O R D E R E D _ S E T S --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 2004-2019, 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.Containers.Red_Black_Trees;
kono
parents:
diff changeset
38 private with Ada.Streams;
kono
parents:
diff changeset
39 private with Ada.Finalization;
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 generic
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 with function "=" (Left, Right : Element_Type) return Boolean is <>;
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 package Ada.Containers.Bounded_Ordered_Sets is
kono
parents:
diff changeset
48 pragma Annotate (CodePeer, Skip_Analysis);
kono
parents:
diff changeset
49 pragma Pure;
kono
parents:
diff changeset
50 pragma Remote_Types;
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 function Equivalent_Elements (Left, Right : Element_Type) return Boolean;
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 type Set (Capacity : Count_Type) is tagged private
kono
parents:
diff changeset
55 with Constant_Indexing => Constant_Reference,
kono
parents:
diff changeset
56 Default_Iterator => Iterate,
kono
parents:
diff changeset
57 Iterator_Element => Element_Type;
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 pragma Preelaborable_Initialization (Set);
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 type Cursor is private;
kono
parents:
diff changeset
62 pragma Preelaborable_Initialization (Cursor);
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 Empty_Set : constant Set;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 No_Element : constant Cursor;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 function Has_Element (Position : Cursor) return Boolean;
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 package Set_Iterator_Interfaces is new
kono
parents:
diff changeset
71 Ada.Iterator_Interfaces (Cursor, Has_Element);
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 function "=" (Left, Right : Set) return Boolean;
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 function Equivalent_Sets (Left, Right : Set) return Boolean;
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 function To_Set (New_Item : Element_Type) return Set;
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 function Length (Container : Set) return Count_Type;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 function Is_Empty (Container : Set) return Boolean;
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 procedure Clear (Container : in out Set);
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 function Element (Position : Cursor) return Element_Type;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 procedure Replace_Element
kono
parents:
diff changeset
88 (Container : in out Set;
kono
parents:
diff changeset
89 Position : Cursor;
kono
parents:
diff changeset
90 New_Item : Element_Type);
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 procedure Query_Element
kono
parents:
diff changeset
93 (Position : Cursor;
kono
parents:
diff changeset
94 Process : not null access procedure (Element : Element_Type));
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 type Constant_Reference_Type
kono
parents:
diff changeset
97 (Element : not null access constant Element_Type) is
kono
parents:
diff changeset
98 private
kono
parents:
diff changeset
99 with
kono
parents:
diff changeset
100 Implicit_Dereference => Element;
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 function Constant_Reference
kono
parents:
diff changeset
103 (Container : aliased Set;
kono
parents:
diff changeset
104 Position : Cursor) return Constant_Reference_Type;
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 procedure Assign (Target : in out Set; Source : Set);
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 function Copy (Source : Set; Capacity : Count_Type := 0) return Set;
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 procedure Move (Target : in out Set; Source : in out Set);
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 procedure Insert
kono
parents:
diff changeset
113 (Container : in out Set;
kono
parents:
diff changeset
114 New_Item : Element_Type;
kono
parents:
diff changeset
115 Position : out Cursor;
kono
parents:
diff changeset
116 Inserted : out Boolean);
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 procedure Insert
kono
parents:
diff changeset
119 (Container : in out Set;
kono
parents:
diff changeset
120 New_Item : Element_Type);
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 procedure Include
kono
parents:
diff changeset
123 (Container : in out Set;
kono
parents:
diff changeset
124 New_Item : Element_Type);
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 procedure Replace
kono
parents:
diff changeset
127 (Container : in out Set;
kono
parents:
diff changeset
128 New_Item : Element_Type);
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 procedure Exclude
kono
parents:
diff changeset
131 (Container : in out Set;
kono
parents:
diff changeset
132 Item : Element_Type);
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 procedure Delete
kono
parents:
diff changeset
135 (Container : in out Set;
kono
parents:
diff changeset
136 Item : Element_Type);
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 procedure Delete
kono
parents:
diff changeset
139 (Container : in out Set;
kono
parents:
diff changeset
140 Position : in out Cursor);
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 procedure Delete_First (Container : in out Set);
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 procedure Delete_Last (Container : in out Set);
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 procedure Union (Target : in out Set; Source : Set);
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 function Union (Left, Right : Set) return Set;
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 function "or" (Left, Right : Set) return Set renames Union;
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 procedure Intersection (Target : in out Set; Source : Set);
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 function Intersection (Left, Right : Set) return Set;
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 function "and" (Left, Right : Set) return Set renames Intersection;
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 procedure Difference (Target : in out Set; Source : Set);
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 function Difference (Left, Right : Set) return Set;
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 function "-" (Left, Right : Set) return Set renames Difference;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 procedure Symmetric_Difference (Target : in out Set; Source : Set);
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 function Symmetric_Difference (Left, Right : Set) return Set;
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 function "xor" (Left, Right : Set) return Set renames Symmetric_Difference;
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 function Overlap (Left, Right : Set) return Boolean;
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 function Is_Subset (Subset : Set; Of_Set : Set) return Boolean;
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 function First (Container : Set) return Cursor;
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 function First_Element (Container : Set) return Element_Type;
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 function Last (Container : Set) return Cursor;
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 function Last_Element (Container : Set) return Element_Type;
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 function Next (Position : Cursor) return Cursor;
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 procedure Next (Position : in out Cursor);
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 function Previous (Position : Cursor) return Cursor;
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 procedure Previous (Position : in out Cursor);
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 function Find (Container : Set; Item : Element_Type) return Cursor;
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 function Floor (Container : Set; Item : Element_Type) return Cursor;
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 function Ceiling (Container : Set; Item : Element_Type) return Cursor;
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 function Contains (Container : Set; Item : Element_Type) return Boolean;
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 function "<" (Left, Right : Cursor) return Boolean;
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 function ">" (Left, Right : Cursor) return Boolean;
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 function "<" (Left : Cursor; Right : Element_Type) return Boolean;
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 function ">" (Left : Cursor; Right : Element_Type) return Boolean;
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 function "<" (Left : Element_Type; Right : Cursor) return Boolean;
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 function ">" (Left : Element_Type; Right : Cursor) return Boolean;
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 procedure Iterate
kono
parents:
diff changeset
211 (Container : Set;
kono
parents:
diff changeset
212 Process : not null access procedure (Position : Cursor));
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 procedure Reverse_Iterate
kono
parents:
diff changeset
215 (Container : Set;
kono
parents:
diff changeset
216 Process : not null access procedure (Position : Cursor));
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 function Iterate
kono
parents:
diff changeset
219 (Container : Set)
kono
parents:
diff changeset
220 return Set_Iterator_Interfaces.Reversible_Iterator'class;
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 function Iterate
kono
parents:
diff changeset
223 (Container : Set;
kono
parents:
diff changeset
224 Start : Cursor)
kono
parents:
diff changeset
225 return Set_Iterator_Interfaces.Reversible_Iterator'class;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 generic
kono
parents:
diff changeset
228 type Key_Type (<>) is private;
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 with function Key (Element : Element_Type) return Key_Type;
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 with function "<" (Left, Right : Key_Type) return Boolean is <>;
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 package Generic_Keys is
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
kono
parents:
diff changeset
237
kono
parents:
diff changeset
238 function Key (Position : Cursor) return Key_Type;
kono
parents:
diff changeset
239
kono
parents:
diff changeset
240 function Element (Container : Set; Key : Key_Type) return Element_Type;
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 procedure Replace
kono
parents:
diff changeset
243 (Container : in out Set;
kono
parents:
diff changeset
244 Key : Key_Type;
kono
parents:
diff changeset
245 New_Item : Element_Type);
kono
parents:
diff changeset
246
kono
parents:
diff changeset
247 procedure Exclude (Container : in out Set; Key : Key_Type);
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 procedure Delete (Container : in out Set; Key : Key_Type);
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 function Find (Container : Set; Key : Key_Type) return Cursor;
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 function Floor (Container : Set; Key : Key_Type) return Cursor;
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 function Ceiling (Container : Set; Key : Key_Type) return Cursor;
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 function Contains (Container : Set; Key : Key_Type) return Boolean;
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 procedure Update_Element_Preserving_Key
kono
parents:
diff changeset
260 (Container : in out Set;
kono
parents:
diff changeset
261 Position : Cursor;
kono
parents:
diff changeset
262 Process : not null access
kono
parents:
diff changeset
263 procedure (Element : in out Element_Type));
kono
parents:
diff changeset
264
kono
parents:
diff changeset
265 type Reference_Type (Element : not null access Element_Type) is private
kono
parents:
diff changeset
266 with
kono
parents:
diff changeset
267 Implicit_Dereference => Element;
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 function Reference_Preserving_Key
kono
parents:
diff changeset
270 (Container : aliased in out Set;
kono
parents:
diff changeset
271 Position : Cursor) return Reference_Type;
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 function Constant_Reference
kono
parents:
diff changeset
274 (Container : aliased Set;
kono
parents:
diff changeset
275 Key : Key_Type) return Constant_Reference_Type;
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 function Reference_Preserving_Key
kono
parents:
diff changeset
278 (Container : aliased in out Set;
kono
parents:
diff changeset
279 Key : Key_Type) return Reference_Type;
kono
parents:
diff changeset
280
kono
parents:
diff changeset
281 private
kono
parents:
diff changeset
282 type Set_Access is access all Set;
kono
parents:
diff changeset
283 for Set_Access'Storage_Size use 0;
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285 type Key_Access is access all Key_Type;
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 use Ada.Streams;
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 package Impl is new Helpers.Generic_Implementation;
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291 type Reference_Control_Type is
kono
parents:
diff changeset
292 new Impl.Reference_Control_Type with
kono
parents:
diff changeset
293 record
kono
parents:
diff changeset
294 Container : Set_Access;
kono
parents:
diff changeset
295 Pos : Cursor;
kono
parents:
diff changeset
296 Old_Key : Key_Access;
kono
parents:
diff changeset
297 end record;
kono
parents:
diff changeset
298
kono
parents:
diff changeset
299 overriding procedure Finalize (Control : in out Reference_Control_Type);
kono
parents:
diff changeset
300 pragma Inline (Finalize);
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 type Reference_Type (Element : not null access Element_Type) is record
kono
parents:
diff changeset
303 Control : Reference_Control_Type;
kono
parents:
diff changeset
304 end record;
kono
parents:
diff changeset
305
kono
parents:
diff changeset
306 procedure Read
kono
parents:
diff changeset
307 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
308 Item : out Reference_Type);
kono
parents:
diff changeset
309
kono
parents:
diff changeset
310 for Reference_Type'Read use Read;
kono
parents:
diff changeset
311
kono
parents:
diff changeset
312 procedure Write
kono
parents:
diff changeset
313 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
314 Item : Reference_Type);
kono
parents:
diff changeset
315
kono
parents:
diff changeset
316 for Reference_Type'Write use Write;
kono
parents:
diff changeset
317
kono
parents:
diff changeset
318 end Generic_Keys;
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 private
kono
parents:
diff changeset
321
kono
parents:
diff changeset
322 pragma Inline (Next);
kono
parents:
diff changeset
323 pragma Inline (Previous);
kono
parents:
diff changeset
324
kono
parents:
diff changeset
325 type Node_Type is record
kono
parents:
diff changeset
326 Parent : Count_Type;
kono
parents:
diff changeset
327 Left : Count_Type;
kono
parents:
diff changeset
328 Right : Count_Type;
kono
parents:
diff changeset
329 Color : Red_Black_Trees.Color_Type := Red_Black_Trees.Red;
kono
parents:
diff changeset
330 Element : aliased Element_Type;
kono
parents:
diff changeset
331 end record;
kono
parents:
diff changeset
332
kono
parents:
diff changeset
333 package Tree_Types is
kono
parents:
diff changeset
334 new Red_Black_Trees.Generic_Bounded_Tree_Types (Node_Type);
kono
parents:
diff changeset
335
kono
parents:
diff changeset
336 type Set (Capacity : Count_Type) is
kono
parents:
diff changeset
337 new Tree_Types.Tree_Type (Capacity) with null record;
kono
parents:
diff changeset
338
kono
parents:
diff changeset
339 use Tree_Types, Tree_Types.Implementation;
kono
parents:
diff changeset
340 use Ada.Finalization;
kono
parents:
diff changeset
341 use Ada.Streams;
kono
parents:
diff changeset
342
kono
parents:
diff changeset
343 procedure Write
kono
parents:
diff changeset
344 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
345 Container : Set);
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347 for Set'Write use Write;
kono
parents:
diff changeset
348
kono
parents:
diff changeset
349 procedure Read
kono
parents:
diff changeset
350 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
351 Container : out Set);
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 for Set'Read use Read;
kono
parents:
diff changeset
354
kono
parents:
diff changeset
355 type Set_Access is access all Set;
kono
parents:
diff changeset
356 for Set_Access'Storage_Size use 0;
kono
parents:
diff changeset
357
kono
parents:
diff changeset
358 -- Note: If a Cursor object has no explicit initialization expression,
kono
parents:
diff changeset
359 -- it must default initialize to the same value as constant No_Element.
kono
parents:
diff changeset
360 -- The Node component of type Cursor has scalar type Count_Type, so it
kono
parents:
diff changeset
361 -- requires an explicit initialization expression of its own declaration,
kono
parents:
diff changeset
362 -- in order for objects of record type Cursor to properly initialize.
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 type Cursor is record
kono
parents:
diff changeset
365 Container : Set_Access;
kono
parents:
diff changeset
366 Node : Count_Type := 0;
kono
parents:
diff changeset
367 end record;
kono
parents:
diff changeset
368
kono
parents:
diff changeset
369 procedure Write
kono
parents:
diff changeset
370 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
371 Item : Cursor);
kono
parents:
diff changeset
372
kono
parents:
diff changeset
373 for Cursor'Write use Write;
kono
parents:
diff changeset
374
kono
parents:
diff changeset
375 procedure Read
kono
parents:
diff changeset
376 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
377 Item : out Cursor);
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 for Cursor'Read use Read;
kono
parents:
diff changeset
380
kono
parents:
diff changeset
381 subtype Reference_Control_Type is Implementation.Reference_Control_Type;
kono
parents:
diff changeset
382 -- It is necessary to rename this here, so that the compiler can find it
kono
parents:
diff changeset
383
kono
parents:
diff changeset
384 type Constant_Reference_Type
kono
parents:
diff changeset
385 (Element : not null access constant Element_Type) is
kono
parents:
diff changeset
386 record
kono
parents:
diff changeset
387 Control : Reference_Control_Type :=
kono
parents:
diff changeset
388 raise Program_Error with "uninitialized reference";
kono
parents:
diff changeset
389 -- The RM says, "The default initialization of an object of
kono
parents:
diff changeset
390 -- type Constant_Reference_Type or Reference_Type propagates
kono
parents:
diff changeset
391 -- Program_Error."
kono
parents:
diff changeset
392 end record;
kono
parents:
diff changeset
393
kono
parents:
diff changeset
394 procedure Read
kono
parents:
diff changeset
395 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
396 Item : out Constant_Reference_Type);
kono
parents:
diff changeset
397
kono
parents:
diff changeset
398 for Constant_Reference_Type'Read use Read;
kono
parents:
diff changeset
399
kono
parents:
diff changeset
400 procedure Write
kono
parents:
diff changeset
401 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
402 Item : Constant_Reference_Type);
kono
parents:
diff changeset
403
kono
parents:
diff changeset
404 for Constant_Reference_Type'Write use Write;
kono
parents:
diff changeset
405
kono
parents:
diff changeset
406 -- Three operations are used to optimize in the expansion of "for ... of"
kono
parents:
diff changeset
407 -- loops: the Next(Cursor) procedure in the visible part, and the following
kono
parents:
diff changeset
408 -- Pseudo_Reference and Get_Element_Access functions. See Sem_Ch5 for
kono
parents:
diff changeset
409 -- details.
kono
parents:
diff changeset
410
kono
parents:
diff changeset
411 function Pseudo_Reference
kono
parents:
diff changeset
412 (Container : aliased Set'Class) return Reference_Control_Type;
kono
parents:
diff changeset
413 pragma Inline (Pseudo_Reference);
kono
parents:
diff changeset
414 -- Creates an object of type Reference_Control_Type pointing to the
kono
parents:
diff changeset
415 -- container, and increments the Lock. Finalization of this object will
kono
parents:
diff changeset
416 -- decrement the Lock.
kono
parents:
diff changeset
417
kono
parents:
diff changeset
418 type Element_Access is access all Element_Type with
kono
parents:
diff changeset
419 Storage_Size => 0;
kono
parents:
diff changeset
420
kono
parents:
diff changeset
421 function Get_Element_Access
kono
parents:
diff changeset
422 (Position : Cursor) return not null Element_Access;
kono
parents:
diff changeset
423 -- Returns a pointer to the element designated by Position.
kono
parents:
diff changeset
424
kono
parents:
diff changeset
425 Empty_Set : constant Set := Set'(Tree_Type with Capacity => 0);
kono
parents:
diff changeset
426
kono
parents:
diff changeset
427 No_Element : constant Cursor := Cursor'(null, 0);
kono
parents:
diff changeset
428
kono
parents:
diff changeset
429 type Iterator is new Limited_Controlled and
kono
parents:
diff changeset
430 Set_Iterator_Interfaces.Reversible_Iterator with
kono
parents:
diff changeset
431 record
kono
parents:
diff changeset
432 Container : Set_Access;
kono
parents:
diff changeset
433 Node : Count_Type;
kono
parents:
diff changeset
434 end record
kono
parents:
diff changeset
435 with Disable_Controlled => not T_Check;
kono
parents:
diff changeset
436
kono
parents:
diff changeset
437 overriding procedure Finalize (Object : in out Iterator);
kono
parents:
diff changeset
438
kono
parents:
diff changeset
439 overriding function First (Object : Iterator) return Cursor;
kono
parents:
diff changeset
440 overriding function Last (Object : Iterator) return Cursor;
kono
parents:
diff changeset
441
kono
parents:
diff changeset
442 overriding function Next
kono
parents:
diff changeset
443 (Object : Iterator;
kono
parents:
diff changeset
444 Position : Cursor) return Cursor;
kono
parents:
diff changeset
445
kono
parents:
diff changeset
446 overriding function Previous
kono
parents:
diff changeset
447 (Object : Iterator;
kono
parents:
diff changeset
448 Position : Cursor) return Cursor;
kono
parents:
diff changeset
449
kono
parents:
diff changeset
450 end Ada.Containers.Bounded_Ordered_Sets;