OSDN Git Service

Remove s-crtl-vms64.ads, no longer used.
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-cidlli.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT LIBRARY COMPONENTS                          --
4 --                                                                          --
5 --                      A D A . C O N T A I N E R S .                       --
6 --        I N D E F I N I T E _ D O U B L Y _ L I N K E D _ L I S T S       --
7 --                                                                          --
8 --                                 S p e c                                  --
9 --                                                                          --
10 --          Copyright (C) 2004-2007, Free Software Foundation, Inc.         --
11 --                                                                          --
12 -- This specification is derived from the Ada Reference Manual for use with --
13 -- GNAT. The copyright notice above, and the license provisions that follow --
14 -- apply solely to the  contents of the part following the private keyword. --
15 --                                                                          --
16 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
17 -- terms of the  GNU General Public License as published  by the Free Soft- --
18 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
19 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
20 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
21 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
22 -- for  more details.  You should have  received  a copy of the GNU General --
23 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
24 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
25 -- Boston, MA 02110-1301, USA.                                              --
26 --                                                                          --
27 -- As a special exception,  if other files  instantiate  generics from this --
28 -- unit, or you link  this unit with other files  to produce an executable, --
29 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
30 -- covered  by the  GNU  General  Public  License.  This exception does not --
31 -- however invalidate  any other reasons why  the executable file  might be --
32 -- covered by the  GNU Public License.                                      --
33 --                                                                          --
34 -- This unit was originally developed by Matthew J Heaney.                  --
35 ------------------------------------------------------------------------------
36
37 with Ada.Finalization;
38 with Ada.Streams;
39
40 generic
41    type Element_Type (<>) is private;
42
43    with function "=" (Left, Right : Element_Type)
44       return Boolean is <>;
45
46 package Ada.Containers.Indefinite_Doubly_Linked_Lists is
47    pragma Preelaborate;
48    pragma Remote_Types;
49
50    type List is tagged private;
51    pragma Preelaborable_Initialization (List);
52
53    type Cursor is private;
54    pragma Preelaborable_Initialization (Cursor);
55
56    Empty_List : constant List;
57
58    No_Element : constant Cursor;
59
60    function "=" (Left, Right : List) return Boolean;
61
62    function Length (Container : List) return Count_Type;
63
64    function Is_Empty (Container : List) return Boolean;
65
66    procedure Clear (Container : in out List);
67
68    function Element (Position : Cursor) return Element_Type;
69
70    procedure Replace_Element
71      (Container : in out List;
72       Position  : Cursor;
73       New_Item  : Element_Type);
74
75    procedure Query_Element
76      (Position : Cursor;
77       Process  : not null access procedure (Element : Element_Type));
78
79    procedure Update_Element
80      (Container : in out List;
81       Position  : Cursor;
82       Process   : not null access procedure (Element : in out Element_Type));
83
84    procedure Move
85      (Target : in out List;
86       Source : in out List);
87
88    procedure Insert
89      (Container : in out List;
90       Before    : Cursor;
91       New_Item  : Element_Type;
92       Count     : Count_Type := 1);
93
94    procedure Insert
95      (Container : in out List;
96       Before    : Cursor;
97       New_Item  : Element_Type;
98       Position  : out Cursor;
99       Count     : Count_Type := 1);
100
101    procedure Prepend
102      (Container : in out List;
103       New_Item  : Element_Type;
104       Count     : Count_Type := 1);
105
106    procedure Append
107      (Container : in out List;
108       New_Item  : Element_Type;
109       Count     : Count_Type := 1);
110
111    procedure Delete
112      (Container : in out List;
113       Position  : in out Cursor;
114       Count     : Count_Type := 1);
115
116    procedure Delete_First
117      (Container : in out List;
118       Count     : Count_Type := 1);
119
120    procedure Delete_Last
121      (Container : in out List;
122       Count     : Count_Type := 1);
123
124    procedure Reverse_Elements (Container : in out List);
125
126    procedure Swap (Container : in out List; I, J : Cursor);
127
128    procedure Swap_Links (Container : in out List; I, J : Cursor);
129
130    procedure Splice
131      (Target : in out List;
132       Before : Cursor;
133       Source : in out List);
134
135    procedure Splice
136      (Target   : in out List;
137       Before   : Cursor;
138       Source   : in out List;
139       Position : in out Cursor);
140
141    procedure Splice
142      (Container : in out List;
143       Before    : Cursor;
144       Position  : Cursor);
145
146    function First (Container : List) return Cursor;
147
148    function First_Element (Container : List) return Element_Type;
149
150    function Last (Container : List) return Cursor;
151
152    function Last_Element (Container : List) return Element_Type;
153
154    function Next (Position : Cursor) return Cursor;
155
156    procedure Next (Position : in out Cursor);
157
158    function Previous (Position : Cursor) return Cursor;
159
160    procedure Previous (Position : in out Cursor);
161
162    function Find
163      (Container : List;
164       Item      : Element_Type;
165       Position  : Cursor := No_Element) return Cursor;
166
167    function Reverse_Find
168      (Container : List;
169       Item      : Element_Type;
170       Position  : Cursor := No_Element) return Cursor;
171
172    function Contains
173      (Container : List;
174       Item      : Element_Type) return Boolean;
175
176    function Has_Element (Position : Cursor) return Boolean;
177
178    procedure Iterate
179      (Container : List;
180       Process   : not null access procedure (Position : Cursor));
181
182    procedure Reverse_Iterate
183      (Container : List;
184       Process   : not null access procedure (Position : Cursor));
185
186    generic
187       with function "<" (Left, Right : Element_Type) return Boolean is <>;
188    package Generic_Sorting is
189
190       function Is_Sorted (Container : List) return Boolean;
191
192       procedure Sort (Container : in out List);
193
194       procedure Merge (Target, Source : in out List);
195
196    end Generic_Sorting;
197
198 private
199
200    pragma Inline (Next);
201    pragma Inline (Previous);
202
203    type Node_Type;
204    type Node_Access is access Node_Type;
205
206    type Element_Access is access Element_Type;
207
208    type Node_Type is
209       limited record
210          Element : Element_Access;
211          Next    : Node_Access;
212          Prev    : Node_Access;
213       end record;
214
215    use Ada.Finalization;
216
217    type List is
218      new Controlled with record
219         First  : Node_Access;
220         Last   : Node_Access;
221         Length : Count_Type := 0;
222         Busy   : Natural := 0;
223         Lock   : Natural := 0;
224      end record;
225
226    procedure Adjust (Container : in out List);
227
228    procedure Finalize (Container : in out List) renames Clear;
229
230    use Ada.Streams;
231
232    procedure Read
233      (Stream : not null access Root_Stream_Type'Class;
234       Item   : out List);
235
236    for List'Read use Read;
237
238    procedure Write
239      (Stream : not null access Root_Stream_Type'Class;
240       Item   : List);
241
242    for List'Write use Write;
243
244    type List_Access is access constant List;
245    for List_Access'Storage_Size use 0;
246
247    type Cursor is
248       record
249          Container : List_Access;
250          Node      : Node_Access;
251       end record;
252
253    procedure Read
254      (Stream : not null access Root_Stream_Type'Class;
255       Item   : out Cursor);
256
257    for Cursor'Read use Read;
258
259    procedure Write
260      (Stream : not null access Root_Stream_Type'Class;
261       Item   : Cursor);
262
263    for Cursor'Write use Write;
264
265    Empty_List : constant List := List'(Controlled with null, null, 0, 0, 0);
266
267    No_Element : constant Cursor := Cursor'(null, null);
268
269 end Ada.Containers.Indefinite_Doubly_Linked_Lists;