1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- ADA.CONTAINERS.DOUBLY_LINKED_LISTS --
9 -- Copyright (C) 2004 Free Software Foundation, Inc. --
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. --
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, 59 Temple Place - Suite 330, Boston, --
24 -- MA 02111-1307, USA. --
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. --
33 -- This unit was originally developed by Matthew J Heaney. --
34 ------------------------------------------------------------------------------
36 with Ada.Finalization;
40 type Element_Type is private;
42 with function "=" (Left, Right : Element_Type)
45 package Ada.Containers.Doubly_Linked_Lists is
46 pragma Preelaborate (Doubly_Linked_Lists);
48 type List is tagged private;
50 type Cursor is private;
52 Empty_List : constant List;
54 No_Element : constant Cursor;
56 function "=" (Left, Right : List) return Boolean;
58 function Length (Container : List) return Count_Type;
60 function Is_Empty (Container : List) return Boolean;
62 procedure Clear (Container : in out List);
64 function Element (Position : Cursor) return Element_Type;
66 procedure Query_Element
68 Process : not null access procedure (Element : Element_Type));
70 procedure Update_Element
72 Process : not null access procedure (Element : in out Element_Type));
74 procedure Replace_Element
79 (Target : in out List;
80 Source : in out List);
83 (Container : in out List;
84 New_Item : Element_Type;
85 Count : Count_Type := 1);
88 (Container : in out List;
89 New_Item : Element_Type;
90 Count : Count_Type := 1);
93 (Container : in out List;
95 New_Item : Element_Type;
96 Count : Count_Type := 1);
99 (Container : in out List;
101 New_Item : Element_Type;
102 Position : out Cursor;
103 Count : Count_Type := 1);
106 (Container : in out List;
108 Position : out Cursor;
109 Count : Count_Type := 1);
112 (Container : in out List;
113 Position : in out Cursor;
114 Count : Count_Type := 1);
116 procedure Delete_First
117 (Container : in out List;
118 Count : Count_Type := 1);
120 procedure Delete_Last
121 (Container : in out List;
122 Count : Count_Type := 1);
125 with function "<" (Left, Right : Element_Type)
126 return Boolean is <>;
127 procedure Generic_Sort (Container : in out List);
130 with function "<" (Left, Right : Element_Type)
131 return Boolean is <>;
132 procedure Generic_Merge (Target : in out List; Source : in out List);
134 procedure Reverse_List (Container : in out List);
136 procedure Swap (I, J : in Cursor);
139 (Container : in out List;
143 (Target : in out List;
145 Source : in out List);
148 (Target : in out List;
153 (Target : in out List;
155 Source : in out List;
158 function First (Container : List) return Cursor;
160 function First_Element (Container : List) return Element_Type;
162 function Last (Container : List) return Cursor;
164 function Last_Element (Container : List) return Element_Type;
168 Item : Element_Type) return Boolean;
173 Position : Cursor := No_Element) return Cursor;
175 function Reverse_Find
178 Position : Cursor := No_Element) return Cursor;
180 function Next (Position : Cursor) return Cursor;
182 function Previous (Position : Cursor) return Cursor;
184 procedure Next (Position : in out Cursor);
186 procedure Previous (Position : in out Cursor);
188 function Has_Element (Position : Cursor) return Boolean;
192 Process : not null access procedure (Position : Cursor));
194 procedure Reverse_Iterate
196 Process : not null access procedure (Position : Cursor));
200 type Node_Access is access Node_Type;
204 Element : Element_Type;
209 function "=" (L, R : Node_Type) return Boolean is abstract;
211 use Ada.Finalization;
214 new Controlled with record
217 Length : Count_Type := 0;
220 procedure Adjust (Container : in out List);
222 procedure Finalize (Container : in out List) renames Clear;
227 (Stream : access Root_Stream_Type'Class;
230 for List'Read use Read;
233 (Stream : access Root_Stream_Type'Class;
236 for List'Write use Write;
238 Empty_List : constant List := List'(Controlled with null, null, 0);
240 type List_Access is access constant List;
241 for List_Access'Storage_Size use 0;
245 Container : List_Access;
249 No_Element : constant Cursor := Cursor'(null, null);
251 end Ada.Containers.Doubly_Linked_Lists;