re PR c++/65046 (-Wabi-tag doesn't warn about variables or function return types)
[official-gcc.git] / gcc / ada / a-cdlili.ads
blobc99e7350afc2e4c9ce2d2655ad1d9a91e5251aca
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT LIBRARY COMPONENTS --
4 -- --
5 -- A D A . C O N T A I N E R S . D O U B L Y _ L I N K E D _ L I S T S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2004-2013, Free Software Foundation, Inc. --
10 -- --
11 -- This specification is derived from the Ada Reference Manual for use with --
12 -- GNAT. The copyright notice above, and the license provisions that follow --
13 -- apply solely to the contents of the part following the private keyword. --
14 -- --
15 -- GNAT is free software; you can redistribute it and/or modify it under --
16 -- terms of the GNU General Public License as published by the Free Soft- --
17 -- ware Foundation; either version 3, or (at your option) any later ver- --
18 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
19 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
20 -- or FITNESS FOR A PARTICULAR PURPOSE. --
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/>. --
30 -- --
31 -- This unit was originally developed by Matthew J Heaney. --
32 ------------------------------------------------------------------------------
34 with Ada.Iterator_Interfaces;
36 private with Ada.Finalization;
37 private with Ada.Streams;
39 generic
40 type Element_Type is private;
42 with function "=" (Left, Right : Element_Type)
43 return Boolean is <>;
45 package Ada.Containers.Doubly_Linked_Lists is
46 pragma Preelaborate;
47 pragma Remote_Types;
49 type List is tagged private
50 with
51 Constant_Indexing => Constant_Reference,
52 Variable_Indexing => Reference,
53 Default_Iterator => Iterate,
54 Iterator_Element => Element_Type;
56 pragma Preelaborable_Initialization (List);
58 type Cursor is private;
59 pragma Preelaborable_Initialization (Cursor);
61 Empty_List : constant List;
63 No_Element : constant Cursor;
65 function Has_Element (Position : Cursor) return Boolean;
67 package List_Iterator_Interfaces is new
68 Ada.Iterator_Interfaces (Cursor, Has_Element);
70 function "=" (Left, Right : List) return Boolean;
72 function Length (Container : List) return Count_Type;
74 function Is_Empty (Container : List) return Boolean;
76 procedure Clear (Container : in out List);
78 function Element (Position : Cursor) return Element_Type;
80 procedure Replace_Element
81 (Container : in out List;
82 Position : Cursor;
83 New_Item : Element_Type);
85 procedure Query_Element
86 (Position : Cursor;
87 Process : not null access procedure (Element : Element_Type));
89 procedure Update_Element
90 (Container : in out List;
91 Position : Cursor;
92 Process : not null access procedure (Element : in out Element_Type));
94 type Constant_Reference_Type
95 (Element : not null access constant Element_Type) is private
96 with
97 Implicit_Dereference => Element;
99 type Reference_Type
100 (Element : not null access Element_Type) is private
101 with
102 Implicit_Dereference => Element;
104 function Constant_Reference
105 (Container : aliased List;
106 Position : Cursor) return Constant_Reference_Type;
107 pragma Inline (Constant_Reference);
109 function Reference
110 (Container : aliased in out List;
111 Position : Cursor) return Reference_Type;
112 pragma Inline (Reference);
114 procedure Assign (Target : in out List; Source : List);
116 function Copy (Source : List) return List;
118 procedure Move
119 (Target : in out List;
120 Source : in out List);
122 procedure Insert
123 (Container : in out List;
124 Before : Cursor;
125 New_Item : Element_Type;
126 Count : Count_Type := 1);
128 procedure Insert
129 (Container : in out List;
130 Before : Cursor;
131 New_Item : Element_Type;
132 Position : out Cursor;
133 Count : Count_Type := 1);
135 procedure Insert
136 (Container : in out List;
137 Before : Cursor;
138 Position : out Cursor;
139 Count : Count_Type := 1);
141 procedure Prepend
142 (Container : in out List;
143 New_Item : Element_Type;
144 Count : Count_Type := 1);
146 procedure Append
147 (Container : in out List;
148 New_Item : Element_Type;
149 Count : Count_Type := 1);
151 procedure Delete
152 (Container : in out List;
153 Position : in out Cursor;
154 Count : Count_Type := 1);
156 procedure Delete_First
157 (Container : in out List;
158 Count : Count_Type := 1);
160 procedure Delete_Last
161 (Container : in out List;
162 Count : Count_Type := 1);
164 procedure Reverse_Elements (Container : in out List);
166 function Iterate (Container : List)
167 return List_Iterator_Interfaces.Reversible_Iterator'Class;
169 function Iterate (Container : List; Start : Cursor)
170 return List_Iterator_Interfaces.Reversible_Iterator'Class;
172 procedure Swap
173 (Container : in out List;
174 I, J : Cursor);
176 procedure Swap_Links
177 (Container : in out List;
178 I, J : Cursor);
180 procedure Splice
181 (Target : in out List;
182 Before : Cursor;
183 Source : in out List);
185 procedure Splice
186 (Target : in out List;
187 Before : Cursor;
188 Source : in out List;
189 Position : in out Cursor);
191 procedure Splice
192 (Container : in out List;
193 Before : Cursor;
194 Position : Cursor);
196 function First (Container : List) return Cursor;
198 function First_Element (Container : List) return Element_Type;
200 function Last (Container : List) return Cursor;
202 function Last_Element (Container : List) return Element_Type;
204 function Next (Position : Cursor) return Cursor;
206 procedure Next (Position : in out Cursor);
208 function Previous (Position : Cursor) return Cursor;
210 procedure Previous (Position : in out Cursor);
212 function Find
213 (Container : List;
214 Item : Element_Type;
215 Position : Cursor := No_Element) return Cursor;
217 function Reverse_Find
218 (Container : List;
219 Item : Element_Type;
220 Position : Cursor := No_Element) return Cursor;
222 function Contains
223 (Container : List;
224 Item : Element_Type) return Boolean;
226 procedure Iterate
227 (Container : List;
228 Process : not null access procedure (Position : Cursor));
230 procedure Reverse_Iterate
231 (Container : List;
232 Process : not null access procedure (Position : Cursor));
234 generic
235 with function "<" (Left, Right : Element_Type) return Boolean is <>;
236 package Generic_Sorting is
238 function Is_Sorted (Container : List) return Boolean;
240 procedure Sort (Container : in out List);
242 procedure Merge (Target, Source : in out List);
244 end Generic_Sorting;
246 private
248 pragma Inline (Next);
249 pragma Inline (Previous);
251 type Node_Type;
252 type Node_Access is access Node_Type;
254 type Node_Type is
255 limited record
256 Element : aliased Element_Type;
257 Next : Node_Access;
258 Prev : Node_Access;
259 end record;
261 use Ada.Finalization;
262 use Ada.Streams;
264 type List is
265 new Controlled with record
266 First : Node_Access;
267 Last : Node_Access;
268 Length : Count_Type := 0;
269 Busy : Natural := 0;
270 Lock : Natural := 0;
271 end record;
273 overriding procedure Adjust (Container : in out List);
275 overriding procedure Finalize (Container : in out List) renames Clear;
277 procedure Read
278 (Stream : not null access Root_Stream_Type'Class;
279 Item : out List);
281 for List'Read use Read;
283 procedure Write
284 (Stream : not null access Root_Stream_Type'Class;
285 Item : List);
287 for List'Write use Write;
289 type List_Access is access all List;
290 for List_Access'Storage_Size use 0;
292 type Cursor is
293 record
294 Container : List_Access;
295 Node : Node_Access;
296 end record;
298 procedure Read
299 (Stream : not null access Root_Stream_Type'Class;
300 Item : out Cursor);
302 for Cursor'Read use Read;
304 procedure Write
305 (Stream : not null access Root_Stream_Type'Class;
306 Item : Cursor);
308 for Cursor'Write use Write;
310 type Reference_Control_Type is
311 new Controlled with record
312 Container : List_Access;
313 end record;
315 overriding procedure Adjust (Control : in out Reference_Control_Type);
316 pragma Inline (Adjust);
318 overriding procedure Finalize (Control : in out Reference_Control_Type);
319 pragma Inline (Finalize);
321 type Constant_Reference_Type
322 (Element : not null access constant Element_Type) is
323 record
324 Control : Reference_Control_Type;
325 end record;
327 procedure Write
328 (Stream : not null access Root_Stream_Type'Class;
329 Item : Constant_Reference_Type);
331 for Constant_Reference_Type'Write use Write;
333 procedure Read
334 (Stream : not null access Root_Stream_Type'Class;
335 Item : out Constant_Reference_Type);
337 for Constant_Reference_Type'Read use Read;
339 type Reference_Type
340 (Element : not null access Element_Type) is
341 record
342 Control : Reference_Control_Type;
343 end record;
345 procedure Write
346 (Stream : not null access Root_Stream_Type'Class;
347 Item : Reference_Type);
349 for Reference_Type'Write use Write;
351 procedure Read
352 (Stream : not null access Root_Stream_Type'Class;
353 Item : out Reference_Type);
355 for Reference_Type'Read use Read;
357 Empty_List : constant List := (Controlled with null, null, 0, 0, 0);
359 No_Element : constant Cursor := Cursor'(null, null);
361 type Iterator is new Limited_Controlled and
362 List_Iterator_Interfaces.Reversible_Iterator with
363 record
364 Container : List_Access;
365 Node : Node_Access;
366 end record;
368 overriding procedure Finalize (Object : in out Iterator);
370 overriding function First (Object : Iterator) return Cursor;
371 overriding function Last (Object : Iterator) return Cursor;
373 overriding function Next
374 (Object : Iterator;
375 Position : Cursor) return Cursor;
377 overriding function Previous
378 (Object : Iterator;
379 Position : Cursor) return Cursor;
381 end Ada.Containers.Doubly_Linked_Lists;