annotate gcc/ada/libgnat/a-cofuve.ads @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT LIBRARY COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- ADA.CONTAINERS.FUNCTIONAL_VECTORS --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 2016-2017, Free Software Foundation, Inc. --
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- This specification is derived from the Ada Reference Manual for use with --
kono
parents:
diff changeset
12 -- GNAT. The copyright notice above, and the license provisions that follow --
kono
parents:
diff changeset
13 -- apply solely to the contents of the part following the private keyword. --
kono
parents:
diff changeset
14 -- --
kono
parents:
diff changeset
15 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
16 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
17 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
18 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
19 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
20 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
23 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
24 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
25 -- --
kono
parents:
diff changeset
26 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
27 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
28 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
29 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 pragma Ada_2012;
kono
parents:
diff changeset
33 private with Ada.Containers.Functional_Base;
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 generic
kono
parents:
diff changeset
36 type Index_Type is (<>);
kono
parents:
diff changeset
37 -- To avoid Constraint_Error being raised at run time, Index_Type'Base
kono
parents:
diff changeset
38 -- should have at least one more element at the low end than Index_Type.
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 type Element_Type (<>) is private;
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 package Ada.Containers.Functional_Vectors with SPARK_Mode is
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 subtype Extended_Index is Index_Type'Base range
kono
parents:
diff changeset
45 Index_Type'Pred (Index_Type'First) .. Index_Type'Last;
kono
parents:
diff changeset
46 -- Index_Type with one more element at the low end of the range.
kono
parents:
diff changeset
47 -- This type is never used but it forces GNATprove to check that there is
kono
parents:
diff changeset
48 -- room for one more element at the low end of Index_Type.
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 type Sequence is private
kono
parents:
diff changeset
51 with Default_Initial_Condition => Length (Sequence) = 0,
kono
parents:
diff changeset
52 Iterable => (First => Iter_First,
kono
parents:
diff changeset
53 Has_Element => Iter_Has_Element,
kono
parents:
diff changeset
54 Next => Iter_Next,
kono
parents:
diff changeset
55 Element => Get);
kono
parents:
diff changeset
56 -- Sequences are empty when default initialized.
kono
parents:
diff changeset
57 -- Quantification over sequences can be done using the regular
kono
parents:
diff changeset
58 -- quantification over its range or directly on its elements with "for of".
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 -----------------------
kono
parents:
diff changeset
61 -- Basic operations --
kono
parents:
diff changeset
62 -----------------------
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 -- Sequences are axiomatized using Length and Get, providing respectively
kono
parents:
diff changeset
65 -- the length of a sequence and an accessor to its Nth element:
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 function Length (Container : Sequence) return Count_Type with
kono
parents:
diff changeset
68 -- Length of a sequence
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 Global => null,
kono
parents:
diff changeset
71 Post =>
kono
parents:
diff changeset
72 (Index_Type'Pos (Index_Type'First) - 1) + Length'Result <=
kono
parents:
diff changeset
73 Index_Type'Pos (Index_Type'Last);
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 function Get
kono
parents:
diff changeset
76 (Container : Sequence;
kono
parents:
diff changeset
77 Position : Extended_Index) return Element_Type
kono
parents:
diff changeset
78 -- Access the Element at position Position in Container
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 with
kono
parents:
diff changeset
81 Global => null,
kono
parents:
diff changeset
82 Pre => Position in Index_Type'First .. Last (Container);
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 function Last (Container : Sequence) return Extended_Index with
kono
parents:
diff changeset
85 -- Last index of a sequence
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 Global => null,
kono
parents:
diff changeset
88 Post =>
kono
parents:
diff changeset
89 Last'Result =
kono
parents:
diff changeset
90 Index_Type'Val ((Index_Type'Pos (Index_Type'First) - 1) +
kono
parents:
diff changeset
91 Length (Container));
kono
parents:
diff changeset
92 pragma Annotate (GNATprove, Inline_For_Proof, Last);
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 function First return Extended_Index is (Index_Type'First);
kono
parents:
diff changeset
95 -- First index of a sequence
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 ------------------------
kono
parents:
diff changeset
98 -- Property Functions --
kono
parents:
diff changeset
99 ------------------------
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 function "=" (Left : Sequence; Right : Sequence) return Boolean with
kono
parents:
diff changeset
102 -- Extensional equality over sequences
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 Global => null,
kono
parents:
diff changeset
105 Post =>
kono
parents:
diff changeset
106 "="'Result =
kono
parents:
diff changeset
107 (Length (Left) = Length (Right)
kono
parents:
diff changeset
108 and then (for all N in Index_Type'First .. Last (Left) =>
kono
parents:
diff changeset
109 Get (Left, N) = Get (Right, N)));
kono
parents:
diff changeset
110 pragma Annotate (GNATprove, Inline_For_Proof, "=");
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 function "<" (Left : Sequence; Right : Sequence) return Boolean with
kono
parents:
diff changeset
113 -- Left is a strict subsequence of Right
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 Global => null,
kono
parents:
diff changeset
116 Post =>
kono
parents:
diff changeset
117 "<"'Result =
kono
parents:
diff changeset
118 (Length (Left) < Length (Right)
kono
parents:
diff changeset
119 and then (for all N in Index_Type'First .. Last (Left) =>
kono
parents:
diff changeset
120 Get (Left, N) = Get (Right, N)));
kono
parents:
diff changeset
121 pragma Annotate (GNATprove, Inline_For_Proof, "<");
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 function "<=" (Left : Sequence; Right : Sequence) return Boolean with
kono
parents:
diff changeset
124 -- Left is a subsequence of Right
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 Global => null,
kono
parents:
diff changeset
127 Post =>
kono
parents:
diff changeset
128 "<="'Result =
kono
parents:
diff changeset
129 (Length (Left) <= Length (Right)
kono
parents:
diff changeset
130 and then (for all N in Index_Type'First .. Last (Left) =>
kono
parents:
diff changeset
131 Get (Left, N) = Get (Right, N)));
kono
parents:
diff changeset
132 pragma Annotate (GNATprove, Inline_For_Proof, "<=");
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 function Contains
kono
parents:
diff changeset
135 (Container : Sequence;
kono
parents:
diff changeset
136 Fst : Index_Type;
kono
parents:
diff changeset
137 Lst : Extended_Index;
kono
parents:
diff changeset
138 Item : Element_Type) return Boolean
kono
parents:
diff changeset
139 -- Returns True if Item occurs in the range from Fst to Lst of Container
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 with
kono
parents:
diff changeset
142 Global => null,
kono
parents:
diff changeset
143 Pre => Lst <= Last (Container),
kono
parents:
diff changeset
144 Post =>
kono
parents:
diff changeset
145 Contains'Result =
kono
parents:
diff changeset
146 (for some I in Fst .. Lst => Get (Container, I) = Item);
kono
parents:
diff changeset
147 pragma Annotate (GNATprove, Inline_For_Proof, Contains);
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 function Constant_Range
kono
parents:
diff changeset
150 (Container : Sequence;
kono
parents:
diff changeset
151 Fst : Index_Type;
kono
parents:
diff changeset
152 Lst : Extended_Index;
kono
parents:
diff changeset
153 Item : Element_Type) return Boolean
kono
parents:
diff changeset
154 -- Returns True if every element of the range from Fst to Lst of Container
kono
parents:
diff changeset
155 -- is equal to Item.
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 with
kono
parents:
diff changeset
158 Global => null,
kono
parents:
diff changeset
159 Pre => Lst <= Last (Container),
kono
parents:
diff changeset
160 Post =>
kono
parents:
diff changeset
161 Constant_Range'Result =
kono
parents:
diff changeset
162 (for all I in Fst .. Lst => Get (Container, I) = Item);
kono
parents:
diff changeset
163 pragma Annotate (GNATprove, Inline_For_Proof, Constant_Range);
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 function Equal_Except
kono
parents:
diff changeset
166 (Left : Sequence;
kono
parents:
diff changeset
167 Right : Sequence;
kono
parents:
diff changeset
168 Position : Index_Type) return Boolean
kono
parents:
diff changeset
169 -- Returns True is Left and Right are the same except at position Position
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 with
kono
parents:
diff changeset
172 Global => null,
kono
parents:
diff changeset
173 Pre => Position <= Last (Left),
kono
parents:
diff changeset
174 Post =>
kono
parents:
diff changeset
175 Equal_Except'Result =
kono
parents:
diff changeset
176 (Length (Left) = Length (Right)
kono
parents:
diff changeset
177 and then (for all I in Index_Type'First .. Last (Left) =>
kono
parents:
diff changeset
178 (if I /= Position then Get (Left, I) = Get (Right, I))));
kono
parents:
diff changeset
179 pragma Annotate (GNATprove, Inline_For_Proof, Equal_Except);
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 function Equal_Except
kono
parents:
diff changeset
182 (Left : Sequence;
kono
parents:
diff changeset
183 Right : Sequence;
kono
parents:
diff changeset
184 X : Index_Type;
kono
parents:
diff changeset
185 Y : Index_Type) return Boolean
kono
parents:
diff changeset
186 -- Returns True is Left and Right are the same except at positions X and Y
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 with
kono
parents:
diff changeset
189 Global => null,
kono
parents:
diff changeset
190 Pre => X <= Last (Left) and Y <= Last (Left),
kono
parents:
diff changeset
191 Post =>
kono
parents:
diff changeset
192 Equal_Except'Result =
kono
parents:
diff changeset
193 (Length (Left) = Length (Right)
kono
parents:
diff changeset
194 and then (for all I in Index_Type'First .. Last (Left) =>
kono
parents:
diff changeset
195 (if I /= X and I /= Y then
kono
parents:
diff changeset
196 Get (Left, I) = Get (Right, I))));
kono
parents:
diff changeset
197 pragma Annotate (GNATprove, Inline_For_Proof, Equal_Except);
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 function Range_Equal
kono
parents:
diff changeset
200 (Left : Sequence;
kono
parents:
diff changeset
201 Right : Sequence;
kono
parents:
diff changeset
202 Fst : Index_Type;
kono
parents:
diff changeset
203 Lst : Extended_Index) return Boolean
kono
parents:
diff changeset
204 -- Returns True if the ranges from Fst to Lst contain the same elements in
kono
parents:
diff changeset
205 -- Left and Right.
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 with
kono
parents:
diff changeset
208 Global => null,
kono
parents:
diff changeset
209 Pre => Lst <= Last (Left) and Lst <= Last (Right),
kono
parents:
diff changeset
210 Post =>
kono
parents:
diff changeset
211 Range_Equal'Result =
kono
parents:
diff changeset
212 (for all I in Fst .. Lst => Get (Left, I) = Get (Right, I));
kono
parents:
diff changeset
213 pragma Annotate (GNATprove, Inline_For_Proof, Range_Equal);
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 function Range_Shifted
kono
parents:
diff changeset
216 (Left : Sequence;
kono
parents:
diff changeset
217 Right : Sequence;
kono
parents:
diff changeset
218 Fst : Index_Type;
kono
parents:
diff changeset
219 Lst : Extended_Index;
kono
parents:
diff changeset
220 Offset : Count_Type'Base) return Boolean
kono
parents:
diff changeset
221 -- Returns True if the range from Fst to Lst in Left contains the same
kono
parents:
diff changeset
222 -- elements as the range from Fst + Offset to Lst + Offset in Right.
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 with
kono
parents:
diff changeset
225 Global => null,
kono
parents:
diff changeset
226 Pre =>
kono
parents:
diff changeset
227 Lst <= Last (Left)
kono
parents:
diff changeset
228 and then
kono
parents:
diff changeset
229 (if Offset < 0 then
kono
parents:
diff changeset
230 Index_Type'Pos (Index_Type'Base'First) - Offset <=
kono
parents:
diff changeset
231 Index_Type'Pos (Index_Type'First))
kono
parents:
diff changeset
232 and then
kono
parents:
diff changeset
233 (if Fst <= Lst then
kono
parents:
diff changeset
234 Offset in
kono
parents:
diff changeset
235 Index_Type'Pos (Index_Type'First) - Index_Type'Pos (Fst) ..
kono
parents:
diff changeset
236 (Index_Type'Pos (Index_Type'First) - 1) + Length (Right) -
kono
parents:
diff changeset
237 Index_Type'Pos (Lst)),
kono
parents:
diff changeset
238 Post =>
kono
parents:
diff changeset
239 Range_Shifted'Result =
kono
parents:
diff changeset
240 ((for all I in Fst .. Lst =>
kono
parents:
diff changeset
241 Get (Left, I) =
kono
parents:
diff changeset
242 Get (Right, Index_Type'Val (Index_Type'Pos (I) + Offset)))
kono
parents:
diff changeset
243 and
kono
parents:
diff changeset
244 (for all I in Index_Type'Val (Index_Type'Pos (Fst) + Offset) ..
kono
parents:
diff changeset
245 Index_Type'Val (Index_Type'Pos (Lst) + Offset)
kono
parents:
diff changeset
246 =>
kono
parents:
diff changeset
247 Get (Left, Index_Type'Val (Index_Type'Pos (I) - Offset)) =
kono
parents:
diff changeset
248 Get (Right, I)));
kono
parents:
diff changeset
249 pragma Annotate (GNATprove, Inline_For_Proof, Range_Shifted);
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 ----------------------------
kono
parents:
diff changeset
252 -- Construction Functions --
kono
parents:
diff changeset
253 ----------------------------
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 -- For better efficiency of both proofs and execution, avoid using
kono
parents:
diff changeset
256 -- construction functions in annotations and rather use property functions.
kono
parents:
diff changeset
257
kono
parents:
diff changeset
258 function Set
kono
parents:
diff changeset
259 (Container : Sequence;
kono
parents:
diff changeset
260 Position : Index_Type;
kono
parents:
diff changeset
261 New_Item : Element_Type) return Sequence
kono
parents:
diff changeset
262 -- Returns a new sequence which contains the same elements as Container
kono
parents:
diff changeset
263 -- except for the one at position Position which is replaced by New_Item.
kono
parents:
diff changeset
264
kono
parents:
diff changeset
265 with
kono
parents:
diff changeset
266 Global => null,
kono
parents:
diff changeset
267 Pre => Position in Index_Type'First .. Last (Container),
kono
parents:
diff changeset
268 Post =>
kono
parents:
diff changeset
269 Get (Set'Result, Position) = New_Item
kono
parents:
diff changeset
270 and then Equal_Except (Container, Set'Result, Position);
kono
parents:
diff changeset
271
kono
parents:
diff changeset
272 function Add (Container : Sequence; New_Item : Element_Type) return Sequence
kono
parents:
diff changeset
273 -- Returns a new sequence which contains the same elements as Container
kono
parents:
diff changeset
274 -- plus New_Item at the end.
kono
parents:
diff changeset
275
kono
parents:
diff changeset
276 with
kono
parents:
diff changeset
277 Global => null,
kono
parents:
diff changeset
278 Pre =>
kono
parents:
diff changeset
279 Length (Container) < Count_Type'Last
kono
parents:
diff changeset
280 and then Last (Container) < Index_Type'Last,
kono
parents:
diff changeset
281 Post =>
kono
parents:
diff changeset
282 Length (Add'Result) = Length (Container) + 1
kono
parents:
diff changeset
283 and then Get (Add'Result, Last (Add'Result)) = New_Item
kono
parents:
diff changeset
284 and then Container <= Add'Result;
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286 function Add
kono
parents:
diff changeset
287 (Container : Sequence;
kono
parents:
diff changeset
288 Position : Index_Type;
kono
parents:
diff changeset
289 New_Item : Element_Type) return Sequence
kono
parents:
diff changeset
290 with
kono
parents:
diff changeset
291 -- Returns a new sequence which contains the same elements as Container
kono
parents:
diff changeset
292 -- except that New_Item has been inserted at position Position.
kono
parents:
diff changeset
293
kono
parents:
diff changeset
294 Global => null,
kono
parents:
diff changeset
295 Pre =>
kono
parents:
diff changeset
296 Length (Container) < Count_Type'Last
kono
parents:
diff changeset
297 and then Last (Container) < Index_Type'Last
kono
parents:
diff changeset
298 and then Position <= Extended_Index'Succ (Last (Container)),
kono
parents:
diff changeset
299 Post =>
kono
parents:
diff changeset
300 Length (Add'Result) = Length (Container) + 1
kono
parents:
diff changeset
301 and then Get (Add'Result, Position) = New_Item
kono
parents:
diff changeset
302 and then Range_Equal
kono
parents:
diff changeset
303 (Left => Container,
kono
parents:
diff changeset
304 Right => Add'Result,
kono
parents:
diff changeset
305 Fst => Index_Type'First,
kono
parents:
diff changeset
306 Lst => Index_Type'Pred (Position))
kono
parents:
diff changeset
307 and then Range_Shifted
kono
parents:
diff changeset
308 (Left => Container,
kono
parents:
diff changeset
309 Right => Add'Result,
kono
parents:
diff changeset
310 Fst => Position,
kono
parents:
diff changeset
311 Lst => Last (Container),
kono
parents:
diff changeset
312 Offset => 1);
kono
parents:
diff changeset
313
kono
parents:
diff changeset
314 function Remove
kono
parents:
diff changeset
315 (Container : Sequence;
kono
parents:
diff changeset
316 Position : Index_Type) return Sequence
kono
parents:
diff changeset
317 -- Returns a new sequence which contains the same elements as Container
kono
parents:
diff changeset
318 -- except that the element at position Position has been removed.
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 with
kono
parents:
diff changeset
321 Global => null,
kono
parents:
diff changeset
322 Pre => Position in Index_Type'First .. Last (Container),
kono
parents:
diff changeset
323 Post =>
kono
parents:
diff changeset
324 Length (Remove'Result) = Length (Container) - 1
kono
parents:
diff changeset
325 and then Range_Equal
kono
parents:
diff changeset
326 (Left => Container,
kono
parents:
diff changeset
327 Right => Remove'Result,
kono
parents:
diff changeset
328 Fst => Index_Type'First,
kono
parents:
diff changeset
329 Lst => Index_Type'Pred (Position))
kono
parents:
diff changeset
330 and then Range_Shifted
kono
parents:
diff changeset
331 (Left => Remove'Result,
kono
parents:
diff changeset
332 Right => Container,
kono
parents:
diff changeset
333 Fst => Position,
kono
parents:
diff changeset
334 Lst => Last (Remove'Result),
kono
parents:
diff changeset
335 Offset => 1);
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 ---------------------------
kono
parents:
diff changeset
338 -- Iteration Primitives --
kono
parents:
diff changeset
339 ---------------------------
kono
parents:
diff changeset
340
kono
parents:
diff changeset
341 function Iter_First (Container : Sequence) return Extended_Index with
kono
parents:
diff changeset
342 Global => null;
kono
parents:
diff changeset
343
kono
parents:
diff changeset
344 function Iter_Has_Element
kono
parents:
diff changeset
345 (Container : Sequence;
kono
parents:
diff changeset
346 Position : Extended_Index) return Boolean
kono
parents:
diff changeset
347 with
kono
parents:
diff changeset
348 Global => null,
kono
parents:
diff changeset
349 Post =>
kono
parents:
diff changeset
350 Iter_Has_Element'Result =
kono
parents:
diff changeset
351 (Position in Index_Type'First .. Last (Container));
kono
parents:
diff changeset
352 pragma Annotate (GNATprove, Inline_For_Proof, Iter_Has_Element);
kono
parents:
diff changeset
353
kono
parents:
diff changeset
354 function Iter_Next
kono
parents:
diff changeset
355 (Container : Sequence;
kono
parents:
diff changeset
356 Position : Extended_Index) return Extended_Index
kono
parents:
diff changeset
357 with
kono
parents:
diff changeset
358 Global => null,
kono
parents:
diff changeset
359 Pre => Iter_Has_Element (Container, Position);
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 private
kono
parents:
diff changeset
362
kono
parents:
diff changeset
363 pragma SPARK_Mode (Off);
kono
parents:
diff changeset
364
kono
parents:
diff changeset
365 package Containers is new Ada.Containers.Functional_Base
kono
parents:
diff changeset
366 (Index_Type => Index_Type,
kono
parents:
diff changeset
367 Element_Type => Element_Type);
kono
parents:
diff changeset
368
kono
parents:
diff changeset
369 type Sequence is record
kono
parents:
diff changeset
370 Content : Containers.Container;
kono
parents:
diff changeset
371 end record;
kono
parents:
diff changeset
372
kono
parents:
diff changeset
373 function Iter_First (Container : Sequence) return Extended_Index is
kono
parents:
diff changeset
374 (Index_Type'First);
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 function Iter_Next
kono
parents:
diff changeset
377 (Container : Sequence;
kono
parents:
diff changeset
378 Position : Extended_Index) return Extended_Index
kono
parents:
diff changeset
379 is
kono
parents:
diff changeset
380 (if Position = Extended_Index'Last then
kono
parents:
diff changeset
381 Extended_Index'First
kono
parents:
diff changeset
382 else
kono
parents:
diff changeset
383 Extended_Index'Succ (Position));
kono
parents:
diff changeset
384
kono
parents:
diff changeset
385 function Iter_Has_Element
kono
parents:
diff changeset
386 (Container : Sequence;
kono
parents:
diff changeset
387 Position : Extended_Index) return Boolean
kono
parents:
diff changeset
388 is
kono
parents:
diff changeset
389 (Position in Index_Type'First ..
kono
parents:
diff changeset
390 (Index_Type'Val
kono
parents:
diff changeset
391 ((Index_Type'Pos (Index_Type'First) - 1) + Length (Container))));
kono
parents:
diff changeset
392
kono
parents:
diff changeset
393 end Ada.Containers.Functional_Vectors;