annotate gcc/ada/libgnat/a-coorse.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 . 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 -- --
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.Containers.Red_Black_Trees;
kono
parents:
diff changeset
38 private with Ada.Finalization;
kono
parents:
diff changeset
39 private with Ada.Streams;
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.Ordered_Sets is
kono
parents:
diff changeset
48 pragma Annotate (CodePeer, Skip_Analysis);
kono
parents:
diff changeset
49 pragma Preelaborate;
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 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 function Has_Element (Position : Cursor) return Boolean;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 Empty_Set : constant Set;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 No_Element : constant Cursor;
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 pragma Inline (Constant_Reference);
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 procedure Assign (Target : in out Set; Source : Set);
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 function Copy (Source : Set) return Set;
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 procedure Move (Target : in out Set; Source : in out Set);
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 procedure Insert
kono
parents:
diff changeset
114 (Container : in out Set;
kono
parents:
diff changeset
115 New_Item : Element_Type;
kono
parents:
diff changeset
116 Position : out Cursor;
kono
parents:
diff changeset
117 Inserted : out Boolean);
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 procedure Insert
kono
parents:
diff changeset
120 (Container : in out Set;
kono
parents:
diff changeset
121 New_Item : Element_Type);
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 procedure Include
kono
parents:
diff changeset
124 (Container : in out Set;
kono
parents:
diff changeset
125 New_Item : Element_Type);
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 procedure Replace
kono
parents:
diff changeset
128 (Container : in out Set;
kono
parents:
diff changeset
129 New_Item : Element_Type);
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 procedure Exclude
kono
parents:
diff changeset
132 (Container : in out Set;
kono
parents:
diff changeset
133 Item : Element_Type);
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 procedure Delete
kono
parents:
diff changeset
136 (Container : in out Set;
kono
parents:
diff changeset
137 Item : Element_Type);
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 procedure Delete
kono
parents:
diff changeset
140 (Container : in out Set;
kono
parents:
diff changeset
141 Position : in out Cursor);
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 procedure Delete_First (Container : in out Set);
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 procedure Delete_Last (Container : in out Set);
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 procedure Union (Target : in out Set; Source : Set);
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 function Union (Left, Right : Set) return Set;
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 function "or" (Left, Right : Set) return Set renames Union;
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 procedure Intersection (Target : in out Set; Source : Set);
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 function Intersection (Left, Right : Set) return Set;
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 function "and" (Left, Right : Set) return Set renames Intersection;
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 procedure Difference (Target : in out Set; Source : Set);
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 function Difference (Left, Right : Set) return Set;
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 function "-" (Left, Right : Set) return Set renames Difference;
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 procedure Symmetric_Difference (Target : in out Set; Source : Set);
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 function Symmetric_Difference (Left, Right : Set) return Set;
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 function "xor" (Left, Right : Set) return Set renames Symmetric_Difference;
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 function Overlap (Left, Right : Set) return Boolean;
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 function Is_Subset (Subset : Set; Of_Set : Set) return Boolean;
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 function First (Container : Set) return Cursor;
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 function First_Element (Container : Set) return Element_Type;
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 function Last (Container : Set) return Cursor;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 function Last_Element (Container : Set) return Element_Type;
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 function Next (Position : Cursor) return Cursor;
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 procedure Next (Position : in out Cursor);
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 function Previous (Position : Cursor) return Cursor;
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 procedure Previous (Position : in out Cursor);
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 function Find (Container : Set; Item : Element_Type) return Cursor;
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 function Floor (Container : Set; Item : Element_Type) return Cursor;
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 function Ceiling (Container : Set; Item : Element_Type) return Cursor;
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 function Contains (Container : Set; Item : Element_Type) return Boolean;
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 function "<" (Left, Right : Cursor) return Boolean;
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 function ">" (Left, Right : Cursor) return Boolean;
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 function "<" (Left : Cursor; Right : Element_Type) return Boolean;
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 function ">" (Left : Cursor; Right : Element_Type) return Boolean;
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 function "<" (Left : Element_Type; Right : Cursor) return Boolean;
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 function ">" (Left : Element_Type; Right : Cursor) return Boolean;
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 procedure Iterate
kono
parents:
diff changeset
212 (Container : Set;
kono
parents:
diff changeset
213 Process : not null access procedure (Position : Cursor));
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 procedure Reverse_Iterate
kono
parents:
diff changeset
216 (Container : Set;
kono
parents:
diff changeset
217 Process : not null access procedure (Position : Cursor));
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219 function Iterate
kono
parents:
diff changeset
220 (Container : Set)
kono
parents:
diff changeset
221 return Set_Iterator_Interfaces.Reversible_Iterator'class;
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 function Iterate
kono
parents:
diff changeset
224 (Container : Set;
kono
parents:
diff changeset
225 Start : Cursor)
kono
parents:
diff changeset
226 return Set_Iterator_Interfaces.Reversible_Iterator'class;
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 generic
kono
parents:
diff changeset
229 type Key_Type (<>) is private;
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 with function Key (Element : Element_Type) return Key_Type;
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 with function "<" (Left, Right : Key_Type) return Boolean is <>;
kono
parents:
diff changeset
234
kono
parents:
diff changeset
235 package Generic_Keys is
kono
parents:
diff changeset
236
kono
parents:
diff changeset
237 function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 function Key (Position : Cursor) return Key_Type;
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 function Element (Container : Set; Key : Key_Type) return Element_Type;
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 procedure Replace
kono
parents:
diff changeset
244 (Container : in out Set;
kono
parents:
diff changeset
245 Key : Key_Type;
kono
parents:
diff changeset
246 New_Item : Element_Type);
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 procedure Exclude (Container : in out Set; Key : Key_Type);
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 procedure Delete (Container : in out Set; Key : Key_Type);
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 function Find (Container : Set; Key : Key_Type) return Cursor;
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 function Floor (Container : Set; Key : Key_Type) return Cursor;
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 function Ceiling (Container : Set; Key : Key_Type) return Cursor;
kono
parents:
diff changeset
257
kono
parents:
diff changeset
258 function Contains (Container : Set; Key : Key_Type) return Boolean;
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 procedure Update_Element_Preserving_Key
kono
parents:
diff changeset
261 (Container : in out Set;
kono
parents:
diff changeset
262 Position : Cursor;
kono
parents:
diff changeset
263 Process : not null access
kono
parents:
diff changeset
264 procedure (Element : in out Element_Type));
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 type Reference_Type (Element : not null access Element_Type) is private
kono
parents:
diff changeset
267 with
kono
parents:
diff changeset
268 Implicit_Dereference => Element;
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 function Reference_Preserving_Key
kono
parents:
diff changeset
271 (Container : aliased in out Set;
kono
parents:
diff changeset
272 Position : Cursor) return Reference_Type;
kono
parents:
diff changeset
273
kono
parents:
diff changeset
274 function Constant_Reference
kono
parents:
diff changeset
275 (Container : aliased Set;
kono
parents:
diff changeset
276 Key : Key_Type) return Constant_Reference_Type;
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278 function Reference_Preserving_Key
kono
parents:
diff changeset
279 (Container : aliased in out Set;
kono
parents:
diff changeset
280 Key : Key_Type) return Reference_Type;
kono
parents:
diff changeset
281
kono
parents:
diff changeset
282 private
kono
parents:
diff changeset
283 type Set_Access is access all Set;
kono
parents:
diff changeset
284 for Set_Access'Storage_Size use 0;
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286 type Key_Access is access all Key_Type;
kono
parents:
diff changeset
287
kono
parents:
diff changeset
288 package Impl is new Helpers.Generic_Implementation;
kono
parents:
diff changeset
289
kono
parents:
diff changeset
290 type Reference_Control_Type is
kono
parents:
diff changeset
291 new Impl.Reference_Control_Type with
kono
parents:
diff changeset
292 record
kono
parents:
diff changeset
293 Container : Set_Access;
kono
parents:
diff changeset
294 Pos : Cursor;
kono
parents:
diff changeset
295 Old_Key : Key_Access;
kono
parents:
diff changeset
296 end record;
kono
parents:
diff changeset
297
kono
parents:
diff changeset
298 overriding procedure Finalize (Control : in out Reference_Control_Type);
kono
parents:
diff changeset
299 pragma Inline (Finalize);
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 type Reference_Type (Element : not null access Element_Type) is record
kono
parents:
diff changeset
302 Control : Reference_Control_Type;
kono
parents:
diff changeset
303 end record;
kono
parents:
diff changeset
304
kono
parents:
diff changeset
305 use Ada.Streams;
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 procedure Write
kono
parents:
diff changeset
308 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
309 Item : Reference_Type);
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 for Reference_Type'Write use Write;
kono
parents:
diff changeset
312
kono
parents:
diff changeset
313 procedure Read
kono
parents:
diff changeset
314 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
315 Item : out Reference_Type);
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 for Reference_Type'Read use Read;
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;
kono
parents:
diff changeset
326 type Node_Access is access Node_Type;
kono
parents:
diff changeset
327
kono
parents:
diff changeset
328 type Node_Type is limited record
kono
parents:
diff changeset
329 Parent : Node_Access;
kono
parents:
diff changeset
330 Left : Node_Access;
kono
parents:
diff changeset
331 Right : Node_Access;
kono
parents:
diff changeset
332 Color : Red_Black_Trees.Color_Type := Red_Black_Trees.Red;
kono
parents:
diff changeset
333 Element : aliased Element_Type;
kono
parents:
diff changeset
334 end record;
kono
parents:
diff changeset
335
kono
parents:
diff changeset
336 package Tree_Types is
kono
parents:
diff changeset
337 new Red_Black_Trees.Generic_Tree_Types (Node_Type, Node_Access);
kono
parents:
diff changeset
338
kono
parents:
diff changeset
339 type Set is new Ada.Finalization.Controlled with record
kono
parents:
diff changeset
340 Tree : Tree_Types.Tree_Type;
kono
parents:
diff changeset
341 end record;
kono
parents:
diff changeset
342
kono
parents:
diff changeset
343 overriding procedure Adjust (Container : in out Set);
kono
parents:
diff changeset
344
kono
parents:
diff changeset
345 overriding procedure Finalize (Container : in out Set) renames Clear;
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347 use Red_Black_Trees;
kono
parents:
diff changeset
348 use Tree_Types, Tree_Types.Implementation;
kono
parents:
diff changeset
349 use Ada.Finalization;
kono
parents:
diff changeset
350 use Ada.Streams;
kono
parents:
diff changeset
351
kono
parents:
diff changeset
352 procedure Write
kono
parents:
diff changeset
353 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
354 Container : Set);
kono
parents:
diff changeset
355
kono
parents:
diff changeset
356 for Set'Write use Write;
kono
parents:
diff changeset
357
kono
parents:
diff changeset
358 procedure Read
kono
parents:
diff changeset
359 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
360 Container : out Set);
kono
parents:
diff changeset
361
kono
parents:
diff changeset
362 for Set'Read use Read;
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 type Set_Access is access all Set;
kono
parents:
diff changeset
365 for Set_Access'Storage_Size use 0;
kono
parents:
diff changeset
366
kono
parents:
diff changeset
367 type Cursor is record
kono
parents:
diff changeset
368 Container : Set_Access;
kono
parents:
diff changeset
369 Node : Node_Access;
kono
parents:
diff changeset
370 end record;
kono
parents:
diff changeset
371
kono
parents:
diff changeset
372 procedure Write
kono
parents:
diff changeset
373 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
374 Item : Cursor);
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 for Cursor'Write use Write;
kono
parents:
diff changeset
377
kono
parents:
diff changeset
378 procedure Read
kono
parents:
diff changeset
379 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
380 Item : out Cursor);
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 for Cursor'Read use Read;
kono
parents:
diff changeset
383
kono
parents:
diff changeset
384 subtype Reference_Control_Type is Implementation.Reference_Control_Type;
kono
parents:
diff changeset
385 -- It is necessary to rename this here, so that the compiler can find it
kono
parents:
diff changeset
386
kono
parents:
diff changeset
387 type Constant_Reference_Type
kono
parents:
diff changeset
388 (Element : not null access constant Element_Type) is
kono
parents:
diff changeset
389 record
kono
parents:
diff changeset
390 Control : Reference_Control_Type :=
kono
parents:
diff changeset
391 raise Program_Error with "uninitialized reference";
kono
parents:
diff changeset
392 -- The RM says, "The default initialization of an object of
kono
parents:
diff changeset
393 -- type Constant_Reference_Type or Reference_Type propagates
kono
parents:
diff changeset
394 -- Program_Error."
kono
parents:
diff changeset
395 end record;
kono
parents:
diff changeset
396
kono
parents:
diff changeset
397 procedure Write
kono
parents:
diff changeset
398 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
399 Item : Constant_Reference_Type);
kono
parents:
diff changeset
400
kono
parents:
diff changeset
401 for Constant_Reference_Type'Write use Write;
kono
parents:
diff changeset
402
kono
parents:
diff changeset
403 procedure Read
kono
parents:
diff changeset
404 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
405 Item : out Constant_Reference_Type);
kono
parents:
diff changeset
406
kono
parents:
diff changeset
407 for Constant_Reference_Type'Read use Read;
kono
parents:
diff changeset
408
kono
parents:
diff changeset
409 -- Three operations are used to optimize in the expansion of "for ... of"
kono
parents:
diff changeset
410 -- loops: the Next(Cursor) procedure in the visible part, and the following
kono
parents:
diff changeset
411 -- Pseudo_Reference and Get_Element_Access functions. See Sem_Ch5 for
kono
parents:
diff changeset
412 -- details.
kono
parents:
diff changeset
413
kono
parents:
diff changeset
414 function Pseudo_Reference
kono
parents:
diff changeset
415 (Container : aliased Set'Class) return Reference_Control_Type;
kono
parents:
diff changeset
416 pragma Inline (Pseudo_Reference);
kono
parents:
diff changeset
417 -- Creates an object of type Reference_Control_Type pointing to the
kono
parents:
diff changeset
418 -- container, and increments the Lock. Finalization of this object will
kono
parents:
diff changeset
419 -- decrement the Lock.
kono
parents:
diff changeset
420
kono
parents:
diff changeset
421 type Element_Access is access all Element_Type with
kono
parents:
diff changeset
422 Storage_Size => 0;
kono
parents:
diff changeset
423
kono
parents:
diff changeset
424 function Get_Element_Access
kono
parents:
diff changeset
425 (Position : Cursor) return not null Element_Access;
kono
parents:
diff changeset
426 -- Returns a pointer to the element designated by Position.
kono
parents:
diff changeset
427
kono
parents:
diff changeset
428 Empty_Set : constant Set := (Controlled with others => <>);
kono
parents:
diff changeset
429
kono
parents:
diff changeset
430 No_Element : constant Cursor := Cursor'(null, null);
kono
parents:
diff changeset
431
kono
parents:
diff changeset
432 type Iterator is new Limited_Controlled and
kono
parents:
diff changeset
433 Set_Iterator_Interfaces.Reversible_Iterator with
kono
parents:
diff changeset
434 record
kono
parents:
diff changeset
435 Container : Set_Access;
kono
parents:
diff changeset
436 Node : Node_Access;
kono
parents:
diff changeset
437 end record
kono
parents:
diff changeset
438 with Disable_Controlled => not T_Check;
kono
parents:
diff changeset
439
kono
parents:
diff changeset
440 overriding procedure Finalize (Object : in out Iterator);
kono
parents:
diff changeset
441
kono
parents:
diff changeset
442 overriding function First (Object : Iterator) return Cursor;
kono
parents:
diff changeset
443 overriding function Last (Object : Iterator) return Cursor;
kono
parents:
diff changeset
444
kono
parents:
diff changeset
445 overriding function Next
kono
parents:
diff changeset
446 (Object : Iterator;
kono
parents:
diff changeset
447 Position : Cursor) return Cursor;
kono
parents:
diff changeset
448
kono
parents:
diff changeset
449 overriding function Previous
kono
parents:
diff changeset
450 (Object : Iterator;
kono
parents:
diff changeset
451 Position : Cursor) return Cursor;
kono
parents:
diff changeset
452
kono
parents:
diff changeset
453 end Ada.Containers.Ordered_Sets;