1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
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 --
9 -- Copyright (C) 2004-2005, 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, 51 Franklin Street, Fifth Floor, --
24 -- Boston, MA 02110-1301, 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
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 Replace_Element
67 (Container : in out List;
69 New_Item : Element_Type);
71 procedure Query_Element
73 Process : not null access procedure (Element : Element_Type));
75 procedure Update_Element
76 (Container : in out List;
78 Process : not null access procedure (Element : in out Element_Type));
81 (Target : in out List;
82 Source : in out List);
85 (Container : in out List;
87 New_Item : Element_Type;
88 Count : Count_Type := 1);
91 (Container : in out List;
93 New_Item : Element_Type;
94 Position : out Cursor;
95 Count : Count_Type := 1);
98 (Container : in out List;
100 Position : out Cursor;
101 Count : Count_Type := 1);
104 (Container : in out List;
105 New_Item : Element_Type;
106 Count : Count_Type := 1);
109 (Container : in out List;
110 New_Item : Element_Type;
111 Count : Count_Type := 1);
114 (Container : in out List;
115 Position : in out Cursor;
116 Count : Count_Type := 1);
118 procedure Delete_First
119 (Container : in out List;
120 Count : Count_Type := 1);
122 procedure Delete_Last
123 (Container : in out List;
124 Count : Count_Type := 1);
126 procedure Reverse_Elements (Container : in out List);
129 (Container : in out List;
133 (Container : in out List;
137 (Target : in out List;
139 Source : in out List);
142 (Target : in out List;
144 Source : in out List;
145 Position : in out Cursor);
148 (Container : in out List;
150 Position : in out Cursor);
152 function First (Container : List) return Cursor;
154 function First_Element (Container : List) return Element_Type;
156 function Last (Container : List) return Cursor;
158 function Last_Element (Container : List) return Element_Type;
160 function Next (Position : Cursor) return Cursor;
162 procedure Next (Position : in out Cursor);
164 function Previous (Position : Cursor) return Cursor;
166 procedure Previous (Position : in out Cursor);
171 Position : Cursor := No_Element) return Cursor;
173 function Reverse_Find
176 Position : Cursor := No_Element) return Cursor;
180 Item : Element_Type) return Boolean;
182 function Has_Element (Position : Cursor) return Boolean;
186 Process : not null access procedure (Position : Cursor));
188 procedure Reverse_Iterate
190 Process : not null access procedure (Position : Cursor));
193 with function "<" (Left, Right : Element_Type) return Boolean is <>;
194 package Generic_Sorting is
196 function Is_Sorted (Container : List) return Boolean;
198 procedure Sort (Container : in out List);
200 procedure Merge (Target, Source : in out List);
206 type Node_Access is access Node_Type;
210 Element : Element_Type;
215 use Ada.Finalization;
218 new Controlled with record
221 Length : Count_Type := 0;
226 procedure Adjust (Container : in out List);
228 procedure Finalize (Container : in out List) renames Clear;
233 (Stream : access Root_Stream_Type'Class;
236 for List'Read use Read;
239 (Stream : access Root_Stream_Type'Class;
242 for List'Write use Write;
244 Empty_List : constant List := (Controlled with null, null, 0, 0, 0);
246 type List_Access is access constant List;
247 for List_Access'Storage_Size use 0;
251 Container : List_Access;
256 (Stream : access Root_Stream_Type'Class;
259 for Cursor'Read use Read;
262 (Stream : access Root_Stream_Type'Class;
265 for Cursor'Write use Write;
267 No_Element : constant Cursor := Cursor'(null, null);
269 end Ada.Containers.Doubly_Linked_Lists;