1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
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 --
10 -- Copyright (C) 2004-2007, Free Software Foundation, Inc. --
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. --
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. --
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. --
34 -- This unit was originally developed by Matthew J Heaney. --
35 ------------------------------------------------------------------------------
37 with Ada.Finalization;
41 type Element_Type (<>) is private;
43 with function "=" (Left, Right : Element_Type)
46 package Ada.Containers.Indefinite_Doubly_Linked_Lists is
50 type List is tagged private;
51 pragma Preelaborable_Initialization (List);
53 type Cursor is private;
54 pragma Preelaborable_Initialization (Cursor);
56 Empty_List : constant List;
58 No_Element : constant Cursor;
60 function "=" (Left, Right : List) return Boolean;
62 function Length (Container : List) return Count_Type;
64 function Is_Empty (Container : List) return Boolean;
66 procedure Clear (Container : in out List);
68 function Element (Position : Cursor) return Element_Type;
70 procedure Replace_Element
71 (Container : in out List;
73 New_Item : Element_Type);
75 procedure Query_Element
77 Process : not null access procedure (Element : Element_Type));
79 procedure Update_Element
80 (Container : in out List;
82 Process : not null access procedure (Element : in out Element_Type));
85 (Target : in out List;
86 Source : in out List);
89 (Container : in out List;
91 New_Item : Element_Type;
92 Count : Count_Type := 1);
95 (Container : in out List;
97 New_Item : Element_Type;
98 Position : out Cursor;
99 Count : Count_Type := 1);
102 (Container : in out List;
103 New_Item : Element_Type;
104 Count : Count_Type := 1);
107 (Container : in out List;
108 New_Item : Element_Type;
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);
124 procedure Reverse_Elements (Container : in out List);
126 procedure Swap (Container : in out List; I, J : Cursor);
128 procedure Swap_Links (Container : in out List; I, J : Cursor);
131 (Target : in out List;
133 Source : in out List);
136 (Target : in out List;
138 Source : in out List;
139 Position : in out Cursor);
142 (Container : in out List;
146 function First (Container : List) return Cursor;
148 function First_Element (Container : List) return Element_Type;
150 function Last (Container : List) return Cursor;
152 function Last_Element (Container : List) return Element_Type;
154 function Next (Position : Cursor) return Cursor;
156 procedure Next (Position : in out Cursor);
158 function Previous (Position : Cursor) return Cursor;
160 procedure Previous (Position : in out Cursor);
165 Position : Cursor := No_Element) return Cursor;
167 function Reverse_Find
170 Position : Cursor := No_Element) return Cursor;
174 Item : Element_Type) return Boolean;
176 function Has_Element (Position : Cursor) return Boolean;
180 Process : not null access procedure (Position : Cursor));
182 procedure Reverse_Iterate
184 Process : not null access procedure (Position : Cursor));
187 with function "<" (Left, Right : Element_Type) return Boolean is <>;
188 package Generic_Sorting is
190 function Is_Sorted (Container : List) return Boolean;
192 procedure Sort (Container : in out List);
194 procedure Merge (Target, Source : in out List);
200 pragma Inline (Next);
201 pragma Inline (Previous);
204 type Node_Access is access Node_Type;
206 type Element_Access is access Element_Type;
210 Element : Element_Access;
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 : not null access Root_Stream_Type'Class;
236 for List'Read use Read;
239 (Stream : not null access Root_Stream_Type'Class;
242 for List'Write use Write;
244 type List_Access is access constant List;
245 for List_Access'Storage_Size use 0;
249 Container : List_Access;
254 (Stream : not null access Root_Stream_Type'Class;
257 for Cursor'Read use Read;
260 (Stream : not null access Root_Stream_Type'Class;
263 for Cursor'Write use Write;
265 Empty_List : constant List := List'(Controlled with null, null, 0, 0, 0);
267 No_Element : constant Cursor := Cursor'(null, null);
269 end Ada.Containers.Indefinite_Doubly_Linked_Lists;