mips.h (set_volatile): Delete.
[official-gcc.git] / gcc / ada / a-cdlili.ads
blobe8a0488b2b4e01a0ccc1ce5378d6d2cc48c4b7c7
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT LIBRARY COMPONENTS --
4 -- --
5 -- A D A . C O N T A I N E R S . D O U B L Y _ L I N K E D _ L I S T S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2004-2007, 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 2, 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. See the GNU General Public License --
21 -- for more details. You should have received a copy of the GNU General --
22 -- Public License distributed with GNAT; see file COPYING. If not, write --
23 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
24 -- Boston, MA 02110-1301, USA. --
25 -- --
26 -- As a special exception, if other files instantiate generics from this --
27 -- unit, or you link this unit with other files to produce an executable, --
28 -- this unit does not by itself cause the resulting executable to be --
29 -- covered by the GNU General Public License. This exception does not --
30 -- however invalidate any other reasons why the executable file might be --
31 -- covered by the GNU Public License. --
32 -- --
33 -- This unit was originally developed by Matthew J Heaney. --
34 ------------------------------------------------------------------------------
36 with Ada.Finalization;
37 with Ada.Streams;
39 generic
40 type Element_Type is private;
42 with function "=" (Left, Right : Element_Type)
43 return Boolean is <>;
45 package Ada.Containers.Doubly_Linked_Lists is
46 pragma Preelaborate;
47 pragma Remote_Types;
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 Insert
101 (Container : in out List;
102 Before : Cursor;
103 Position : out Cursor;
104 Count : Count_Type := 1);
106 procedure Prepend
107 (Container : in out List;
108 New_Item : Element_Type;
109 Count : Count_Type := 1);
111 procedure Append
112 (Container : in out List;
113 New_Item : Element_Type;
114 Count : Count_Type := 1);
116 procedure Delete
117 (Container : in out List;
118 Position : in out Cursor;
119 Count : Count_Type := 1);
121 procedure Delete_First
122 (Container : in out List;
123 Count : Count_Type := 1);
125 procedure Delete_Last
126 (Container : in out List;
127 Count : Count_Type := 1);
129 procedure Reverse_Elements (Container : in out List);
131 procedure Swap
132 (Container : in out List;
133 I, J : Cursor);
135 procedure Swap_Links
136 (Container : in out List;
137 I, J : Cursor);
139 procedure Splice
140 (Target : in out List;
141 Before : Cursor;
142 Source : in out List);
144 procedure Splice
145 (Target : in out List;
146 Before : Cursor;
147 Source : in out List;
148 Position : in out Cursor);
150 procedure Splice
151 (Container : in out List;
152 Before : Cursor;
153 Position : Cursor);
155 function First (Container : List) return Cursor;
157 function First_Element (Container : List) return Element_Type;
159 function Last (Container : List) return Cursor;
161 function Last_Element (Container : List) return Element_Type;
163 function Next (Position : Cursor) return Cursor;
165 procedure Next (Position : in out Cursor);
167 function Previous (Position : Cursor) return Cursor;
169 procedure Previous (Position : in out Cursor);
171 function Find
172 (Container : List;
173 Item : Element_Type;
174 Position : Cursor := No_Element) return Cursor;
176 function Reverse_Find
177 (Container : List;
178 Item : Element_Type;
179 Position : Cursor := No_Element) return Cursor;
181 function Contains
182 (Container : List;
183 Item : Element_Type) return Boolean;
185 function Has_Element (Position : Cursor) return Boolean;
187 procedure Iterate
188 (Container : List;
189 Process : not null access procedure (Position : Cursor));
191 procedure Reverse_Iterate
192 (Container : List;
193 Process : not null access procedure (Position : Cursor));
195 generic
196 with function "<" (Left, Right : Element_Type) return Boolean is <>;
197 package Generic_Sorting is
199 function Is_Sorted (Container : List) return Boolean;
201 procedure Sort (Container : in out List);
203 procedure Merge (Target, Source : in out List);
205 end Generic_Sorting;
207 private
209 pragma Inline (Next);
210 pragma Inline (Previous);
212 type Node_Type;
213 type Node_Access is access Node_Type;
215 type Node_Type is
216 limited record
217 Element : Element_Type;
218 Next : Node_Access;
219 Prev : Node_Access;
220 end record;
222 use Ada.Finalization;
224 type List is
225 new Controlled with record
226 First : Node_Access;
227 Last : Node_Access;
228 Length : Count_Type := 0;
229 Busy : Natural := 0;
230 Lock : Natural := 0;
231 end record;
233 procedure Adjust (Container : in out List);
235 procedure Finalize (Container : in out List) renames Clear;
237 use Ada.Streams;
239 procedure Read
240 (Stream : not null access Root_Stream_Type'Class;
241 Item : out List);
243 for List'Read use Read;
245 procedure Write
246 (Stream : not null access Root_Stream_Type'Class;
247 Item : List);
249 for List'Write use Write;
251 type List_Access is access constant List;
252 for List_Access'Storage_Size use 0;
254 type Cursor is
255 record
256 Container : List_Access;
257 Node : Node_Access;
258 end record;
260 procedure Read
261 (Stream : not null access Root_Stream_Type'Class;
262 Item : out Cursor);
264 for Cursor'Read use Read;
266 procedure Write
267 (Stream : not null access Root_Stream_Type'Class;
268 Item : Cursor);
270 for Cursor'Write use Write;
272 Empty_List : constant List := (Controlled with null, null, 0, 0, 0);
274 No_Element : constant Cursor := Cursor'(null, null);
276 end Ada.Containers.Doubly_Linked_Lists;