* config/alpha/alpha.c (emit_insxl): Force the first operand of
[official-gcc.git] / gcc / ada / a-cidlli.ads
blobff354ccf1e28232f320d2b80fc157a8b6cbfae76
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-2006, 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;
50 pragma Preelaborable_Initialization (List);
52 type Cursor is private;
53 pragma Preelaborable_Initialization (Cursor);
55 Empty_List : constant List;
57 No_Element : constant Cursor;
59 function "=" (Left, Right : List) return Boolean;
61 function Length (Container : List) return Count_Type;
63 function Is_Empty (Container : List) return Boolean;
65 procedure Clear (Container : in out List);
67 function Element (Position : Cursor) return Element_Type;
69 procedure Replace_Element
70 (Container : in out List;
71 Position : Cursor;
72 New_Item : Element_Type);
74 procedure Query_Element
75 (Position : Cursor;
76 Process : not null access procedure (Element : Element_Type));
78 procedure Update_Element
79 (Container : in out List;
80 Position : Cursor;
81 Process : not null access procedure (Element : in out Element_Type));
83 procedure Move
84 (Target : in out List;
85 Source : in out List);
87 procedure Insert
88 (Container : in out List;
89 Before : Cursor;
90 New_Item : Element_Type;
91 Count : Count_Type := 1);
93 procedure Insert
94 (Container : in out List;
95 Before : Cursor;
96 New_Item : Element_Type;
97 Position : out Cursor;
98 Count : Count_Type := 1);
100 procedure Prepend
101 (Container : in out List;
102 New_Item : Element_Type;
103 Count : Count_Type := 1);
105 procedure Append
106 (Container : in out List;
107 New_Item : Element_Type;
108 Count : Count_Type := 1);
110 procedure Delete
111 (Container : in out List;
112 Position : in out Cursor;
113 Count : Count_Type := 1);
115 procedure Delete_First
116 (Container : in out List;
117 Count : Count_Type := 1);
119 procedure Delete_Last
120 (Container : in out List;
121 Count : Count_Type := 1);
123 procedure Reverse_Elements (Container : in out List);
125 procedure Swap (Container : in out List; I, J : Cursor);
127 procedure Swap_Links (Container : in out List; I, J : Cursor);
129 procedure Splice
130 (Target : in out List;
131 Before : Cursor;
132 Source : in out List);
134 procedure Splice
135 (Target : in out List;
136 Before : Cursor;
137 Source : in out List;
138 Position : in out Cursor);
140 procedure Splice
141 (Container : in out List;
142 Before : Cursor;
143 Position : Cursor);
145 function First (Container : List) return Cursor;
147 function First_Element (Container : List) return Element_Type;
149 function Last (Container : List) return Cursor;
151 function Last_Element (Container : List) return Element_Type;
153 function Next (Position : Cursor) return Cursor;
155 procedure Next (Position : in out Cursor);
157 function Previous (Position : Cursor) return Cursor;
159 procedure Previous (Position : in out Cursor);
161 function Find
162 (Container : List;
163 Item : Element_Type;
164 Position : Cursor := No_Element) return Cursor;
166 function Reverse_Find
167 (Container : List;
168 Item : Element_Type;
169 Position : Cursor := No_Element) return Cursor;
171 function Contains
172 (Container : List;
173 Item : Element_Type) return Boolean;
175 function Has_Element (Position : Cursor) return Boolean;
177 procedure Iterate
178 (Container : List;
179 Process : not null access procedure (Position : Cursor));
181 procedure Reverse_Iterate
182 (Container : List;
183 Process : not null access procedure (Position : Cursor));
185 generic
186 with function "<" (Left, Right : Element_Type) return Boolean is <>;
187 package Generic_Sorting is
189 function Is_Sorted (Container : List) return Boolean;
191 procedure Sort (Container : in out List);
193 procedure Merge (Target, Source : in out List);
195 end Generic_Sorting;
197 private
198 type Node_Type;
199 type Node_Access is access Node_Type;
201 type Element_Access is access Element_Type;
203 type Node_Type is
204 limited record
205 Element : Element_Access;
206 Next : Node_Access;
207 Prev : Node_Access;
208 end record;
210 use Ada.Finalization;
212 type List is
213 new Controlled with record
214 First : Node_Access;
215 Last : Node_Access;
216 Length : Count_Type := 0;
217 Busy : Natural := 0;
218 Lock : Natural := 0;
219 end record;
221 procedure Adjust (Container : in out List);
223 procedure Finalize (Container : in out List) renames Clear;
225 use Ada.Streams;
227 procedure Read
228 (Stream : not null access Root_Stream_Type'Class;
229 Item : out List);
231 for List'Read use Read;
233 procedure Write
234 (Stream : not null access Root_Stream_Type'Class;
235 Item : List);
237 for List'Write use Write;
239 Empty_List : constant List := List'(Controlled with null, null, 0, 0, 0);
241 type List_Access is access constant List;
242 for List_Access'Storage_Size use 0;
244 type Cursor is
245 record
246 Container : List_Access;
247 Node : Node_Access;
248 end record;
250 procedure Read
251 (Stream : not null access Root_Stream_Type'Class;
252 Item : out Cursor);
254 for Cursor'Read use Read;
256 procedure Write
257 (Stream : not null access Root_Stream_Type'Class;
258 Item : Cursor);
260 for Cursor'Write use Write;
262 No_Element : constant Cursor := Cursor'(null, null);
264 end Ada.Containers.Indefinite_Doubly_Linked_Lists;