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-2009, 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 3, 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. --
22 -- As a special exception under Section 7 of GPL version 3, you are granted --
23 -- additional permissions described in the GCC Runtime Library Exception, --
24 -- version 3.1, as published by the Free Software Foundation. --
26 -- You should have received a copy of the GNU General Public License and --
27 -- a copy of the GCC Runtime Library Exception along with this program; --
28 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
29 -- <http://www.gnu.org/licenses/>. --
31 -- This unit was originally developed by Matthew J Heaney. --
32 ------------------------------------------------------------------------------
34 private with Ada.Finalization;
35 private with Ada.Streams;
38 type Element_Type is private;
40 with function "=" (Left, Right : Element_Type)
43 package Ada.Containers.Doubly_Linked_Lists is
47 type List is tagged private;
48 pragma Preelaborable_Initialization (List);
50 type Cursor is private;
51 pragma Preelaborable_Initialization (Cursor);
53 Empty_List : constant List;
55 No_Element : constant Cursor;
57 function "=" (Left, Right : List) return Boolean;
59 function Length (Container : List) return Count_Type;
61 function Is_Empty (Container : List) return Boolean;
63 procedure Clear (Container : in out List);
65 function Element (Position : Cursor) return Element_Type;
67 procedure Replace_Element
68 (Container : in out List;
70 New_Item : Element_Type);
72 procedure Query_Element
74 Process : not null access procedure (Element : Element_Type));
76 procedure Update_Element
77 (Container : in out List;
79 Process : not null access procedure (Element : in out Element_Type));
82 (Target : in out List;
83 Source : in out List);
86 (Container : in out List;
88 New_Item : Element_Type;
89 Count : Count_Type := 1);
92 (Container : in out List;
94 New_Item : Element_Type;
95 Position : out Cursor;
96 Count : Count_Type := 1);
99 (Container : in out List;
101 Position : out Cursor;
102 Count : Count_Type := 1);
105 (Container : in out List;
106 New_Item : Element_Type;
107 Count : Count_Type := 1);
110 (Container : in out List;
111 New_Item : Element_Type;
112 Count : Count_Type := 1);
115 (Container : in out List;
116 Position : in out Cursor;
117 Count : Count_Type := 1);
119 procedure Delete_First
120 (Container : in out List;
121 Count : Count_Type := 1);
123 procedure Delete_Last
124 (Container : in out List;
125 Count : Count_Type := 1);
127 procedure Reverse_Elements (Container : in out List);
130 (Container : in out List;
134 (Container : in out List;
138 (Target : in out List;
140 Source : in out List);
143 (Target : in out List;
145 Source : in out List;
146 Position : in out Cursor);
149 (Container : in out List;
153 function First (Container : List) return Cursor;
155 function First_Element (Container : List) return Element_Type;
157 function Last (Container : List) return Cursor;
159 function Last_Element (Container : List) return Element_Type;
161 function Next (Position : Cursor) return Cursor;
163 procedure Next (Position : in out Cursor);
165 function Previous (Position : Cursor) return Cursor;
167 procedure Previous (Position : in out Cursor);
172 Position : Cursor := No_Element) return Cursor;
174 function Reverse_Find
177 Position : Cursor := No_Element) return Cursor;
181 Item : Element_Type) return Boolean;
183 function Has_Element (Position : Cursor) return Boolean;
187 Process : not null access procedure (Position : Cursor));
189 procedure Reverse_Iterate
191 Process : not null access procedure (Position : Cursor));
194 with function "<" (Left, Right : Element_Type) return Boolean is <>;
195 package Generic_Sorting is
197 function Is_Sorted (Container : List) return Boolean;
199 procedure Sort (Container : in out List);
201 procedure Merge (Target, Source : in out List);
207 pragma Inline (Next);
208 pragma Inline (Previous);
211 type Node_Access is access Node_Type;
215 Element : Element_Type;
220 use Ada.Finalization;
223 new Controlled with record
226 Length : Count_Type := 0;
232 procedure Adjust (Container : in out List);
235 procedure Finalize (Container : in out List) renames Clear;
240 (Stream : not null access Root_Stream_Type'Class;
243 for List'Read use Read;
246 (Stream : not null access Root_Stream_Type'Class;
249 for List'Write use Write;
251 type List_Access is access constant List;
252 for List_Access'Storage_Size use 0;
256 Container : List_Access;
261 (Stream : not null access Root_Stream_Type'Class;
264 for Cursor'Read use Read;
267 (Stream : not null access Root_Stream_Type'Class;
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;