1 | |
---|
2 | |
---|
3 | |
---|
4 | |
---|
5 | |
---|
6 | |
---|
7 | |
---|
8 | |
---|
9 | |
---|
10 | |
---|
11 | |
---|
12 | |
---|
13 | |
---|
14 | |
---|
15 | |
---|
16 | |
---|
17 | |
---|
18 | |
---|
19 | |
---|
20 | |
---|
21 | |
---|
22 | |
---|
23 | |
---|
24 | |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | generic |
---|
44 | type Element_Type is private; |
---|
45 | |
---|
46 | with function "=" (Left, Right : Element_Type) |
---|
47 | return Boolean is <>; |
---|
48 | |
---|
49 | package Ada_Containers.AUnit_Lists is |
---|
50 | |
---|
51 | type List is tagged limited private; |
---|
52 | |
---|
53 | type Cursor is private; |
---|
54 | |
---|
55 | |
---|
56 | |
---|
57 | No_Element : constant Cursor; |
---|
58 | |
---|
59 | function "=" (Left, Right : List) return Boolean; |
---|
60 | |
---|
61 | function Length (Container : List) return Count_Type; |
---|
62 | |
---|
63 | function Is_Empty (Container : List) return Boolean; |
---|
64 | |
---|
65 | procedure Clear (Container : in out List); |
---|
66 | |
---|
67 | function Element (Position : Cursor) return Element_Type; |
---|
68 | |
---|
69 | procedure Replace_Element |
---|
70 | (Container : in out List; |
---|
71 | Position : Cursor; |
---|
72 | New_Item : Element_Type); |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | procedure Move |
---|
84 | (Target : in out List; |
---|
85 | Source : in out List); |
---|
86 | |
---|
87 | procedure Insert |
---|
88 | (Container : in out List; |
---|
89 | Before : Cursor; |
---|
90 | New_Item : Element_Type; |
---|
91 | Count : Count_Type := 1); |
---|
92 | |
---|
93 | procedure Insert |
---|
94 | (Container : in out List; |
---|
95 | Before : Cursor; |
---|
96 | New_Item : Element_Type; |
---|
97 | Position : out Cursor; |
---|
98 | Count : Count_Type := 1); |
---|
99 | |
---|
100 | procedure Insert |
---|
101 | (Container : in out List; |
---|
102 | Before : Cursor; |
---|
103 | Position : out Cursor; |
---|
104 | Count : Count_Type := 1); |
---|
105 | |
---|
106 | procedure Prepend |
---|
107 | (Container : in out List; |
---|
108 | New_Item : Element_Type; |
---|
109 | Count : Count_Type := 1); |
---|
110 | |
---|
111 | procedure Append |
---|
112 | (Container : in out List; |
---|
113 | New_Item : Element_Type; |
---|
114 | Count : Count_Type := 1); |
---|
115 | |
---|
116 | procedure Delete |
---|
117 | (Container : in out List; |
---|
118 | Position : in out Cursor; |
---|
119 | Count : Count_Type := 1); |
---|
120 | |
---|
121 | procedure Delete_First |
---|
122 | (Container : in out List; |
---|
123 | Count : Count_Type := 1); |
---|
124 | |
---|
125 | procedure Delete_Last |
---|
126 | (Container : in out List; |
---|
127 | Count : Count_Type := 1); |
---|
128 | |
---|
129 | procedure Reverse_Elements (Container : in out List); |
---|
130 | |
---|
131 | procedure Swap |
---|
132 | (Container : in out List; |
---|
133 | I, J : Cursor); |
---|
134 | |
---|
135 | procedure Swap_Links |
---|
136 | (Container : in out List; |
---|
137 | I, J : Cursor); |
---|
138 | |
---|
139 | procedure Splice |
---|
140 | (Target : in out List; |
---|
141 | Before : Cursor; |
---|
142 | Source : in out List); |
---|
143 | |
---|
144 | procedure Splice |
---|
145 | (Target : in out List; |
---|
146 | Before : Cursor; |
---|
147 | Source : in out List; |
---|
148 | Position : in out Cursor); |
---|
149 | |
---|
150 | procedure Splice |
---|
151 | (Container : in out List; |
---|
152 | Before : Cursor; |
---|
153 | Position : Cursor); |
---|
154 | |
---|
155 | function First (Container : List) return Cursor; |
---|
156 | |
---|
157 | function First_Element (Container : List) return Element_Type; |
---|
158 | |
---|
159 | function Last (Container : List) return Cursor; |
---|
160 | |
---|
161 | function Last_Element (Container : List) return Element_Type; |
---|
162 | |
---|
163 | function Next (Position : Cursor) return Cursor; |
---|
164 | |
---|
165 | procedure Next (Position : in out Cursor); |
---|
166 | |
---|
167 | function Previous (Position : Cursor) return Cursor; |
---|
168 | |
---|
169 | procedure Previous (Position : in out Cursor); |
---|
170 | |
---|
171 | function Find |
---|
172 | (Container : List; |
---|
173 | Item : Element_Type; |
---|
174 | Position : Cursor := No_Element) return Cursor; |
---|
175 | |
---|
176 | function Reverse_Find |
---|
177 | (Container : List; |
---|
178 | Item : Element_Type; |
---|
179 | Position : Cursor := No_Element) return Cursor; |
---|
180 | |
---|
181 | function Contains |
---|
182 | (Container : List; |
---|
183 | Item : Element_Type) return Boolean; |
---|
184 | |
---|
185 | function Has_Element (Position : Cursor) return Boolean; |
---|
186 | |
---|
187 | type Iterator is access procedure (Position : Cursor); |
---|
188 | |
---|
189 | procedure Iterate |
---|
190 | (Container : List; |
---|
191 | Process : Iterator); |
---|
192 | |
---|
193 | |
---|
194 | |
---|
195 | |
---|
196 | |
---|
197 | generic |
---|
198 | with function "<" (Left, Right : Element_Type) return Boolean is <>; |
---|
199 | package Generic_Sorting is |
---|
200 | |
---|
201 | function Is_Sorted (Container : List) return Boolean; |
---|
202 | |
---|
203 | procedure Sort (Container : in out List); |
---|
204 | |
---|
205 | procedure Merge (Target, Source : in out List); |
---|
206 | |
---|
207 | end Generic_Sorting; |
---|
208 | |
---|
209 | private |
---|
210 | |
---|
211 | pragma Inline (Next); |
---|
212 | pragma Inline (Previous); |
---|
213 | |
---|
214 | type Node_Type; |
---|
215 | type Node_Access is access Node_Type; |
---|
216 | pragma No_Strict_Aliasing (Node_Access); |
---|
217 | |
---|
218 | type Node_Type is limited record |
---|
219 | Element : Element_Type; |
---|
220 | Next : Node_Access; |
---|
221 | Prev : Node_Access; |
---|
222 | end record; |
---|
223 | |
---|
224 | type List is tagged limited record |
---|
225 | First : Node_Access := null; |
---|
226 | Last : Node_Access := null; |
---|
227 | Length : Count_Type := 0; |
---|
228 | Busy : Natural := 0; |
---|
229 | Lock : Natural := 0; |
---|
230 | end record; |
---|
231 | |
---|
232 | type List_Access is access constant List; |
---|
233 | |
---|
234 | type Cursor is record |
---|
235 | Container : List_Access; |
---|
236 | Node : Node_Access; |
---|
237 | end record; |
---|
238 | |
---|
239 | |
---|
240 | |
---|
241 | No_Element : constant Cursor := (null, null); |
---|
242 | |
---|
243 | end Ada_Containers.AUnit_Lists; |
---|