OSDN Git Service

libitm: Remove unused code.
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-cidlli.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT LIBRARY COMPONENTS                          --
4 --                                                                          --
5 --               ADA.CONTAINERS.INDEFINITE_DOUBLY_LINKED_LISTS              --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 2004-2011, 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 ------------------------------------------------------------------------------
33
34 with Ada.Iterator_Interfaces;
35 with Ada.Streams;             use Ada.Streams;
36
37 private with Ada.Finalization;
38
39 generic
40    type Element_Type (<>) is private;
41
42    with function "=" (Left, Right : Element_Type)
43       return Boolean is <>;
44
45 package Ada.Containers.Indefinite_Doubly_Linked_Lists is
46    pragma Preelaborate;
47    pragma Remote_Types;
48
49    type List is tagged private with
50       Constant_Indexing => Constant_Reference,
51       Variable_Indexing => Reference,
52       Default_Iterator  => Iterate,
53       Iterator_Element  => Element_Type;
54
55    pragma Preelaborable_Initialization (List);
56
57    type Cursor is private;
58    pragma Preelaborable_Initialization (Cursor);
59
60    Empty_List : constant List;
61
62    No_Element : constant Cursor;
63
64    function Has_Element (Position : Cursor) return Boolean;
65
66    package List_Iterator_Interfaces is new
67      Ada.Iterator_Interfaces (Cursor, Has_Element);
68
69    function "=" (Left, Right : List) return Boolean;
70
71    function Length (Container : List) return Count_Type;
72
73    function Is_Empty (Container : List) return Boolean;
74
75    procedure Clear (Container : in out List);
76
77    function Element (Position : Cursor) return Element_Type;
78
79    procedure Replace_Element
80      (Container : in out List;
81       Position  : Cursor;
82       New_Item  : Element_Type);
83
84    procedure Query_Element
85      (Position : Cursor;
86       Process  : not null access procedure (Element : Element_Type));
87
88    procedure Update_Element
89      (Container : in out List;
90       Position  : Cursor;
91       Process   : not null access procedure (Element : in out Element_Type));
92
93    procedure Assign (Target : in out List; Source : List);
94
95    function Copy (Source : List) return List;
96
97    procedure Move
98      (Target : in out List;
99       Source : in out List);
100
101    procedure Insert
102      (Container : in out List;
103       Before    : Cursor;
104       New_Item  : Element_Type;
105       Count     : Count_Type := 1);
106
107    procedure Insert
108      (Container : in out List;
109       Before    : Cursor;
110       New_Item  : Element_Type;
111       Position  : out Cursor;
112       Count     : Count_Type := 1);
113
114    procedure Prepend
115      (Container : in out List;
116       New_Item  : Element_Type;
117       Count     : Count_Type := 1);
118
119    procedure Append
120      (Container : in out List;
121       New_Item  : Element_Type;
122       Count     : Count_Type := 1);
123
124    procedure Delete
125      (Container : in out List;
126       Position  : in out Cursor;
127       Count     : Count_Type := 1);
128
129    procedure Delete_First
130      (Container : in out List;
131       Count     : Count_Type := 1);
132
133    procedure Delete_Last
134      (Container : in out List;
135       Count     : Count_Type := 1);
136
137    procedure Reverse_Elements (Container : in out List);
138
139    procedure Swap (Container : in out List; I, J : Cursor);
140
141    procedure Swap_Links (Container : in out List; I, J : Cursor);
142
143    procedure Splice
144      (Target : in out List;
145       Before : Cursor;
146       Source : in out List);
147
148    procedure Splice
149      (Target   : in out List;
150       Before   : Cursor;
151       Source   : in out List;
152       Position : in out Cursor);
153
154    procedure Splice
155      (Container : in out List;
156       Before    : Cursor;
157       Position  : Cursor);
158
159    function First (Container : List) return Cursor;
160
161    function First_Element (Container : List) return Element_Type;
162
163    function Last (Container : List) return Cursor;
164
165    function Last_Element (Container : List) return Element_Type;
166
167    function Next (Position : Cursor) return Cursor;
168
169    procedure Next (Position : in out Cursor);
170
171    function Previous (Position : Cursor) return Cursor;
172
173    procedure Previous (Position : in out Cursor);
174
175    function Find
176      (Container : List;
177       Item      : Element_Type;
178       Position  : Cursor := No_Element) return Cursor;
179
180    function Reverse_Find
181      (Container : List;
182       Item      : Element_Type;
183       Position  : Cursor := No_Element) return Cursor;
184
185    function Contains
186      (Container : List;
187       Item      : Element_Type) return Boolean;
188
189    procedure Iterate
190      (Container : List;
191       Process   : not null access procedure (Position : Cursor));
192
193    procedure Reverse_Iterate
194      (Container : List;
195       Process   : not null access procedure (Position : Cursor));
196
197    function Iterate
198      (Container : List)
199       return List_Iterator_Interfaces.Reversible_Iterator'class;
200
201    function Iterate
202      (Container : List;
203       Start     : Cursor)
204       return List_Iterator_Interfaces.Reversible_Iterator'class;
205
206    type Constant_Reference_Type
207       (Element : not null access constant Element_Type) is private
208    with
209       Implicit_Dereference => Element;
210
211    procedure Write
212      (Stream : not null access Root_Stream_Type'Class;
213       Item   : Constant_Reference_Type);
214
215    for Constant_Reference_Type'Write use Write;
216
217    procedure Read
218      (Stream : not null access Root_Stream_Type'Class;
219       Item   : out Constant_Reference_Type);
220
221    for Constant_Reference_Type'Read use Read;
222
223    type Reference_Type (Element : not null access Element_Type) is
224    private
225    with
226       Implicit_Dereference => Element;
227
228    procedure Write
229      (Stream : not null access Root_Stream_Type'Class;
230       Item   : Reference_Type);
231
232    for Reference_Type'Write use Write;
233
234    procedure Read
235      (Stream : not null access Root_Stream_Type'Class;
236       Item   : out Reference_Type);
237
238    for Reference_Type'Read use Read;
239
240    function Constant_Reference
241      (Container : List;
242       Position  : Cursor)    --  SHOULD BE ALIASED ???
243       return Constant_Reference_Type;
244
245    function Reference
246      (Container : List;
247       Position  : Cursor)    --  SHOULD BE ALIASED ???
248       return Reference_Type;
249
250    generic
251       with function "<" (Left, Right : Element_Type) return Boolean is <>;
252    package Generic_Sorting is
253
254       function Is_Sorted (Container : List) return Boolean;
255
256       procedure Sort (Container : in out List);
257
258       procedure Merge (Target, Source : in out List);
259
260    end Generic_Sorting;
261
262 private
263
264    pragma Inline (Next);
265    pragma Inline (Previous);
266
267    type Node_Type;
268    type Node_Access is access Node_Type;
269
270    type Element_Access is access Element_Type;
271
272    type Node_Type is
273       limited record
274          Element : Element_Access;
275          Next    : Node_Access;
276          Prev    : Node_Access;
277       end record;
278
279    use Ada.Finalization;
280
281    type List is
282      new Controlled with record
283         First  : Node_Access;
284         Last   : Node_Access;
285         Length : Count_Type := 0;
286         Busy   : Natural := 0;
287         Lock   : Natural := 0;
288      end record;
289
290    type Constant_Reference_Type
291       (Element : not null access constant Element_Type) is null record;
292
293    type Reference_Type
294       (Element : not null access Element_Type) is null record;
295
296    overriding procedure Adjust (Container : in out List);
297
298    overriding procedure Finalize (Container : in out List) renames Clear;
299
300    procedure Read
301      (Stream : not null access Root_Stream_Type'Class;
302       Item   : out List);
303
304    for List'Read use Read;
305
306    procedure Write
307      (Stream : not null access Root_Stream_Type'Class;
308       Item   : List);
309
310    for List'Write use Write;
311
312    type List_Access is access constant List;
313    for List_Access'Storage_Size use 0;
314
315    type Cursor is
316       record
317          Container : List_Access;
318          Node      : Node_Access;
319       end record;
320
321    procedure Read
322      (Stream : not null access Root_Stream_Type'Class;
323       Item   : out Cursor);
324
325    for Cursor'Read use Read;
326
327    procedure Write
328      (Stream : not null access Root_Stream_Type'Class;
329       Item   : Cursor);
330
331    for Cursor'Write use Write;
332
333    Empty_List : constant List := List'(Controlled with null, null, 0, 0, 0);
334
335    No_Element : constant Cursor := Cursor'(null, null);
336
337 end Ada.Containers.Indefinite_Doubly_Linked_Lists;