OSDN Git Service

* gcc.dg/attr-weakref-1.c: Add exit (0) to avoid spurious
[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-2005 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
49    type List is tagged private;
50
51    type Cursor is private;
52
53    Empty_List : constant List;
54
55    No_Element : constant Cursor;
56
57    function "=" (Left, Right : List) return Boolean;
58
59    function Length (Container : List) return Count_Type;
60
61    function Is_Empty (Container : List) return Boolean;
62
63    procedure Clear (Container : in out List);
64
65    function Element (Position : Cursor)
66       return Element_Type;
67
68    procedure Query_Element
69      (Position : Cursor;
70       Process  : not null access procedure (Element : Element_Type));
71
72    procedure Update_Element
73      (Position : Cursor;
74       Process  : not null access procedure (Element : in out Element_Type));
75
76    procedure Replace_Element
77      (Position : Cursor;
78       By       : Element_Type);
79
80    procedure Move
81      (Target : in out List;
82       Source : in out List);
83
84    procedure Prepend
85      (Container : in out List;
86       New_Item  : Element_Type;
87       Count     : Count_Type := 1);
88
89    procedure Append
90      (Container : in out List;
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       Count     : Count_Type := 1);
99
100    procedure Insert
101      (Container : in out List;
102       Before    : Cursor;
103       New_Item  : Element_Type;
104       Position  : out Cursor;
105       Count     : Count_Type := 1);
106
107    procedure Delete
108      (Container : in out List;
109       Position  : in out Cursor;
110       Count     : Count_Type := 1);
111
112    procedure Delete_First
113      (Container : in out List;
114       Count     : Count_Type := 1);
115
116    procedure Delete_Last
117      (Container : in out List;
118       Count     : Count_Type := 1);
119
120    generic
121       with function "<" (Left, Right : Element_Type) return Boolean is <>;
122    package Generic_Sorting is
123
124       function Is_Sorted (Container : List) return Boolean;
125
126       procedure Sort (Container : in out List);
127
128       procedure Merge (Target, Source : in out List);
129
130    end Generic_Sorting;
131
132    procedure Reverse_List (Container : in out List);
133
134    procedure Swap (I, J : Cursor);
135
136    procedure Swap_Links (Container : in out List; I, J : Cursor);
137
138    procedure Splice
139      (Target : in out List;
140       Before : Cursor;
141       Source : in out List);
142
143    procedure Splice
144      (Target   : in out List;
145       Before   : Cursor;
146       Position : Cursor);
147
148    procedure Splice
149      (Target   : in out List;
150       Before   : Cursor;
151       Source   : in out List;
152       Position : in out Cursor);
153
154    function First (Container : List) return Cursor;
155
156    function First_Element (Container : List) return Element_Type;
157
158    function Last (Container : List) return Cursor;
159
160    function Last_Element (Container : List) return Element_Type;
161
162    function Contains
163      (Container : List;
164       Item      : Element_Type) return Boolean;
165
166    function Find
167      (Container : List;
168       Item      : Element_Type;
169       Position  : Cursor := No_Element) return Cursor;
170
171    function Reverse_Find
172      (Container : List;
173       Item      : Element_Type;
174       Position  : Cursor := No_Element) return Cursor;
175
176    function Next (Position : Cursor) return Cursor;
177
178    function Previous (Position : Cursor) return Cursor;
179
180    procedure Next (Position : in out Cursor);
181
182    procedure Previous (Position : in out Cursor);
183
184    function Has_Element (Position : Cursor) return Boolean;
185
186    procedure Iterate
187      (Container : List;
188       Process   : not null access procedure (Position : Cursor));
189
190    procedure Reverse_Iterate
191      (Container : List;
192       Process   : not null access procedure (Position : Cursor));
193
194 private
195    type Node_Type;
196    type Node_Access is access Node_Type;
197
198    type Element_Access is access Element_Type;
199
200    type Node_Type is
201       limited record
202          Element : Element_Access;
203          Next    : Node_Access;
204          Prev    : Node_Access;
205       end record;
206
207    use Ada.Finalization;
208
209    type List is
210      new Controlled with record
211         First  : Node_Access;
212         Last   : Node_Access;
213         Length : Count_Type := 0;
214         Busy   : Natural := 0;
215         Lock   : Natural := 0;
216      end record;
217
218    procedure Adjust (Container : in out List);
219
220    procedure Finalize (Container : in out List) renames Clear;
221
222    use Ada.Streams;
223
224    procedure Read
225      (Stream : access Root_Stream_Type'Class;
226       Item   : out List);
227
228    for List'Read use Read;
229
230    procedure Write
231      (Stream : access Root_Stream_Type'Class;
232       Item   : List);
233
234    for List'Write use Write;
235
236    Empty_List : constant List := List'(Controlled with null, null, 0, 0, 0);
237
238    type List_Access is access constant List;
239    for List_Access'Storage_Size use 0;
240
241    type Cursor is
242       record
243          Container : List_Access;
244          Node      : Node_Access;
245       end record;
246
247    No_Element : constant Cursor := Cursor'(null, null);
248
249 end Ada.Containers.Indefinite_Doubly_Linked_Lists;