1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- ADA.CONTAINERS.INDEFINITE_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;
41 type Element_Type (<>) is private;
43 with function "=" (Left, Right : Element_Type)
46 package Ada.Containers.Indefinite_Doubly_Linked_Lists is
47 pragma Preelaborate (Indefinite_Doubly_Linked_Lists);
49 type List is tagged private;
51 type Cursor is private;
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)
68 procedure Query_Element
70 Process : not null access procedure (Element : Element_Type));
72 procedure Update_Element
74 Process : not null access procedure (Element : in out Element_Type));
76 procedure Replace_Element
81 (Target : in out List;
82 Source : in out List);
85 (Container : in out List;
86 New_Item : Element_Type;
87 Count : Count_Type := 1);
90 (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 Count : Count_Type := 1);
101 (Container : in out List;
103 New_Item : Element_Type;
104 Position : out Cursor;
105 Count : Count_Type := 1);
108 (Container : in out List;
109 Position : in out Cursor;
110 Count : Count_Type := 1);
112 procedure Delete_First
113 (Container : in out List;
114 Count : Count_Type := 1);
116 procedure Delete_Last
117 (Container : in out List;
118 Count : Count_Type := 1);
121 with function "<" (Left, Right : Element_Type)
122 return Boolean is <>;
123 procedure Generic_Sort (Container : in out List);
126 with function "<" (Left, Right : Element_Type)
127 return Boolean is <>;
128 procedure Generic_Merge
129 (Target : in out List;
130 Source : in out List);
132 procedure Reverse_List (Container : in out List);
134 procedure Swap (I, J : Cursor);
136 procedure Swap_Links (Container : in out List; I, J : Cursor);
139 (Target : in out List;
141 Source : in out List);
144 (Target : in out List;
149 (Target : in out List;
151 Source : in out List;
154 function First (Container : List) return Cursor;
156 function First_Element (Container : List) return Element_Type;
158 function Last (Container : List) return Cursor;
160 function Last_Element (Container : List) return Element_Type;
164 Item : Element_Type) return Boolean;
169 Position : Cursor := No_Element) return Cursor;
171 function Reverse_Find
174 Position : Cursor := No_Element) return Cursor;
176 function Next (Position : Cursor) return Cursor;
178 function Previous (Position : Cursor) return Cursor;
180 procedure Next (Position : in out Cursor);
182 procedure Previous (Position : in out Cursor);
184 function Has_Element (Position : Cursor) return Boolean;
188 Process : not null access procedure (Position : Cursor));
190 procedure Reverse_Iterate
192 Process : not null access procedure (Position : Cursor));
196 type Node_Access is access Node_Type;
198 type Element_Access is access Element_Type;
202 Element : Element_Access;
207 function "=" (L, R : Node_Type) return Boolean is abstract;
209 use Ada.Finalization;
212 new Controlled with record
215 Length : Count_Type := 0;
218 procedure Adjust (Container : in out List);
220 procedure Finalize (Container : in out List) renames Clear;
225 (Stream : access Root_Stream_Type'Class;
228 for List'Read use Read;
231 (Stream : access Root_Stream_Type'Class;
234 for List'Write use Write;
236 Empty_List : constant List := List'(Controlled with null, null, 0);
238 type List_Access is access constant List;
239 for List_Access'Storage_Size use 0;
243 Container : List_Access;
247 No_Element : constant Cursor := Cursor'(null, null);
249 end Ada.Containers.Indefinite_Doubly_Linked_Lists;