* tree-loop-linear.c: Don't include varray.h.
[official-gcc.git] / gcc / ada / a-cidlli.ads
blobe6fbf7694cff2b7a44e03e84b2332985f30b4374
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 ------------------------------------------------------------------------------
37 with Ada.Finalization;
38 with Ada.Streams;
40 generic
41 type Element_Type (<>) is private;
43 with function "=" (Left, Right : Element_Type)
44 return Boolean is <>;
46 package Ada.Containers.Indefinite_Doubly_Linked_Lists is
47 pragma Preelaborate;
49 type List is tagged private;
51 type Cursor is private;
53 Empty_List : constant List;
55 No_Element : constant Cursor;
57 function "=" (Left, Right : List) return Boolean;
59 function Length (Container : List) return Count_Type;
61 function Is_Empty (Container : List) return Boolean;
63 procedure Clear (Container : in out List);
65 function Element (Position : Cursor) return Element_Type;
67 procedure Replace_Element
68 (Container : in out List;
69 Position : Cursor;
70 New_Item : Element_Type);
72 procedure Query_Element
73 (Position : Cursor;
74 Process : not null access procedure (Element : Element_Type));
76 procedure Update_Element
77 (Container : in out List;
78 Position : Cursor;
79 Process : not null access procedure (Element : in out Element_Type));
81 procedure Move
82 (Target : in out List;
83 Source : in out List);
85 procedure Insert
86 (Container : in out List;
87 Before : Cursor;
88 New_Item : Element_Type;
89 Count : Count_Type := 1);
91 procedure Insert
92 (Container : in out List;
93 Before : Cursor;
94 New_Item : Element_Type;
95 Position : out Cursor;
96 Count : Count_Type := 1);
98 procedure Prepend
99 (Container : in out List;
100 New_Item : Element_Type;
101 Count : Count_Type := 1);
103 procedure Append
104 (Container : in out List;
105 New_Item : Element_Type;
106 Count : Count_Type := 1);
108 procedure Delete
109 (Container : in out List;
110 Position : in out Cursor;
111 Count : Count_Type := 1);
113 procedure Delete_First
114 (Container : in out List;
115 Count : Count_Type := 1);
117 procedure Delete_Last
118 (Container : in out List;
119 Count : Count_Type := 1);
121 procedure Reverse_Elements (Container : in out List);
123 procedure Swap (Container : in out List; I, J : Cursor);
125 procedure Swap_Links (Container : in out List; I, J : Cursor);
127 procedure Splice
128 (Target : in out List;
129 Before : Cursor;
130 Source : in out List);
132 procedure Splice
133 (Target : in out List;
134 Before : Cursor;
135 Source : in out List;
136 Position : in out Cursor);
138 procedure Splice
139 (Container : in out List;
140 Before : Cursor;
141 Position : in out Cursor);
143 function First (Container : List) return Cursor;
145 function First_Element (Container : List) return Element_Type;
147 function Last (Container : List) return Cursor;
149 function Last_Element (Container : List) return Element_Type;
151 function Next (Position : Cursor) return Cursor;
153 procedure Next (Position : in out Cursor);
155 function Previous (Position : Cursor) return Cursor;
157 procedure Previous (Position : in out Cursor);
159 function Find
160 (Container : List;
161 Item : Element_Type;
162 Position : Cursor := No_Element) return Cursor;
164 function Reverse_Find
165 (Container : List;
166 Item : Element_Type;
167 Position : Cursor := No_Element) return Cursor;
169 function Contains
170 (Container : List;
171 Item : Element_Type) return Boolean;
173 function Has_Element (Position : Cursor) return Boolean;
175 procedure Iterate
176 (Container : List;
177 Process : not null access procedure (Position : Cursor));
179 procedure Reverse_Iterate
180 (Container : List;
181 Process : not null access procedure (Position : Cursor));
183 generic
184 with function "<" (Left, Right : Element_Type) return Boolean is <>;
185 package Generic_Sorting is
187 function Is_Sorted (Container : List) return Boolean;
189 procedure Sort (Container : in out List);
191 procedure Merge (Target, Source : in out List);
193 end Generic_Sorting;
195 private
196 type Node_Type;
197 type Node_Access is access Node_Type;
199 type Element_Access is access Element_Type;
201 type Node_Type is
202 limited record
203 Element : Element_Access;
204 Next : Node_Access;
205 Prev : Node_Access;
206 end record;
208 use Ada.Finalization;
210 type List is
211 new Controlled with record
212 First : Node_Access;
213 Last : Node_Access;
214 Length : Count_Type := 0;
215 Busy : Natural := 0;
216 Lock : Natural := 0;
217 end record;
219 procedure Adjust (Container : in out List);
221 procedure Finalize (Container : in out List) renames Clear;
223 use Ada.Streams;
225 procedure Read
226 (Stream : access Root_Stream_Type'Class;
227 Item : out List);
229 for List'Read use Read;
231 procedure Write
232 (Stream : access Root_Stream_Type'Class;
233 Item : List);
235 for List'Write use Write;
237 Empty_List : constant List := List'(Controlled with null, null, 0, 0, 0);
239 type List_Access is access constant List;
240 for List_Access'Storage_Size use 0;
242 type Cursor is
243 record
244 Container : List_Access;
245 Node : Node_Access;
246 end record;
248 procedure Read
249 (Stream : access Root_Stream_Type'Class;
250 Item : out Cursor);
252 for Cursor'Read use Read;
254 procedure Write
255 (Stream : access Root_Stream_Type'Class;
256 Item : Cursor);
258 for Cursor'Write use Write;
260 No_Element : constant Cursor := Cursor'(null, null);
262 end Ada.Containers.Indefinite_Doubly_Linked_Lists;