1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- A D A . C O N T A I N E R S . --
6 -- R E S R I C T E D _ D O U B L Y _ L I N K E D _ L I S T S --
10 -- Copyright (C) 2004-2006, 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 ------------------------------------------------------------------------------
38 type Element_Type
is private;
40 with function "=" (Left
, Right
: Element_Type
)
43 package Ada
.Containers
.Restricted_Doubly_Linked_Lists
is
46 type List
(Capacity
: Count_Type
) is tagged limited private;
47 pragma Preelaborable_Initialization
(List
);
49 type Cursor
is private;
50 pragma Preelaborable_Initialization
(Cursor
);
52 Empty_List
: constant List
;
54 No_Element
: constant Cursor
;
56 function "=" (Left
, Right
: List
) return Boolean;
58 procedure Assign
(Target
: in out List
; Source
: List
);
60 function Length
(Container
: List
) return Count_Type
;
62 function Is_Empty
(Container
: List
) return Boolean;
64 procedure Clear
(Container
: in out List
);
66 function Element
(Position
: Cursor
) return Element_Type
;
68 procedure Replace_Element
69 (Container
: in out List
;
71 New_Item
: Element_Type
);
73 procedure Query_Element
75 Process
: not null access procedure (Element
: Element_Type
));
77 procedure Update_Element
78 (Container
: in out List
;
80 Process
: not null access procedure (Element
: in out Element_Type
));
83 (Container
: in out List
;
85 New_Item
: Element_Type
;
86 Count
: Count_Type
:= 1);
89 (Container
: in out List
;
91 New_Item
: Element_Type
;
92 Position
: out Cursor
;
93 Count
: Count_Type
:= 1);
96 (Container
: in out List
;
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
);
127 (Container
: in out List
;
131 (Container
: in out List
;
135 (Container
: in out List
;
137 Position
: in out Cursor
);
139 function First
(Container
: List
) return Cursor
;
141 function First_Element
(Container
: List
) return Element_Type
;
143 function Last
(Container
: List
) return Cursor
;
145 function Last_Element
(Container
: List
) return Element_Type
;
147 function Next
(Position
: Cursor
) return Cursor
;
149 procedure Next
(Position
: in out Cursor
);
151 function Previous
(Position
: Cursor
) return Cursor
;
153 procedure Previous
(Position
: in out Cursor
);
158 Position
: Cursor
:= No_Element
) return Cursor
;
160 function Reverse_Find
163 Position
: Cursor
:= No_Element
) return Cursor
;
167 Item
: Element_Type
) return Boolean;
169 function Has_Element
(Position
: Cursor
) return Boolean;
173 Process
: not null access procedure (Position
: Cursor
));
175 procedure Reverse_Iterate
177 Process
: not null access procedure (Position
: Cursor
));
180 with function "<" (Left
, Right
: Element_Type
) return Boolean is <>;
181 package Generic_Sorting
is
183 function Is_Sorted
(Container
: List
) return Boolean;
185 procedure Sort
(Container
: in out List
);
191 type Node_Type
is limited record
192 Prev
: Count_Type
'Base;
194 Element
: Element_Type
;
197 type Node_Array
is array (Count_Type
range <>) of Node_Type
;
199 type List
(Capacity
: Count_Type
) is tagged limited record
200 Nodes
: Node_Array
(1 .. Capacity
) := (others => <>);
201 Free
: Count_Type
'Base := -1;
202 First
: Count_Type
:= 0;
203 Last
: Count_Type
:= 0;
204 Length
: Count_Type
:= 0;
207 Empty_List
: constant List
:= (0, others => <>);
209 type List_Access
is access all List
;
210 for List_Access
'Storage_Size use 0;
214 Container
: List_Access
;
215 Node
: Count_Type
:= 0;
218 No_Element
: constant Cursor
:= (null, 0);
220 end Ada
.Containers
.Restricted_Doubly_Linked_Lists
;