1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- ADA.CONTAINERS.RESTRICTED_DOUBLY_LINKED_LISTS --
9 -- Copyright (C) 2004-2007, 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 -- Documentation required for this unit ???
39 type Element_Type is private;
41 with function "=" (Left, Right : Element_Type)
44 package Ada.Containers.Restricted_Doubly_Linked_Lists is
47 type List (Capacity : Count_Type) is tagged limited 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 procedure Assign (Target : in out List; Source : List);
61 function Length (Container : List) return Count_Type;
63 function Is_Empty (Container : List) return Boolean;
65 procedure Clear (Container : in out List);
67 function Element (Position : Cursor) return Element_Type;
69 procedure Replace_Element
70 (Container : in out List;
72 New_Item : Element_Type);
74 procedure Query_Element
76 Process : not null access procedure (Element : Element_Type));
78 procedure Update_Element
79 (Container : in out List;
81 Process : not null access procedure (Element : in out Element_Type));
84 (Container : in out List;
86 New_Item : Element_Type;
87 Count : Count_Type := 1);
90 (Container : in out List;
92 New_Item : Element_Type;
93 Position : out Cursor;
94 Count : Count_Type := 1);
97 (Container : in out List;
99 Position : out Cursor;
100 Count : Count_Type := 1);
103 (Container : in out List;
104 New_Item : Element_Type;
105 Count : Count_Type := 1);
108 (Container : in out List;
109 New_Item : Element_Type;
110 Count : Count_Type := 1);
113 (Container : in out List;
114 Position : in out Cursor;
115 Count : Count_Type := 1);
117 procedure Delete_First
118 (Container : in out List;
119 Count : Count_Type := 1);
121 procedure Delete_Last
122 (Container : in out List;
123 Count : Count_Type := 1);
125 procedure Reverse_Elements (Container : in out List);
128 (Container : in out List;
132 (Container : in out List;
136 (Container : in out List;
138 Position : in out Cursor);
140 function First (Container : List) return Cursor;
142 function First_Element (Container : List) return Element_Type;
144 function Last (Container : List) return Cursor;
146 function Last_Element (Container : List) return Element_Type;
148 function Next (Position : Cursor) return Cursor;
150 procedure Next (Position : in out Cursor);
152 function Previous (Position : Cursor) return Cursor;
154 procedure Previous (Position : in out Cursor);
159 Position : Cursor := No_Element) return Cursor;
161 function Reverse_Find
164 Position : Cursor := No_Element) return Cursor;
168 Item : Element_Type) return Boolean;
170 function Has_Element (Position : Cursor) return Boolean;
174 Process : not null access procedure (Position : Cursor));
176 procedure Reverse_Iterate
178 Process : not null access procedure (Position : Cursor));
181 with function "<" (Left, Right : Element_Type) return Boolean is <>;
182 package Generic_Sorting is
184 function Is_Sorted (Container : List) return Boolean;
186 procedure Sort (Container : in out List);
192 type Node_Type is limited record
193 Prev : Count_Type'Base;
195 Element : Element_Type;
198 type Node_Array is array (Count_Type range <>) of Node_Type;
200 type List (Capacity : Count_Type) is tagged limited record
201 Nodes : Node_Array (1 .. Capacity) := (others => <>);
202 Free : Count_Type'Base := -1;
203 First : Count_Type := 0;
204 Last : Count_Type := 0;
205 Length : Count_Type := 0;
208 Empty_List : constant List := (0, others => <>);
210 type List_Access is access all List;
211 for List_Access'Storage_Size use 0;
215 Container : List_Access;
216 Node : Count_Type := 0;
219 No_Element : constant Cursor := (null, 0);
221 end Ada.Containers.Restricted_Doubly_Linked_Lists;