Debian Codegraph @

source_2020/pre_containers.mss

raw
1 @comment{ $Source: e:\\cvsroot/ARM/Source/pre_containers.mss,v $ }
2 @comment{ $Revision: 1.111 $ $Date: 2020/06/03 00:09:01 $ $Author: randy $ }
3 @Part(precontainers, Root="ada.mss")
4
5 @Comment{$Date: 2020/06/03 00:09:01 $}
6
7 @RMNewPage
8 @LabeledAddedClause{Version=[2],Name=[Containers]}
9
10 @begin{Intro}
11 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
12 @ChgAdded{Version=[2],Text=[This clause presents the specifications of the package
13 Containers and several child packages, which provide facilities for storing
14 collections of elements.]}
15
16 @ChgToGlossary{Version=[3],Kind=[Added],Term=<Container>,
17 Text=<@ChgAdded{Version=[3],Text=[A container is an object that contain other
18 objects all of the same type, which could be class-wide.
19 Several predefined container types are provided by the children
20 of package Ada.Containers (see @RefSecNum{The Package Containers}).]}>}
21
22 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
23 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0196-1]}
24 @ChgAdded{Version=[2],Text=[A variety of sequence and associative containers are
25 provided. Each container includes a @i{cursor} type. A cursor is a reference
26 to an element within a container. Many operations on cursors are common to
27 all of the containers. A cursor referencing
28 an element in a container is considered to be overlapping
29 @Chg{Version=[5],New=[only ],Old=[]}with the
30 @Chg{Version=[5],New=[element],Old=[container object]}
31 itself.@PDefn2{Term=[cursor],Sec=[for a container]}
32 @Defn2{Term=[container],Sec=[cursor]}]}
33
34 @begin{Reason}
35 @ChgRef{Version=[2],Kind=[AddedNormal]}
36 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0196-1]}
37 @ChgAdded{Version=[2],Text=[The last sentence is intended to clarify that
38 operations that just use a cursor @Chg{Version=[5],New=[do not interfere if
39 the cursor objects designated diferent elements of the container],Old=[are
40 on the same footing as operations that
41 use a container]} in terms of
42 the @Chg{Version=[5],New=[concurrent call],Old=[reentrancy]} rules of
43 @RefSecNum{Predefined Language Environment}.]}
44 @end{Reason}
45
46 @begin{Ramification}
47 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0196-1]}
48 @ChgAdded{Version=[5],Text=[A cursor is not considered to overlap with other
49 elements of the associated container, thus parallel operations involving a set
50 of cursors each operating on mutually exclusive sets of elements from the same
51 container are expected to work.]}
52 @end{Ramification}
53
54 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
55 @ChgAdded{Version=[5],Text=[Some operations of the language-defined child units
56 of Ada.Containers have access-to-subprogram parameters. To ensure such
57 operations are well-defined, they guard against certain actions by the
58 designated subprogram. An action on a container that might add or remove an
59 element is considered to @i{tamper with cursors},@PDefn{tamper with cursors} and
60 these are prohibited during all such operations. An action on a container that
61 might replace an element with one of a different size is considered to @i{tamper
62 with elements}, and these are prohibited during certain of such
63 operations.@PDefn{tamper with elements} The details of the specific actions that
64 are considered to tamper with cursors or elements are defined for each child
65 unit of Ada.Containers.]}
66
67 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
68 @ChgAdded{Version=[5],Text=[Several of the language-defined child units of
69 Ada.Containers include a nested package named Stable, which provides a view of a
70 container that prohibits any operations that would tamper with elements. By
71 using a Stable view for manipulating a container, the number of tampering checks
72 performed while performing the operations can be reduced. The details of the
73 Stable subpackage are defined separately for each child unit of Ada.Containers
74 that includes such a nested package.]}
75
76
77 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
78 @ChgAdded{Version=[2],Text=[Within this clause we provide Implementation Advice
79 for the desired average or worst case time complexity of certain operations
80 on a container. This advice is expressed using the Landau symbol @i{O}(X).
81 Presuming f is some function of a length parameter N and t(N) is the time the
82 operation takes (on average or worst case, as specified) for the length N, a
83 complexity of @i{O}(f(N)) means that there exists a finite A such that for any N,
84 t(N)/f(N) < A. @Defn{Landau symbol @i{O}(X)}@Defn{@i{O}(f(N))}]}
85
86 @begin{Discussion}
87 @ChgRef{Version=[2],Kind=[AddedNormal]}
88 @ChgAdded{Version=[2],Text=[Of course, an implementation can do better than a
89 specified @i{O}(f(N)): for example, @i{O}(1) meets the requirements for
90 @i{O}(log N).]}
91
92 @ChgRef{Version=[2],Kind=[AddedNormal]}
93 @ChgAdded{Version=[2],Text=[This concept seems to have
94 as many names as there are authors. We used @lquotes@;Landau symbol@rquotes
95 because that's what our reference does. But we'd also seen this referred as
96 big-O notation@Defn{big-O notation} (sometimes written as @i<big-oh>), and
97 as Bachmann notation. Whatever the name, it always has the above definition.]}
98 @end{Discussion}
99
100 @ChgRef{Version=[2],Kind=[AddedNormal]}
101 @ChgAdded{Version=[2],Text=[If the advice suggests that the complexity should be
102 less than @i{O}(f(N)), then for any arbitrarily small positive real D, there
103 should exist a positive integer M such that for all N > M,
104 t(N)/f(N) < D.]}
105
106 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1],ARef=[AI05-0044-1]}
107 @ChgAdded{Version=[3],Text=[When a formal function is used to provide an
108 ordering for a container, it is generally required to define
109 a strict weak ordering. A function "<" defines
110 a @i<strict weak ordering>@Defn{strict weak ordering} if it is irreflexive,
111 asymmetric, transitive, and in addition, if @i<x> < @i<y> for any values
112 @i<x> and @i<y>, then for all other
113 values @i<z>, (@i<x> < @i<z>) or (@i<z> < @i<y>).]}
114
115 @end{Intro}
116
117 @begin{Metarules}
118
119 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
120 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
121 @ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[subclause],Old=[clause]}
122 provides a number of useful containers
123 for Ada. Only the most useful containers are provided. Ones that are relatively
124 easy to code, redundant, or rarely used are omitted from this set, even if they
125 are generally included in containers libraries.]}
126
127 @ChgRef{Version=[2],Kind=[AddedNormal]}
128 @ChgAdded{Version=[2],Text=[The containers packages are modeled on the Standard Template Library (STL), an
129 algorithms and data structure library popularized by Alexander Stepanov, and
130 included in the C++ standard library. The structure and terminology differ from
131 the STL where that better maps to common Ada usage. For instance, what the STL
132 calls @lquotes@;iterators@rquotes@; are
133 called @lquotes@;cursors@rquotes@; here.]}
134
135 @ChgRef{Version=[2],Kind=[AddedNormal]}
136 @ChgAdded{Version=[2],Type=[Leading],Text=[The following major nonlimited
137 containers are provided:]}
138
139 @begin{Itemize}
140 @ChgRef{Version=[2],Kind=[AddedNormal]}
141 @ChgAdded{Version=[2],Text=[(Expandable) Vectors of any nonlimited type;]}
142
143 @ChgRef{Version=[2],Kind=[AddedNormal]}
144 @ChgAdded{Version=[2],Text=[Doubly-linked Lists of any nonlimited type;]}
145
146 @ChgRef{Version=[2],Kind=[AddedNormal]}
147 @ChgAdded{Version=[2],Text=[Hashed Maps keyed by any nonlimited hashable type,
148 and containing any nonlimited type;]}
149
150 @ChgRef{Version=[2],Kind=[AddedNormal]}
151 @ChgAdded{Version=[2],Text=[Ordered Maps keyed by any nonlimited ordered type,
152 and containing any nonlimited type;]}
153
154 @ChgRef{Version=[2],Kind=[AddedNormal]}
155 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0136-1]}
156 @ChgAdded{Version=[2],Text=[Hashed Sets of any nonlimited hashable type;@Chg{Version=[3],New=[],Old=[ and]}]}
157
158 @ChgRef{Version=[2],Kind=[AddedNormal]}
159 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0136-1]}
160 @ChgAdded{Version=[2],Text=[Ordered Sets of any nonlimited ordered type@Chg{Version=[3],New=[;],Old=[.]}]}
161
162 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0136-1]}
163 @ChgAdded{Version=[3],Text=[Multiway Trees of any nonlimited type;]}
164
165 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0069-1]}
166 @ChgAdded{Version=[3],Text=[Holders of any (indefinite) nonlimited type;]}
167
168 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0159-1]}
169 @ChgAdded{Version=[3],Text=[Synchronized queues of any definite nonlimited type; and]}
170
171 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0159-1]}
172 @ChgAdded{Version=[3],Text=[Priority queues of any definite nonlimited type.]}
173 @end{Itemize}
174
175 @ChgRef{Version=[2],Kind=[AddedNormal]}
176 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1]}
177 @ChgAdded{Version=[2],Text=[Separate versions for definite and indefinite
178 element types are provided, as those for definite types can be implemented more
179 efficiently.@Chg{Version=[3],New=[ Similarly, a separate bounded version is
180 provided in order to give more predictable memory usage.],Old=[]}]}
181
182 @ChgRef{Version=[2],Kind=[AddedNormal]}
183 @ChgAdded{Version=[2],Text=[Each container includes a cursor, which is a
184 reference to an element within a container. Cursors generally remain valid as
185 long as the container exists and the element referenced is not deleted. Many
186 operations on cursors are common to all of the containers. This makes it
187 possible to write generic algorithms that work on any kind of container.]}
188
189 @ChgRef{Version=[2],Kind=[AddedNormal]}
190 @ChgAdded{Version=[2],Text=[The containers packages are structured so that
191 additional packages can be added in the future. Indeed, we hope that these
192 packages provide the basis for a more extensive secondary standard for
193 containers.]}
194
195 @ChgRef{Version=[2],Kind=[AddedNormal]}
196 @ChgAdded{Version=[2],Text=[If containers with similar functionality (but
197 different performance characteristics) are provided (by the implementation or
198 by a secondary standard), we suggest that a prefix be used to identify the
199 class of the functionality: "Ada.Containers.Bounded_Sets" (for a set with a
200 maximum number of elements); "Ada.Containers.Protected_Maps" (for a map which
201 can be accessed by multiple tasks at one time);
202 "Ada.Containers.Persistent_Vectors" (for a persistent vector which continues to
203 exist between executions of a program) and so on.]}
204
205 @ChgRef{Version=[2],Kind=[AddedNormal]}
206 @ChgAdded{Version=[2],Type=[Leading],Text=[Note that the language already
207 includes several requirements that are important to the use of containers.
208 These include:]}
209
210 @begin{Itemize}
211 @ChgRef{Version=[2],Kind=[AddedNormal]}
212 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0196-1]}
213 @ChgAdded{Version=[2],Text=[Library packages must @Chg{Version=[5],New=[allow
214 concurrent calls],Old=[be
215 reentrant]} @en multiple tasks can use the packages as long as they operate on
216 separate containers. Thus, it is only necessary for a user to protect a
217 container if a single container needs to be used by multiple tasks@Chg{Version=[5],New=[ and
218 concurrent calls to operations of the container have overlapping
219 parameters],Old=[]}.]}
220
221 @ChgRef{Version=[2],Kind=[AddedNormal]}
222 @ChgAdded{Version=[2],Text=[Language-defined types must stream "properly".
223 That means that the stream attributes can be used to implement persistence
224 of containers when necessary, and containers can be passed between
225 partitions of a program.]}
226
227 @ChgRef{Version=[2],Kind=[AddedNormal]}
228 @ChgAdded{Version=[2],Text=[Equality of language-defined types must compose
229 @lquotes@;properly@rquotes@;. This means that the version of "=" directly
230 used by users is the same one that will be used in generics and in predefined
231 equality operators of types with components of the containers and/or cursors.
232 This prevents the abstraction from breaking unexpectedly.]}
233
234 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0048-1]}
235 @ChgAdded{Version=[3],Text=[Redispatching is not allowed (unless it is
236 required). That means that overriding a container operation will not change
237 the behavior of any other predefined container operation. This provides
238 a stable base for extensions.]}
239 @end{Itemize}
240
241
242 @ChgRef{Version=[2],Kind=[AddedNormal]}
243 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0258-1]}
244 @ChgAdded{Version=[2],Text=[If a container's element type is controlled, the
245 point at which the element is finalized will depend on the implementation of
246 the container. @Chg{Version=[5],New=[For certain
247 kinds of containers, we require finalization behavior based on the canonical
248 implementation of the container (see the @ImplReqTitle below).
249 For the "normal" containers, we],Old=[We]}
250 do not specify precisely where this will happen (it will happen no later than
251 the finalization of the container, of course) in order to give implementations
252 flexibility to cache, block, @Chg{Version=[5],New=[],Old=[or ]}split
253 @Chg{Version=[5],New=[, or reuse],Old=[]}the nodes of the
254 container.@Chg{Version=[5],New=[],Old=[ In particular, Delete does not
255 necessarily finalize the element; the implementation may (or may not) hold the
256 space for reuse.]}]}
257
258 @ChgRef{Version=[2],Kind=[AddedNormal]}
259 @ChgRef{Version=[5],Kind=[Deleted],ARef=[AI12-0258-1]}
260 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[This is not likely to
261 be a hardship, as the element type has to be nonlimited. Types used to manage
262 scarce resources generally need to be limited. Otherwise, the amount of
263 resources needed is hard to control, as the language allows a lot of variation
264 in the number or order of adjusts/finalizations. For common uses of nonlimited
265 controlled types such as managing storage, the types already have to manage
266 arbitrary copies.]}]}
267
268 @ChgRef{Version=[2],Kind=[AddedNormal]}
269 @ChgAdded{Version=[2],Text=[The use of controlled types also brings up the
270 possibility of failure of finalization (and thus deallocation) of an element.
271 This is a @ldquote@;serious bug@rdquote@;, as AI95-179 puts it, so we don't try
272 to specify what happens in that case. The implementation should propagate
273 the exception.]}
274 @end{Metarules}
275
276 @begin{ImplNote}
277 @ChgRef{Version=[2],Kind=[AddedNormal]}
278 @ChgAdded{Version=[2],Text=[It is expected that exceptions propagated from
279 these operations do not
280 damage containers. That is, if Storage_Error is propagated because of an
281 allocation failure, or Constraint_Error is propagated by the assignment of
282 elements, the container can continue to be used without further exceptions.
283 The intent is that it should be possible to recover from errors without
284 losing data. We don't try to state this formally in most cases, because it is
285 hard to define precisely what is and is not allowed behavior.]}
286 @end{ImplNote}
287
288 @begin{ImplNote}
289 @ChgRef{Version=[2],Kind=[AddedNormal]}
290 @ChgAdded{Version=[2],Text=[When this clause says that the behavior of
291 something is unspecified@PDefn{unspecified}, we
292 really mean that any result of executing Ada code short of erroneous
293 execution is allowed. We do not mean that memory not belonging to the
294 parameters of the operation can be trashed. When we mean to allow erroneous
295 behavior, we specifically say that execution is erroneous. All this means
296 if the containers are written in Ada is that checks should not be suppressed
297 or removed assuming some behavior of other code, and that the implementation
298 should take care to avoid creating internal dangling accesses by assuming
299 behavior from generic formals that can't be guaranteed. We don't
300 try to say this normatively because it would be fairly complex, and
301 implementers are unlikely to increase their support costs by fielding
302 implementations that are unstable if given buggy hash functions, et al.]}
303 @end{ImplNote}
304
305 @begin{StaticSem}
306 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0035-1]}
307 @ChgAdded{Version=[4],Text=[Certain subprograms declared within instances of
308 some of the generic packages presented in this clause are said to @i<perform
309 indefinite insertion>. These subprograms are those corresponding (in the sense
310 of the copying described in subclause @RefSecNum{Generic Instantiation}) to
311 subprograms that have formal parameters of a generic formal indefinite type and
312 that are identified as performing indefinite insertion in the subclause defining
313 the generic package.@Defn{perform indefinite insertion}]}
314
315 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0035-1]}
316 @ChgAdded{Version=[4],Type=[Leading],Text=[If a subprogram performs indefinite
317 insertion, then certain run-time checks are performed as part of a call to the
318 subprogram; if any of these checks fail, then the resulting exception is
319 propagated to the caller and the container is not modified by the call. These
320 checks are performed for each parameter corresponding (in the sense of the
321 copying described in @RefSecNum{Generic Instantiation}) to a parameter in the
322 corresponding generic whose type is a generic formal indefinite type. The checks
323 performed for a given parameter are those checks explicitly specified in
324 subclause @RefSecNum{Allocators} that would be performed as part of the
325 evaluation of an initialized allocator whose access type is declared immediately
326 within the instance, where:]}
327
328 @begin{Itemize}
329 @ChgRef{Version=[4],Kind=[AddedNormal]}
330 @ChgAdded{Version=[4],Text=[the value of the @nt{qualified_expression} is
331 that of the parameter; and]}
332
333 @ChgRef{Version=[4],Kind=[AddedNormal]}
334 @ChgAdded{Version=[4],Text=[the designated subtype of the access type is the
335 subtype of the parameter; and]}
336
337 @ChgRef{Version=[4],Kind=[AddedNormal]}
338 @ChgAdded{Version=[4],Text=[finalization of the collection of the access type
339 has started if and only if the finalization of the instance has started.]}
340 @end{Itemize}
341
342 @begin{Discussion}
343 @ChgRef{Version=[4],Kind=[AddedNormal]}
344 @ChgAdded{Version=[4],Text=[The phrase "explicitly specified" means those
345 checks for which subclause @RefSecNum{Allocators} includes the phrase "<some
346 exception> is raised if ...". It does not refer, for example, to any checks
347 performed as part of any subtype conversion. In particular, this wording
348 includes the checks described in subclause @RefSecNum{Allocators} to be
349 performed in the case of a class-wide designated type, and of a designated
350 subtype that has access discriminant parts. These checks are needed to prevent
351 containers from outliving their contained (Element_Type or Key_Type) values.]}
352 @end{Discussion}
353 @begin{ImplNote}
354 @ChgRef{Version=[4],Kind=[AddedNormal]}
355 @ChgAdded{Version=[4],Text=[These rules have a dual purpose. Mainly, we are
356 @i{requiring} checks needed to prevent dangling references. As a side effect, we
357 are also @i{allowing} checks needed to permit an implementation of a container
358 generic to make use of access types in a straightforward way. As an example of
359 the second purpose, suppose that an implementation does declare such an access
360 type and suppose further that the finalization of the collection of the
361 access type has started. These rules allow Program_Error to be propagated
362 in this case (as specified in @RefSecNum{Allocators}); this is necessary to
363 allow an all-Ada implementation of these packages.]}
364 @end{ImplNote}
365 @end{StaticSem}
366
367 @begin{ImplReq}
368 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0258-1]}
369 @ChgAdded{Version=[5],Text=[For an indefinite container (one whose type is
370 defined in an instance of a child package of Containers whose
371 @nt{defining_identifier} contains "Indefinite"), each element of the container
372 shall be created when it is inserted into the container and finalized when it is
373 deleted from the container (or when the container object is finalized if the
374 element has not been deleted). For a bounded container (one whose type is
375 defined in an instance of a child package of Containers whose
376 @nt{defining_identifier} starts with "Bounded") that is not an indefinite
377 container, all of the elements of the capacity of the container shall be created
378 and default initialized when the container object is created; the elements shall
379 be finalized when the container object is finalized. @Redundant[For other kinds
380 of containers, when elements are created and finalized is unspecified.]]}
381
382 @begin{Ramification}
383 @ChgRef{Version=[5],Kind=[AddedNormal]}
384 @ChgAdded{Version=[5],Text=[This allows a user to be able to reason about the
385 behavior of elements that have controlled parts. In most cases, such elements
386 need to be stored in an indefinite container.]}
387 @end{Ramification}
388
389 @begin{ImplNote}
390 @ChgRef{Version=[5],Kind=[AddedNormal]}
391 @ChgAdded{Version=[5],Text=[If the containers are implemented in Ada, this
392 implies that elements for an indefinite container are allocated individually,
393 and that a bounded container contains an array of elements or other data
394 structure that is initialized for the entire capacity of the container when it
395 is created. There is no such restriction on the implementation of the "normal"
396 containers; these can be handled in any way convenient to the implementation
397 @em in particular, node reuse is allowed.]}
398 @end{ImplNote}
399
400 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
401 @ChgAdded{Version=[5],Text=[For an instance @i<I> of a container package with a
402 container type @i<C>, the specific type @i<T> of the object returned from a
403 function that returns an object of an iterator interface, as well as the
404 primitive operations of @i<T>, shall be nonblocking. The Global aspect specified
405 for @i<T> and the primitive operations of @i<T> shall be @exam[(@key{in all},
406 @key{out synchronized})] or a specification that allows
407 access to fewer global objects.]}
408
409 @begin{ImplNote}
410 @ChgRef{Version=[5],Kind=[AddedNormal]}
411 @ChgAdded{Version=[5],Text=[This requires that the traversal and iteration
412 operations of a container do not create, destroy, or assign any objects of
413 a formal type of @i<I>, nor call any formal subprograms of @i<I>. Those
414 objects and subprograms might be blocking (depending on the actual parameters).
415 We put similar requirements on the individual traversal operations in the
416 container package definitions.]}
417 @end{ImplNote}
418
419 @begin{Reason}
420 @ChgRef{Version=[5],Kind=[AddedNormal]}
421 @ChgAdded{Version=[5],Text=[These requirements allows users to use container
422 iterators inside of parallel constructs, regardless of the actual parameters
423 to the instantiation. If such an iterator allowed blocking,
424 it would be illegal inside of a parallel construct (see
425 @RefSecNum{Intertask Communication}). If such an iterator allowed writing of
426 unsynchronized global objects, it would be illegal when the default conflict
427 checking policy is in effect (see @RefSecNum{Conflict Check Policies}).
428 These requirements include sequential iterators; the iterator does not need
429 to appear in a parallel loop to trigger these requirements.]}
430 @end{Reason}
431
432 @begin{Discussion}
433 @ChgRef{Version=[5],Kind=[AddedNormal]}
434 @ChgAdded{Version=[5],Text=[We have to give these requirements as a text rule,
435 as there is no place to declare suitable aspects. The specific type of a
436 container iterator is declared by the implementation and is not part of the
437 visible specification (iterator functions just return a value of a class-wide
438 type). The iterator interface itself cannot impose such a requirement since
439 it needs to be able to work with user-defined types that do need to
440 allow blocking. We give this as a global requirement to avoid duplication.]}
441 @end{Discussion}
442
443 @end{ImplReq}
444
445 @begin{Extend95}
446 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
447 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
448 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
449 This @Chg{Version=[3],New=[subclause],Old=[clause]} is new. It just
450 provides an introduction to the following subclauses.]}
451 @end{Extend95}
452
453 @begin{DiffWord2005}
454 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]}
455 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a definition of
456 strict weak ordering.]}
457 @end{DiffWord2005}
458
459 @begin{Incompatible2012}
460 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1],ARef=[AI12-0112-1],ARef=[AI12-0339-1]}
461 @ChgAdded{Version=[5],Text=[@Defn{incompatibilities with Ada 2012}A number of
462 new subprograms, types, and even a nested package were added to
463 Containers.Hashed_Maps to better support contracts and stable views. If an
464 instance of Containers.Hashed_Maps
465 is referenced in a @nt{use_clause}, and an entity @i<E> with the same
466 @nt{defining_identifier} as a new entity in Containers.Hashed_Maps is
467 defined in a package that is also referenced in a @nt{use_clause}, the
468 entity @i<E> may no longer be use-visible, resulting in errors. This should
469 be rare and is easily fixed if it does occur.]}
470 @end{Incompatible2012}
471
472 @begin{Extend2012}
473 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0196-1]}
474 @ChgAdded{Version=[5],Text=[@Defn{extensions to Ada 2012}@b{Correction:}
475 We now say that a cursor only overlaps with the element it designates,
476 rather than with the whole container. This allows some reading operations
477 to operate on the container in parallel without separate synchronization.]}
478 @end{Extend2012}
479
480 @begin{DiffWord2012}
481 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI05-0035-1]}
482 @ChgAdded{Version=[4],Text=[@b<Corrigendum:> Added a definition of
483 @ldquote@;performs indefinite insertion@rdquote. This is used in
484 other subclauses and any resulting inconsistencies are documented
485 there.]}
486
487 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1]}
488 @ChgAdded{Version=[5],Text=[Moved the basic description of tampering
489 checks here, to cut duplication in description of the individual containers.
490 Added a description of stable views of containers.]}
491
492 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
493 @ChgAdded{Version=[5],Text=[Added a global requirement that iterators
494 returned from containers are nonblocking if the instance is nonblocking.]}
495
496 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0258-1]}
497 @ChgAdded{Version=[5],Text=[@b<Correction:> Defined when objects
498 are created and finalized for Bounded and Indefinite containers,
499 so that these can be used reliably with controlled element types.
500 This is not incompatible as this behavior was previously unspecified;
501 code depending on specific behavior was wrong.]}
502 @end{DiffWord2012}
503
504
505 @LabeledAddedSubclause{Version=[2],Name=[The Package Containers]}
506
507 @begin{Intro}
508 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
509 @ChgAdded{Version=[2],Text=[The package Containers is the root of
510 the containers subsystem.]}
511 @end{Intro}
512
513 @begin{StaticSem}
514 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
515 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The library package
516 Containers has the following declaration:]}
517 @begin{Example}
518 @ChgRef{Version=[2],Kind=[AddedNormal]}
519 @ChgAdded{Version=[2],Text=[@key{package} Ada.Containers @key{is}@ChildUnit{Parent=[Ada],Child=[Containers]}
520 @key{pragma} Pure(Containers);]}
521
522 @ChgRef{Version=[2],Kind=[AddedNormal]}
523 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Hash_Type} @key{is mod} @RI<implementation-defined>;]}
524
525 @ChgRef{Version=[2],Kind=[AddedNormal]}
526 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Count_Type} @key{is range} 0 .. @RI<implementation-defined>;]}
527
528 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
529 @ChgAdded{Version=[3],Text=[ @AdaExcDefn{Capacity_Error} : @key[exception];]}
530
531 @ChgRef{Version=[2],Kind=[AddedNormal]}
532 @ChgAdded{Version=[2],Text=[@key{end} Ada.Containers;]}
533 @end{Example}
534
535 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
536 @ChgAdded{Version=[2],Text=[Hash_Type represents the range of the result of a
537 hash function. Count_Type represents the (potential or actual) number of
538 elements of a container.]}
539 @ChgImpldef{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
540 Text=[The value of Containers.Hash_Type'Modulus. The value of
541 Containers.Count_Type'Last.]}]}
542
543 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0262-1]}
544 @ChgAdded{Version=[3],Text=[Capacity_Error is raised when the capacity of a
545 container is exceeded.]}
546
547 @end{StaticSem}
548
549 @begin{ImplAdvice}
550 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
551 @ChgAdded{Version=[2],Text=[Hash_Type'Modulus should be at least 2**32.
552 Count_Type'Last should be at least 2**31@en@;1.]}
553 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
554 Text=[Containers.Hash_Type'Modulus should be at least 2**32.
555 Containers.Count_Type'Last should be at least 2**31@en@;1.]}]}
556
557 @begin{Discussion}
558 @ChgRef{Version=[2],Kind=[AddedNormal]}
559 @ChgAdded{Version=[2],Text=[This is not a requirement so that these types
560 can be declared
561 properly on machines with native sizes that are not 32 bits. For instance, a
562 24-bit target could use 2**24 for Hash_Type'Modulus.]}
563 @end{Discussion}
564 @end{ImplAdvice}
565
566 @begin{Extend95}
567 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
568 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
569 The package Containers is new.]}
570 @end{Extend95}
571
572 @begin{Incompatible2005}
573 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
574 @ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Exception Capacity_Error
575 is added to Containers. If Containers is referenced in a @nt{use_clause},
576 and an entity with the name Capacity_Error is defined in a package that is
577 also referenced in a @nt{use_clause}, the entity Capacity_Error may no
578 longer be use-visible, resulting in errors. This should be rare and is
579 easily fixed if it does occur.]}
580 @end{Incompatible2005}
581
582
583
584 @LabeledAddedSubclause{Version=[2],Name=[The Generic Package Containers.Vectors]}
585
586 @begin{Intro}
587 @ChgRef{Version=[2],Kind=[AddedNormal]}
588 @ChgAdded{Version=[2],Text=[The language-defined generic package
589 Containers.Vectors provides private types Vector and Cursor, and a set of
590 operations for each type. A vector container allows insertion and deletion at
591 any position, but it is specifically optimized for insertion and deletion at
592 the high end (the end with the higher index) of the container. A vector
593 container also provides random access to its elements.@Defn{vector container}
594 @Defn2{Term=[container],Sec=[vector]}]}
595
596 @ChgRef{Version=[2],Kind=[AddedNormal]}
597 @ChgAdded{Version=[2],Text=[@Pdefn2{Term=[length], Sec=(of a vector container)}
598 @Pdefn2{Term=[capacity], Sec=(of a vector)}
599 A vector container behaves conceptually as an array that expands as necessary
600 as items are inserted. The @i{length} of a vector is the number of elements that
601 the vector contains. The @i{capacity} of a vector is the maximum number of
602 elements that can be inserted into the vector prior to it being automatically
603 expanded.]}
604
605 @ChgRef{Version=[2],Kind=[AddedNormal]}
606 @ChgAdded{Version=[2],Text=[Elements in a vector container can be referred to by
607 an index value of a generic formal type. The first element of a vector always
608 has its index value equal to the lower bound of the formal type.]}
609
610 @ChgRef{Version=[2],Kind=[AddedNormal]}
611 @ChgAdded{Version=[2],Text=[@Pdefn2{Term=[empty element], Sec=(of a vector)}
612 A vector container may contain @i{empty elements}. Empty elements do not have a
613 specified value.]}
614
615 @begin{ImplNote}
616 @ChgRef{Version=[2],Kind=[AddedNormal]}
617 @ChgAdded{Version=[2],Text=[
618 Vectors are not intended to be sparse (that is, there are elements at all
619 defined positions). Users are expected to use other containers (like a Map)
620 when they need sparse structures (there is a Note to this effect at the
621 end of this subclause).]}
622
623 @ChgRef{Version=[2],Kind=[AddedNormal]}
624 @ChgAdded{Version=[2],Text=[
625 The internal array is a conceptual model of a vector. There is no requirement
626 for an implementation to be a single contiguous array.]}
627 @end{Implnote}
628 @end{Intro}
629
630 @begin{StaticSem}
631 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
632 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library
633 package Containers.Vectors has the following declaration:]}
634 @begin{Example}
635 @ChgRef{Version=[2],Kind=[AddedNormal]}
636 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0084-1],ARef=[AI05-0212-1]}
637 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
638 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[@key[with] Ada.Iterator_Interfaces;
639 ],Old=[]}@key{generic}
640 @key{type} Index_Type @key{is range} <>;
641 @key{type} Element_Type @key{is private};
642 @key{with function} "=" (Left, Right : Element_Type)
643 @key{return} Boolean @key{is} <>;
644 @key{package} Ada.Containers.Vectors@Chg{Version=[5],New=[],Old=[ @key{is}]}@ChildUnit{Parent=[Ada.Containers],Child=[Vectors]}@Chg{Version=[5],New=[
645 @key[with] Preelaborate, Remote_Types,
646 Nonblocking, Global => @key[null] @key[is]],Old=[
647 @key{pragma} Preelaborate(Vectors);@Chg{Version=[3],New=[
648 @key{pragma} Remote_Types(Vectors);],Old=[]}]}]}
649
650 @begin{Discussion}
651 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
652 @ChgAdded{Version=[5],Text=[For the Global aspect, any side-effects of the
653 actual parameters of an instance are ignored. So Global => @key[null] means
654 that the only global side-effects allowed are associated with the actual
655 generic parameters. Package state is still allowed for packages that are not
656 Pure, but it must be task-safe (that is, @key[synchronized]) and cannot
657 affect the result for correct code.]}
658
659 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
660 @ChgAdded{Version=[5],Text=[Similarly, when Nonblocking is set to True for
661 a generic unit, it still includes the blocking affects of the actual
662 parameters to the instance. Thus, the only blocking allowed is that
663 associated with the actual generic parameters. If none of the actual
664 paramerters allow blocking, then no operation of the generic may block.]}
665 @end{Discussion}
666
667 @ChgRef{Version=[2],Kind=[AddedNormal]}
668 @ChgAdded{Version=[2],Text=[ @key{subtype} @AdaSubtypeDefn{Name=[Extended_Index],Of=[Index_Type'Base]} @key{is}
669 Index_Type'Base @key{range}
670 Index_Type'First-1 ..
671 Index_Type'Min (Index_Type'Base'Last - 1, Index_Type'Last) + 1;
672 @AdaObjDefn{No_Index} : @key{constant} Extended_Index := Extended_Index'First;]}
673
674 @begin{Ramification}
675 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
676 @ChgAdded{Version=[5],Text=[The base type of a scalar type always is
677 nonblocking and has Global => @key[null]. Therefore, so long as this type
678 is used in the implementation, whether or not the actual type for
679 Index_Type allows blocking or side-effects does not matter. Therefore,
680 we require that operations that only operate on the container
681 implementation by nonblocking and have Global => @key[null] regardless
682 of the actual parameters.]}
683 @end{Ramification}
684
685 @ChgRef{Version=[2],Kind=[AddedNormal]}
686 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]}
687 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0111-1],ARef=[AI12-0112-1],ARef=[AI12-0212-1],ARef=[AI12-0339-1]}
688 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Vector} @key{is tagged private}@Chg{Version=[3],New=[
689 @key[with] Constant_Indexing => Constant_Reference,
690 Variable_Indexing => Reference,
691 Default_Iterator => Iterate,
692 Iterator_Element => Element_Type],Old=[]}@Chg{Version=[5],New=[,
693 Iterator_View => Stable.Vector,
694 Aggregate => (Empty => Empty,
695 Add_Unnamed => Append_One,
696 New_Indexed => New_Vector,
697 Assign_Indexed => Replace_Element),
698 Stable_Properties => (Length, Capacity,
699 Tampering_With_Cursors_Prohibited,
700 Tampering_With_Elements_Prohibited),
701 Default_Initial_Condition =>
702 Length (Vector) = 0 @key{and then}
703 (@key{not} Tampering_With_Cursors_Prohibited (Vector)) @key{and then}
704 (@key{not} Tampering_With_Elements_Prohibited (Vector))],Old=[]};
705 @key{pragma} Preelaborable_Initialization(Vector);]}
706
707 @ChgRef{Version=[2],Kind=[AddedNormal]}
708 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private};
709 @key{pragma} Preelaborable_Initialization(Cursor);]}
710
711 @ChgRef{Version=[2],Kind=[AddedNormal]}
712 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{Empty_Vector} : @key{constant} Vector;]}
713
714 @ChgRef{Version=[2],Kind=[AddedNormal]}
715 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]}
716
717 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
718 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
719 @ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
720 @key[with] Nonblocking, Global => (@key[in all], @key[use null])],Old=[]};]}
721
722 @begin{Discussion}
723 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
724 @ChgAdded{Version=[5],Text=[Any operation that takes a cursor but no vector
725 can read the vector associated with the cursor. We only know that that is
726 some object of type Vector. Since we don't have a global specification
727 that describes all objects of a specific type, we have to allow reading
728 any object by specifying @key[in all]. For such functions, we don't allow
729 writing any object, even those associated with generic formal parameters,
730 thus we also specify @key[use null].]}
731 @end{Discussion}
732
733 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
734 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Has_Element} (Container : Vector; Position : Cursor)
735 @key{return} Boolean
736 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
737
738 @begin{Discussion}
739 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
740 @ChgAdded{Version=[5],Text=[For operations that do not depend on any of
741 the operations of the generic formal parameters (including those of formal
742 types), we specify that the operation has no side-effects of any kind.
743 This requires specifying that there is no dependence on the generic formal
744 parameters with @key[use null] in addition to no usual side-effects with
745 @key[null]. We also specify Nonblocking on such operations in order that
746 the operation never blocks even if some of the actual parameters allow
747 blocking.]}
748 @end{Discussion}
749
750 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
751 @ChgRef{Version=[5],Kind=[RevisedAdded]}@ChgNote{Just a paragraph number change}
752 @ChgAdded{Version=[3],Text=[ @key[package] @AdaPackDefn{Vector_Iterator_Interfaces} @key[is new]
753 Ada.Iterator_Interfaces (Cursor, Has_Element);]}
754
755 @ChgRef{Version=[2],Kind=[AddedNormal]}
756 @ChgAdded{Version=[2],Text=[ @key{function} "=" (Left, Right : Vector) @key{return} Boolean;]}
757
758 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
759 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Tampering_With_Cursors_Prohibited}
760 (Container : Vector) @key{return} Boolean
761 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
762
763 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
764 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Tampering_With_Elements_Prohibited}
765 (Container : Vector) @key{return} Boolean
766 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
767
768 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
769 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Maximum_Length} @key{return} Count_Type
770 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
771
772 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0339-1]}
773 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Empty} (Capacity : Count_Type := @RI<implementation-defined>)
774 @key{return} Vector
775 @key[with] Pre => Capacity <= Maximum_Length @key[or else raise] Constraint_Error,
776 Post =>
777 Capacity (Empty'Result) >= Capacity @key[and then]
778 @key[not] Tampering_With_Elements_Prohibited (Empty'Result) @key[and then]
779 @key[not] Tampering_With_Cursors_Prohibited (Empty'Result) @key[and then]
780 Length (Empty'Result) = 0;]}
781
782 @ChgRef{Version=[2],Kind=[AddedNormal]}
783 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
784 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{To_Vector} (Length : Count_Type) @key{return} Vector@Chg{Version=[5],New=[
785 @key[with] Pre => Length <= Maximum_Length @key[or else raise] Constraint_Error,
786 Post =>
787 To_Vector'Result.Length = Length @key[and then]
788 @key[not] Tampering_With_Elements_Prohibited (To_Vector'Result) @key[and then]
789 @key[not] Tampering_With_Cursors_Prohibited (To_Vector'Result) @key[and then]
790 To_Vector'Result.Capacity >= Length],Old=[]};]}
791
792 @ChgRef{Version=[2],Kind=[AddedNormal]}
793 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
794 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{To_Vector}
795 (New_Item : Element_Type;
796 Length : Count_Type) @key{return} Vector@Chg{Version=[5],New=[
797 @key[with] Pre => Length <= Maximum_Length @key[or else raise] Constraint_Error,
798 Post =>
799 To_Vector'Result.Length = Length @key[and then]
800 @key[not] Tampering_With_Elements_Prohibited (To_Vector'Result) @key[and then]
801 @key[not] Tampering_With_Cursors_Prohibited (To_Vector'Result) @key[and then]
802 To_Vector'Result.Capacity >= Length],Old=[]};]}
803
804 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0212-1]}
805 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{New_Vector} (First, Last : Index_Type) @key{return} Vector @key{is}
806 (To_Vector (Count_Type (Last - First + 1)))
807 @key{with} Pre => First = Index_Type'First;]}
808
809 @ChgRef{Version=[2],Kind=[AddedNormal]}
810 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
811 @ChgAdded{Version=[2],Text=[ @key{function} "&" (Left, Right : Vector) @key{return} Vector@Chg{Version=[5],New=[
812 @key{with} Pre => Length (Left) <= Maximum_Length - Length (Right)
813 @key[or else raise] Constraint_Error,
814 Post => Length (Vectors."&"'Result) = Length (Left) + Length (Right) @key[and then]
815 @key[not] Tampering_With_Elements_Prohibited (Vectors."&"'Result) @key[and then]
816 @key[not] Tampering_With_Cursors_Prohibited (Vectors."&"'Result) @key[and then]
817 Vectors."&"'Result.Capacity >= Length (Left) + Length (Right)],Old=[]};]}
818
819 @ChgRef{Version=[2],Kind=[AddedNormal]}
820 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
821 @ChgAdded{Version=[2],Text=[ @key{function} "&" (Left : Vector;
822 Right : Element_Type) @key{return} Vector@Chg{Version=[5],New=[
823 @key{with} Pre => Length (Left) <= Maximum_Length - 1
824 @key[or else raise] Constraint_Error,
825 Post => Vectors."&"'Result.Length = Length (Left) + 1 @key[and then]
826 @key[not] Tampering_With_Elements_Prohibited (Vectors."&"'Result) @key[and then]
827 @key[not] Tampering_With_Cursors_Prohibited (Vectors."&"'Result) @key[and then]
828 Vectors."&"'Result.Capacity >= Length (Left) + 1],Old=[]};]}
829
830 @ChgRef{Version=[2],Kind=[AddedNormal]}
831 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
832 @ChgAdded{Version=[2],Text=[ @key{function} "&" (Left : Element_Type;
833 Right : Vector) @key{return} Vector@Chg{Version=[5],New=[
834 @key{with} Pre => Length (Right) <= Maximum_Length - 1
835 @key[or else raise] Constraint_Error,
836 Post => Length (Vectors."&"'Result) = Length (Right) + 1 @key[and then]
837 @key[not] Tampering_With_Elements_Prohibited (Vectors."&"'Result) @key[and then]
838 @key[not] Tampering_With_Cursors_Prohibited (Vectors."&"'Result) @key[and then]
839 Vectors."&"'Result.Capacity >= Length (Right) + 1],Old=[]};]}
840
841 @ChgRef{Version=[2],Kind=[AddedNormal]}
842 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
843 @ChgAdded{Version=[2],Text=[ @key{function} "&" (Left, Right : Element_Type) @key{return} Vector@Chg{Version=[5],New=[
844 @key{with} Pre => Maximum_Length >= 2 @key[or else raise] Constraint_Error,
845 Post => Length ("&"'Result) = 2 @key[and then]
846 @key[not] Tampering_With_Elements_Prohibited (Vectors."&"'Result) @key[and then]
847 @key[not] Tampering_With_Cursors_Prohibited (Vectors."&"'Result) @key[and then]
848 Vectors."&"'Result.Capacity >= 2],Old=[]};]}
849
850 @ChgRef{Version=[2],Kind=[AddedNormal]}
851 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
852 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Capacity} (Container : Vector) @key{return} Count_Type@Chg{Version=[5],New=[
853 @key[with] Nonblocking, Global => (@key{null}, @key{use null})],Old=[]};]}
854
855 @ChgRef{Version=[2],Kind=[AddedNormal]}
856 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
857 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reserve_Capacity} (Container : @key{in out} Vector;
858 Capacity : @key{in} Count_Type)@Chg{Version=[5],New=[
859 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
860 @key[or else raise] Program_Error,
861 Post => Container.Capacity >= Capacity],Old=[]};]}
862
863 @ChgRef{Version=[2],Kind=[AddedNormal]}
864 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
865 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Length} (Container : Vector) @key{return} Count_Type@Chg{Version=[5],New=[
866 @key[with] Nonblocking, Global => (@key{null}, @key{use null})],Old=[]};]}
867
868 @ChgRef{Version=[2],Kind=[AddedNormal]}
869 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
870 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Set_Length} (Container : @key{in out} Vector;
871 Length : @key{in} Count_Type)@Chg{Version=[5],New=[
872 @key[with] Pre => (@key[not] Tampering_With_Cursors_Prohibited (Container)
873 @key[or else raise] Program_Error) @key[and then]
874 (Length <= Maximum_Length @key[or else raise] Constraint_Error),
875 Post => Container.Length = Length @key[and then]
876 Capacity (Container) >= Length],Old=[]};]}
877
878 @ChgRef{Version=[2],Kind=[AddedNormal]}
879 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
880 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Empty} (Container : Vector) @key{return} Boolean@Chg{Version=[5],New=[
881 @key[with] Nonblocking, Global => (@key{null}, @key{use null}),
882 Post => Is_Empty'Result = (Length (Container) = 0)],Old=[]};]}
883
884 @ChgRef{Version=[2],Kind=[AddedNormal]}
885 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
886 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Clear} (Container : @key{in out} Vector)@Chg{Version=[5],New=[
887 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
888 @key[or else raise] Program_Error,
889 Post => Length (Container) = 0],Old=[]};]}
890
891 @ChgRef{Version=[2],Kind=[AddedNormal]}
892 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
893 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{To_Cursor} (Container : Vector;
894 Index : Extended_Index) @key{return} Cursor@Chg{Version=[5],New=[
895 @key{with} Post => (@key{if} Index @key{in} First_Index (Container) .. Last_Index (Container)
896 @key{then} Has_Element (Container, To_Cursor'Result)
897 @key{else} To_Cursor'Result = No_Element),
898 Nonblocking, Global => (@key{null}, @key{use null})],Old=[]};]}
899
900 @ChgRef{Version=[2],Kind=[AddedNormal]}
901 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
902 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{To_Index} (Position : Cursor) @key{return} Extended_Index@Chg{Version=[5],New=[
903 @key{with} Nonblocking, Global => @key{in all}],Old=[]};]}
904
905 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
906 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{To_Index} (Container : Vector;
907 Position : Cursor) @key{return} Extended_Index
908 @key{with} Pre => Position = No_Element @key{or else}
909 Has_Element (Container, Position) @key{or else}
910 @key{raise} Program_Error,
911 Post => (@key{if} Position = No_Element @key{then} To_Index'Result = No_Index
912 @key{else} To_Index'Result @key{in} First_Index (Container) ..
913 Last_Index (Container)),
914 Nonblocking, Global => (@key{null}, @key{use null});]}
915
916 @ChgRef{Version=[2],Kind=[AddedNormal]}
917 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
918 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Container : Vector;
919 Index : Index_Type)
920 @key{return} Element_Type@Chg{Version=[5],New=[
921 @key{with} Pre => Index @key{in} First_Index (Container) .. Last_Index (Container)
922 @key{or else raise} Constraint_Error,
923 Nonblocking => Element_Type'Nonblocking,
924 Global => (@key{null}, @key{use} Element_Type)],Old=[]};]}
925
926 @begin{Discussion}
927 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
928 @ChgAdded{Version=[5],Text=[Here the Nonblocking and Global contracts are
929 saying that Element depends on the properties of the actual for
930 Element_Type, but not on the properties of the actuals for Index_Type or
931 "=". This is necessary as copying the element may require calling
932 Adjust and Finalize for the actual Element_Type, and those may have
933 side-effects or block.]}
934 @end{Discussion}
935
936 @ChgRef{Version=[2],Kind=[AddedNormal]}
937 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
938 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Position : Cursor) @key{return} Element_Type@Chg{Version=[5],New=[
939 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
940 Nonblocking => Element_Type'Nonblocking,
941 Global => (@key{in all}, @key{use} Element_Type)],Old=[]};]}
942
943 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
944 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Element} (Container : Vector;
945 Position : Cursor) @key{return} Element_Type
946 @key{with} Pre => (Position /= No_Element @key{or else}
947 @key{raise} Constraint_Error) @key{and then}
948 (Has_Element (Container, Position) @key{or else raise} Program_Error),
949 Nonblocking => Element_Type'Nonblocking,
950 Global => (@key{null}, @key{use} Element_Type);]}
951
952 @ChgRef{Version=[2],Kind=[AddedNormal]}
953 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
954 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} Vector;
955 Index : @key{in} Index_Type;
956 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
957 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
958 @key{or else raise} Program_Error) @key{and then}
959 (Index @key{in} First_Index (Container) .. Last_Index (Container)
960 @key{or else raise} Constraint_Error)],Old=[]};]}
961
962 @ChgRef{Version=[2],Kind=[AddedNormal]}
963 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
964 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} Vector;
965 Position : @key{in} Cursor;
966 New_item : @key{in} Element_Type)@Chg{Version=[5],New=[
967 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
968 @key{or else raise} Program_Error) @key{and then}
969 (Position /= No_Element
970 @key{or else raise} Constraint_Error) @key{and then}
971 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
972
973 @ChgRef{Version=[2],Kind=[AddedNormal]}
974 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
975 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element}
976 (Container : @key{in} Vector;
977 Index : @key{in} Index_Type;
978 Process : @key{not null access procedure} (Element : @key{in} Element_Type))@Chg{Version=[5],New=[
979 @key{with} Pre => Index @key{in} First_Index (Container) .. Last_Index (Container)
980 @key{or else raise} Constraint_Error],Old=[]};]}
981
982 @ChgRef{Version=[2],Kind=[AddedNormal]}
983 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
984 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element}
985 (Position : @key{in} Cursor;
986 Process : @key{not null access procedure} (Element : @key{in} Element_Type))@Chg{Version=[5],New=[
987 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
988 Global => @key{in all}],Old=[]};]}
989
990 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
991 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Query_Element}
992 (Container : @key{in} Vector;
993 Position : @key{in} Cursor;
994 Process : @key{not null access procedure} (Element : @key{in} Element_Type))
995 @key{with} Pre => (Position /= No_Element
996 @key{or else raise} Constraint_Error) @key{and then}
997 (Has_Element (Container, Position)
998 @key{or else raise} Program_Error);]}
999
1000 @ChgRef{Version=[2],Kind=[AddedNormal]}
1001 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1002 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element}
1003 (Container : @key{in out} Vector;
1004 Index : @key{in} Index_Type;
1005 Process : @key{not null access procedure}
1006 (Element : @key{in out} Element_Type))@Chg{Version=[5],New=[
1007 @key{with} Pre => Index @key{in} First_Index (Container) .. Last_Index (Container)
1008 @key{or else raise} Constraint_Error],Old=[]};]}
1009
1010 @ChgRef{Version=[2],Kind=[AddedNormal]}
1011 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1012 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element}
1013 (Container : @key{in out} Vector;
1014 Position : @key{in} Cursor;
1015 Process : @key{not null access procedure}
1016 (Element : @key{in out} Element_Type))@Chg{Version=[5],New=[
1017 @key{with} Pre => (Position /= No_Element @key{or else raise} Constraint_Error) @key{and then}
1018 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
1019
1020 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1021 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1022 @ChgAdded{Version=[3],Text=[ @key[type] Constant_Reference_Type
1023 (Element : @key[not null access constant] Element_Type) @key[is private]
1024 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
1025 Nonblocking, Global => @key[in out synchronized],
1026 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
1027
1028 @begin{Discussion}
1029 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
1030 @ChgAdded{Version=[5],Text=[Finalization of this type will update the
1031 tampering counter of an associated container. We know this has to be an
1032 object of type Vector, but we don't have a way to specify that. We need
1033 this separate Global in case an object of this type is declared to exist
1034 separately from the short-lived object associated with a call of the
1035 Constant_Reference function.]}
1036 @end{Discussion}
1037
1038 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1039 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1040 @ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Reference_Type} (Element : @key[not null access] Element_Type) @key[is private]
1041 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
1042 Nonblocking, Global => @key[in out synchronized],
1043 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
1044
1045 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1046 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1047 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Vector;
1048 Index : @key[in] Index_Type)
1049 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
1050 @key[with] Pre => Index @key[in] First_Index (Container) .. Last_Index (Container)
1051 @key[or else raise] Constraint_Error,
1052 Post => Tampering_With_Cursors_Prohibited (Container),
1053 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
1054
1055 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1056 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1057 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] Vector;
1058 Index : @key[in] Index_Type)
1059 @key[return] Reference_Type@Chg{Version=[5],New=[
1060 @key[with] Pre => Index @key[in] First_Index (Container) .. Last_Index (Container)
1061 @key[or else raise] Constraint_Error,
1062 Post => Tampering_With_Cursors_Prohibited (Container),
1063 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
1064
1065 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1066 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1067 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Vector;
1068 Position : @key[in] Cursor)
1069 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
1070 @key[with] Pre => (Position /= No_Element @key[or else]
1071 @key[raise] Constraint_Error) @key[and then]
1072 (Has_Element (Container, Position) @key[or else raise] Program_Error),
1073 Post => Tampering_With_Cursors_Prohibited (Container),
1074 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
1075
1076 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1077 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1078 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] Vector;
1079 Position : @key[in] Cursor)
1080 @key[return] Reference_Type@Chg{Version=[5],New=[
1081 @key[with] Pre => (Position /= No_Element @key[or else]
1082 @key[raise] Constraint_Error) @key[and then]
1083 (Has_Element (Container, Position) @key[or else raise] Program_Error),
1084 Post => Tampering_With_Cursors_Prohibited (Container),
1085 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
1086
1087 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
1088 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1089 @ChgAdded{Version=[3],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} Vector; Source : @key{in} Vector)@Chg{Version=[5],New=[
1090 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Target)
1091 @key[or else raise] Program_Error,
1092 Post => Length (Source) = Length (Target) @key{and then}
1093 Capacity (Target) >= Length (Target)],Old=[]};]}
1094
1095 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
1096 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1097 @ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Copy} (Source : Vector; Capacity : Count_Type := 0)
1098 @key[return] Vector@Chg{Version=[5],New=[
1099 @key[with] Pre => Capacity = 0 @key[or else] Capacity >= Length (Source)
1100 @key[or else raise] Capacity_Error,
1101 Post => Length (Copy'Result) = Length (Source) @key[and then]
1102 @key[not] Tampering_With_Elements_Prohibited (Copy'Result) @key[and then]
1103 @key[not] Tampering_With_Cursors_Prohibited (Copy'Result) @key[and then]
1104 Copy'Result.Capacity >= (@key[if] Capacity = 0 @key[then]
1105 Length (Source) @key[else] Capacity)],Old=[]};]}
1106
1107 @ChgRef{Version=[2],Kind=[AddedNormal]}
1108 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1109 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Move} (Target : @key{in out} Vector;
1110 Source : @key{in out} Vector)@Chg{Version=[5],New=[
1111 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
1112 @key{or else raise} Program_Error) @key{and then}
1113 (@key{not} Tampering_With_Cursors_Prohibited (Source)
1114 @key{or else raise} Program_Error),
1115 Post => (@key{if} Target = Source @key{then} True
1116 @key{else}
1117 Length (Target) = Length (Source'Old) @key{and then}
1118 Length (Source) = 0 @key{and then}
1119 Capacity (Target) >= Length (Source'Old))],Old=[]};]}
1120
1121 @ChgRef{Version=[2],Kind=[AddedNormal]}
1122 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1123 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector;
1124 Before : @key{in} Extended_Index;
1125 New_Item : @key{in} Vector)@Chg{Version=[5],New=[
1126 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1127 @key{or else raise} Program_Error) @key{and then}
1128 (Before @key{in} First_Index (Container) .. Last_Index (Container) + 1
1129 @key{or else raise} Constraint_Error) @key{and then}
1130 (Length (Container) <= Maximum_Length - Length (New_Item)
1131 @key{or else raise} Constraint_Error),
1132 Post => Length (Container)'Old + Length (New_Item) = Length (Container) @key{and then}
1133 Capacity (Container) >= Length (Container)],Old=[]};]}
1134
1135 @ChgRef{Version=[2],Kind=[AddedNormal]}
1136 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1137 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector;
1138 Before : @key{in} Cursor;
1139 New_Item : @key{in} Vector)@Chg{Version=[5],New=[
1140 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1141 @key{or else raise} Program_Error) @key{and then}
1142 (Before = No_Element @key{or else}
1143 Has_Element (Container, Before)
1144 @key{or else raise} Program_Error) @key{and then}
1145 (Length (Container) <= Maximum_Length - Length (New_Item)
1146 @key{or else raise} Constraint_Error),
1147 Post => Length (Container)'Old + Length (New_Item) = Length (Container) @key{and then}
1148 Capacity (Container) >= Length (Container)],Old=[]};]}
1149
1150 @ChgRef{Version=[2],Kind=[AddedNormal]}
1151 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1152 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector;
1153 Before : @key{in} Cursor;
1154 New_Item : @key{in} Vector;
1155 Position : @key{out} Cursor)@Chg{Version=[5],New=[
1156 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1157 @key{or else raise} Program_Error) @key{and then}
1158 (Before = No_Element @key{or else}
1159 Has_Element (Container, Before)
1160 @key{or else raise} Program_Error) @key{and then}
1161 (Length (Container) <= Maximum_Length - Length (New_Item)
1162 @key{or else raise} Constraint_Error),
1163 Post => Length (Container)'Old + Length (New_Item) = Length (Container) @key{and then}
1164 Has_Element (Container, Position) @key{and then}
1165 Capacity (Container) >= Length (Container)],Old=[]};]}
1166
1167 @ChgRef{Version=[2],Kind=[AddedNormal]}
1168 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1169 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector;
1170 Before : @key{in} Extended_Index;
1171 New_Item : @key{in} Element_Type;
1172 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
1173 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1174 @key{or else raise} Program_Error) @key{and then}
1175 (Before @key{in} First_Index (Container) .. Last_Index (Container) + 1
1176 @key{or else raise} Constraint_Error) @key{and then}
1177 (Length (Container) <= Maximum_Length - Count
1178 @key{or else raise} Constraint_Error),
1179 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
1180 Capacity (Container) >= Length (Container)],Old=[]};]}
1181
1182 @ChgRef{Version=[2],Kind=[AddedNormal]}
1183 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1184 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector;
1185 Before : @key{in} Cursor;
1186 New_Item : @key{in} Element_Type;
1187 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
1188 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1189 @key{or else raise} Program_Error) @key{and then}
1190 (Before = No_Element @key{or else}
1191 Has_Element (Container, Before)
1192 @key{or else raise} Program_Error) @key{and then}
1193 (Length (Container) <= Maximum_Length - Count
1194 @key{or else raise} Constraint_Error),
1195 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
1196 Capacity (Container) >= Length (Container)],Old=[]};]}
1197
1198 @ChgRef{Version=[2],Kind=[AddedNormal]}
1199 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1200 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector;
1201 Before : @key{in} Cursor;
1202 New_Item : @key{in} Element_Type;
1203 Position : @key{out} Cursor;
1204 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
1205 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1206 @key{or else raise} Program_Error) @key{and then}
1207 (Before = No_Element @key{or else}
1208 Has_Element (Container, Before)
1209 @key{or else raise} Program_Error) @key{and then}
1210 (Length (Container) <= Maximum_Length - Count
1211 @key{or else raise} Constraint_Error),
1212 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
1213 Has_Element (Container, Position) @key{and then}
1214 Capacity (Container) >= Length (Container)],Old=[]};]}
1215
1216 @ChgRef{Version=[2],Kind=[AddedNormal]}
1217 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1218 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector;
1219 Before : @key{in} Extended_Index;
1220 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
1221 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1222 @key{or else raise} Program_Error) @key{and then}
1223 (Before @key{in} First_Index (Container) .. Last_Index (Container) + 1
1224 @key{or else raise} Constraint_Error) @key{and then}
1225 (Length (Container) <= Maximum_Length - Count
1226 @key{or else raise} Constraint_Error),
1227 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
1228 Capacity (Container) >= Length (Container)],Old=[]};]}
1229
1230 @ChgRef{Version=[2],Kind=[AddedNormal]}
1231 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1232 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector;
1233 Before : @key{in} Cursor;
1234 Position : @key{out} Cursor;
1235 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
1236 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1237 @key{or else raise} Program_Error) @key{and then}
1238 (Before = No_Element @key{or else}
1239 Has_Element (Container, Before)
1240 @key{or else raise} Program_Error) @key{and then}
1241 (Length (Container) <= Maximum_Length - Count
1242 @key{or else raise} Constraint_Error),
1243 Post => Length (Container)'Old + Count = Length (Container)
1244 @key{and then} as_Element (Container, Position) @key{and then}
1245 Capacity (Container) >= Length (Container)],Old=[]};]}
1246
1247 @ChgRef{Version=[2],Kind=[AddedNormal]}
1248 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1249 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Prepend} (Container : @key{in out} Vector;
1250 New_Item : @key{in} Vector)@Chg{Version=[5],New=[
1251 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1252 @key{or else raise} Program_Error) @key{and then}
1253 (Length (Container) <= Maximum_Length - Length (New_Item)
1254 @key{or else raise} Constraint_Error),
1255 Post => Length (Container)'Old + Length (New_Item) = Length (Container) @key{and then}
1256 Capacity (Container) >= Length (Container)],Old=[]};]}
1257
1258 @ChgRef{Version=[2],Kind=[AddedNormal]}
1259 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1260 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Prepend} (Container : @key{in out} Vector;
1261 New_Item : @key{in} Element_Type;
1262 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
1263 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1264 @key{or else raise} Program_Error) @key{and then}
1265 (Length (Container) <= Maximum_Length - Count
1266 @key{or else raise} Constraint_Error),
1267 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
1268 Capacity (Container) >= Length (Container)],Old=[]};]}
1269
1270 @ChgRef{Version=[2],Kind=[AddedNormal]}
1271 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1272 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Append} (Container : @key{in out} Vector;
1273 New_Item : @key{in} Vector)@Chg{Version=[5],New=[
1274 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1275 @key{or else raise} Program_Error) @key{and then}
1276 (Length (Container) <= Maximum_Length - Length (New_Item)
1277 @key{or else raise} Constraint_Error),
1278 Post => Length (Container)'Old + Length (New_Item) = Length (Container) @key{and then}
1279 Capacity (Container) >= Length (Container)],Old=[]};]}
1280
1281 @ChgRef{Version=[2],Kind=[AddedNormal]}
1282 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1283 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Append} (Container : @key{in out} Vector;
1284 New_Item : @key{in} Element_Type;
1285 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
1286 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1287 @key{or else raise} Program_Error) @key{and then}
1288 (Length (Container) <= Maximum_Length - Count
1289 @key{or else raise} Constraint_Error),
1290 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
1291 Capacity (Container) >= Length (Container)],Old=[]};]}
1292
1293 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1],ARef=[AI12-0212-1]}
1294 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Append_One} (Container : @key{in out} Vector;
1295 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
1296 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1297 @key{or else raise} Program_Error) @key{and then}
1298 (Length (Container) <= Maximum_Length - 1
1299 @key{or else raise} Constraint_Error),
1300 Post => Length (Container)'Old + 1 = Length (Container) @key{and then}
1301 Capacity (Container) >= Length (Container)],Old=[]};]}
1302
1303 @ChgRef{Version=[2],Kind=[AddedNormal]}
1304 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1305 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert_Space} (Container : @key{in out} Vector;
1306 Before : @key{in} Extended_Index;
1307 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
1308 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1309 @key{or else raise} Program_Error) @key{and then}
1310 (Before @key{in} First_Index (Container) .. Last_Index (Container) + 1
1311 @key{or else raise} Constraint_Error) @key{and then}
1312 (Length (Container) <= Maximum_Length - Count
1313 @key{or else raise} Constraint_Error),
1314 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
1315 Capacity (Container) >= Length (Container)],Old=[]};]}
1316
1317 @ChgRef{Version=[2],Kind=[AddedNormal]}
1318 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1319 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert_Space} (Container : @key{in out} Vector;
1320 Before : @key{in} Cursor;
1321 Position : @key{out} Cursor;
1322 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
1323 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1324 @key{or else raise} Program_Error) @key{and then}
1325 (Before = No_Element @key{or else}
1326 Has_Element (Container, Before)
1327 @key{or else raise} Program_Error) @key{and then}
1328 (Length (Container) <= Maximum_Length - Count
1329 @key{or else raise} Constraint_Error),
1330 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
1331 Has_Element (Container, Position) @key{and then}
1332 Capacity (Container) >= Length (Container)],Old=[]};]}
1333
1334 @ChgRef{Version=[2],Kind=[AddedNormal]}
1335 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1336 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Vector;
1337 Index : @key{in} Extended_Index;
1338 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
1339 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1340 @key{or else raise} Program_Error) @key{and then}
1341 (Index @key{in} First_Index (Container) .. Last_Index (Container) + 1
1342 @key{or else raise} Constraint_Error),
1343 Post => Length (Container)'Old - Count <= Length (Container)],Old=[]};]}
1344
1345 @ChgRef{Version=[2],Kind=[AddedNormal]}
1346 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1347 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Vector;
1348 Position : @key{in out} Cursor;
1349 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
1350 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1351 @key{or else raise} Program_Error) @key{and then}
1352 (Position /= No_Element
1353 @key{or else raise} Constraint_Error) @key{and then}
1354 (Has_Element (Container, Position)
1355 @key{or else raise} Program_Error),
1356 Post => Length (Container)'Old - Count <= Length (Container) @key{and then}
1357 Position = No_Element],Old=[]};]}
1358
1359 @ChgRef{Version=[2],Kind=[AddedNormal]}
1360 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1361 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_First} (Container : @key{in out} Vector;
1362 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
1363 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
1364 @key{or else raise} Program_Error,
1365 Post => Length (Container)'Old - Count <= Length (Container)],Old=[]};]}
1366
1367 @ChgRef{Version=[2],Kind=[AddedNormal]}
1368 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1369 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_Last} (Container : @key{in out} Vector;
1370 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
1371 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
1372 @key{or else raise} Program_Error,
1373 Post => Length (Container)'Old - Count <= Length (Container)],Old=[]};]}
1374
1375 @ChgRef{Version=[2],Kind=[AddedNormal]}
1376 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1377 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reverse_Elements} (Container : @key{in out} Vector)@Chg{Version=[5],New=[
1378 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
1379 @key{or else raise} Program_Error],Old=[]};]}
1380
1381 @ChgRef{Version=[2],Kind=[AddedNormal]}
1382 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1383 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Swap} (Container : @key{in out} Vector;
1384 I, J : @key{in} Index_Type)@Chg{Version=[5],New=[
1385 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
1386 @key{or else raise} Program_Error) @key{and then}
1387 (I @key{in} First_Index (Container) .. Last_Index (Container)
1388 @key{or else raise} Constraint_Error) @key{and then}
1389 (J @key{in} First_Index (Container) .. Last_Index (Container)
1390 @key{or else raise} Constraint_Error)],Old=[]};]}
1391
1392 @ChgRef{Version=[2],Kind=[AddedNormal]}
1393 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1394 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Swap} (Container : @key{in out} Vector;
1395 I, J : @key{in} Cursor)@Chg{Version=[5],New=[
1396 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
1397 @key{or else raise} Program_Error) @key{and then}
1398 (I /= No_Element @key{or else} Constraint_Error) @key{and then}
1399 (J /= No_Element @key{or else} Constraint_Error) @key{and then}
1400 (Has_Element (Container, I)
1401 @key{or else raise} Program_Error) @key{and then}
1402 (Has_Element (Container, J)
1403 @key{or else raise} Program_Error)],Old=[]};]}
1404
1405 @ChgRef{Version=[2],Kind=[AddedNormal]}
1406 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1407 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First_Index} (Container : Vector) @key{return} Index_Type@Chg{Version=[5],New=[
1408 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
1409 Post => First_Index'Result = Index_Type'First],Old=[]};]}
1410
1411 @ChgRef{Version=[2],Kind=[AddedNormal]}
1412 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1413 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First} (Container : Vector) @key{return} Cursor@Chg{Version=[5],New=[
1414 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
1415 Post => (@key{if not} Is_Empty (Container)
1416 @key{then} Has_Element (Container, First'Result)
1417 @key{else} First'Result = No_Element)],Old=[]};]}
1418
1419 @ChgRef{Version=[2],Kind=[AddedNormal]}
1420 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1421 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First_Element} (Container : Vector)
1422 @key{return} Element_Type@Chg{Version=[5],New=[
1423 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
1424
1425 @ChgRef{Version=[2],Kind=[AddedNormal]}
1426 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1427 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last_Index} (Container : Vector) @key{return} Extended_Index@Chg{Version=[5],New=[
1428 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
1429 Post => (@key{if} Length (Container) = 0 @key{then} Last_Index'Result = No_Index
1430 @key{else} Count_Type(Last_Index'Result - Index_Type'First) =
1431 Length (Container) - 1)],Old=[]};]}
1432
1433 @ChgRef{Version=[2],Kind=[AddedNormal]}
1434 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1435 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last} (Container : Vector) @key{return} Cursor@Chg{Version=[5],New=[
1436 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
1437 Post => (@key{if} not Is_Empty (Container)
1438 @key{then} Has_Element (Container, Last'Result)
1439 @key{else} Last'Result = No_Element)],Old=[]};]}
1440
1441 @ChgRef{Version=[2],Kind=[AddedNormal]}
1442 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1443 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last_Element} (Container : Vector)
1444 @key{return} Element_Type@Chg{Version=[5],New=[
1445 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
1446
1447 @ChgRef{Version=[2],Kind=[AddedNormal]}
1448 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1449 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Next} (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
1450 @key{with} Global => (@key{in all}, @key{use null}),
1451 Nonblocking => True,
1452 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
1453 @key{else} True)],Old=[]};]}
1454
1455 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1456 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Next} (Container : Vector; Position : Cursor) @key{return} Cursor
1457 @key{with} Nonblocking, Global =>(@key{null}, @key{use null}),
1458 Pre => Position = No_Element @key{or else}
1459 Has_Element (Container, Position)
1460 @key{or else raise} Program_Error,
1461 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
1462 @key{elsif} Has_Element (Container, Next'Result) @key{then}
1463 To_Index (Container, Next'Result) =
1464 To_Index (Container, Position) + 1
1465 @key{elsif} Next'Result = No_Element @key{then}
1466 Position = Last (Container)
1467 @key{else} False);]}
1468
1469 @ChgRef{Version=[2],Kind=[AddedNormal]}
1470 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1471 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Next} (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
1472 @key{with} Global => (@key{in all}, @key{use null}),
1473 Nonblocking => True],Old=[]};]}
1474
1475 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1476 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Next} (Container : @key{in} Vector;
1477 Position : @key{in out} Cursor)
1478 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
1479 Pre => Position = No_Element @key{or else}
1480 Has_Element (Container, Position)
1481 @key{or else raise} Program_Error,
1482 Post => (@key{if} Position /= No_Element
1483 @key{then} Has_Element (Container, Position));]}
1484
1485 @ChgRef{Version=[2],Kind=[AddedNormal]}
1486 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1487 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Previous} (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
1488 @key{with} Global => (@key{in all}, @key{use null}),
1489 Nonblocking => True,
1490 Post => (@key{if} Position = No_Element @key{then} Previous'Result = No_Element
1491 @key{else} True)],Old=[]};]}
1492
1493 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1494 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Previous} (Container : Vector;
1495 Position : Cursor) @key{return} Cursor
1496 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
1497 Pre => Position = No_Element @key{or else}
1498 Has_Element (Container, Position)
1499 @key{or else raise} Program_Error,
1500 Post => (@key{if} Position = No_Element @key{then} Previous'Result = No_Element
1501 @key{elsif} Has_Element (Container, Previous'Result) @key{then}
1502 To_Index (Container, Previous'Result) =
1503 To_Index (Container, Position) - 1
1504 @key{elsif} Previous'Result = No_Element @key{then}
1505 Position = First (Container)
1506 @key{else} False);]}
1507
1508 @ChgRef{Version=[2],Kind=[AddedNormal]}
1509 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1510 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Previous} (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
1511 @key{with} Global => (@key{in all}, @key{use null}),
1512 Nonblocking => True],Old=[]};]}
1513
1514 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1515 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Previous} (Container : @key{in} Vector;
1516 Position : @key{in out} Cursor)
1517 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
1518 Pre => Position = No_Element @key{or else}
1519 Has_Element (Container, Position)
1520 @key{or else raise} Program_Error,
1521 Post => (@key{if} Position /= No_Element
1522 @key{then} Has_Element (Container, Position));]}
1523
1524 @ChgRef{Version=[2],Kind=[AddedNormal]}
1525 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find_Index} (Container : Vector;
1526 Item : Element_Type;
1527 Index : Index_Type := Index_Type'First)
1528 @key{return} Extended_Index;]}
1529
1530 @ChgRef{Version=[2],Kind=[AddedNormal]}
1531 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1532 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Vector;
1533 Item : Element_Type;
1534 Position : Cursor := No_Element)
1535 @key{return} Cursor@Chg{Version=[5],New=[
1536 @key{with} Pre => Position = No_Element @key{or else}
1537 Has_Element (Container, Position)
1538 @key{or else raise} Program_Error,
1539 Post => (@key{if} Find'Result = No_Element @key{then} True
1540 @key{else} Has_Element (Container, Find'Result))],Old=[]};]}
1541
1542 @ChgRef{Version=[2],Kind=[AddedNormal]}
1543 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Reverse_Find_Index} (Container : Vector;
1544 Item : Element_Type;
1545 Index : Index_Type := Index_Type'Last)
1546 @key{return} Extended_Index;]}
1547
1548 @ChgRef{Version=[2],Kind=[AddedNormal]}
1549 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1550 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Reverse_Find} (Container : Vector;
1551 Item : Element_Type;
1552 Position : Cursor := No_Element)
1553 @key{return} Cursor@Chg{Version=[5],New=[
1554 @key{with} Pre => Position = No_Element @key{or else}
1555 Has_Element (Container, Position)
1556 @key{or else raise} Program_Error,
1557 Post => (@key{if} Reverse_Find'Result = No_Element @key{then} True
1558 @key{else} Has_Element (Container, Reverse_Find'Result))],Old=[]};]}
1559
1560 @ChgRef{Version=[2],Kind=[AddedNormal]}
1561 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Vector;
1562 Item : Element_Type) @key{return} Boolean;]}
1563
1564 @ChgRef{Version=[2],Kind=[AddedNormal]}
1565 @ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0212-1]}
1566 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]}]}
1567
1568 @ChgRef{Version=[2],Kind=[AddedNormal]}
1569 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1570 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Iterate}
1571 (Container : @key{in} Vector;
1572 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
1573 @key{with} Allows_Exit],Old=[]};]}
1574
1575 @ChgRef{Version=[2],Kind=[AddedNormal]}
1576 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1577 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reverse_Iterate}
1578 (Container : @key{in} Vector;
1579 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
1580 @key{with} Allows_Exit],Old=[]};]}
1581
1582 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1583 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1],ARef=[AI12-0266-1]}
1584 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Iterate} (Container : @key[in] Vector)
1585 @key[return] Vector_Iterator_Interfaces.@Chg{Version=[5],New=[Parallel_Reversible_Iterator],Old=[Reversible_Iterator]}'Class@Chg{Version=[5],New=[
1586 @key[with] Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
1587
1588 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1589 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1590 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Iterate} (Container : @key[in] Vector; Start : @key[in] Cursor)
1591 @key[return] Vector_Iterator_Interfaces.Reversible_Iterator'Class@Chg{Version=[5],New=[
1592 @key[with] Pre => (Start /= No_Element
1593 @key[or else raise] Constraint_Error) @key[and then]
1594 (Has_Element (Container, Start)
1595 @key[or else raise] Program_Error),
1596 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
1597
1598 @ChgRef{Version=[2],Kind=[AddedNormal]}
1599 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1600 @ChgAdded{Version=[2],Text=[ @key{generic}
1601 @key{with function} "<" (Left, Right : Element_Type)
1602 @key{return} Boolean is <>;
1603 @key{package} @AdaPackDefn{Generic_Sorting}@Chg{Version=[5],New=[
1604 @key{with} Nonblocking, Global => @key{null}],Old=[]} @key{is}]}
1605
1606 @ChgRef{Version=[2],Kind=[AddedNormal]}
1607 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Sorted} (Container : Vector) @key{return} Boolean;]}
1608
1609 @ChgRef{Version=[2],Kind=[AddedNormal]}
1610 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1611 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Sort} (Container : @key{in out} Vector)@Chg{Version=[5],New=[
1612 @key{with} Pre => (@key{if} Tampering_With_Elements_Prohibited (Container)
1613 @key{then raise} Program_Error)],Old=[]};]}
1614
1615 @ChgRef{Version=[2],Kind=[AddedNormal]}
1616 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1617 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Merge} (Target : @key{in out} Vector;
1618 Source : @key{in out} Vector)@Chg{Version=[5],New=[
1619 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
1620 @key{or else raise} Program_Error) @key{and then}
1621 (@key{not} Tampering_With_Cursors_Prohibited (Source)
1622 @key{or else raise} Program_Error) @key{and then}
1623 (Length (Target) <= Maximum_Length - Length (Source)
1624 @key{or else raise} Constraint_Error),
1625 Post => (@key{declare}
1626 Result_Length : @key{constant} Count_Type :=
1627 Length (Source)'Old + Length (Target)'Old;
1628 @key{begin}
1629 (@key{if} Target = Source @key{then} True
1630 @key{else} Length (Source) = 0 @key{and then}
1631 Length (Target) = Result_Length @key{and then}
1632 Capacity (Target) >= Result_Length))],Old=[]};]}
1633
1634 @ChgRef{Version=[2],Kind=[AddedNormal]}
1635 @ChgAdded{Version=[2],Text=[ @key{end} Generic_Sorting;]}
1636
1637 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1638 @ChgAdded{Version=[5],Text=[ @key{package} @AdaPackDefn{Stable} @key{is}]}
1639
1640 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1],ARef=[AI12-0339-1]}
1641 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Vector} (Base : @key{not null access} Vectors.Vector) @key{is}
1642 @key{tagged limited private}
1643 @key{with} Constant_Indexing => Constant_Reference,
1644 Variable_Indexing => Reference,
1645 Default_Iterator => Iterate,
1646 Iterator_Element => Element_Type,
1647 Aggregate => (Empty => Empty,
1648 Add_Unnamed => Append_One,
1649 New_Indexed => New_Vector,
1650 Assign_Indexed => Replace_Element),
1651 Stable_Properties => (Length, Capacity),
1652 Global => @key{null},
1653 Default_Initial_Condition => Length (Vector) = 0;
1654 @key{pragma} Preelaborable_Initialization(Vector);]}
1655
1656 @begin{Discussion}
1657 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI05-0112-1]}
1658 @ChgAdded{Version=[5],Text=[The Global of @key{null} assumes that the
1659 user of a stable object is including effects associated with the
1660 access discriminant. For operations with @key{in} parameters (after
1661 any overriding), the object designated by the access discriminant is
1662 assumed to be read, and for other operations (including initialization
1663 and finalization) the object designated by the access discriminant is
1664 assumed to be read and updated.]}
1665 @end{Discussion}
1666
1667 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1668 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private};
1669 @key{pragma} Preelaborable_Initialization(Cursor);]}
1670
1671 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1672 @ChgAdded{Version=[5],Text=[ @AdaObjDefn{Empty_Vector} : @key{constant} Vector;]}
1673
1674 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1675 @ChgAdded{Version=[5],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]}
1676
1677 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1678 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean
1679 @key{with} Nonblocking, Global => (@key{in all}, @key{use null});]}
1680
1681 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1682 @ChgAdded{Version=[5],Text=[ @key{package} @AdaPackDefn{Vector_Iterator_Interfaces} @key[is new]
1683 Ada.Iterator_Interfaces (Cursor, Has_Element);]}
1684
1685 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1686 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} Vectors.Vector;
1687 Source : @key{in} Vector)
1688 @key{with} Post => Length (Source) = Length (Target) @key{and then}
1689 Capacity (Target) >= Length (Target);]}
1690
1691 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1692 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Copy} (Source : Vectors.Vector) @key{return} Vector
1693 @key{with} Post => Length (Copy'Result) = Length (Source);]}
1694
1695 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1696 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Constant_Reference_Type}
1697 (Element : @key{not null access constant} Element_Type) @key{is private}
1698 @key{with} Implicit_Dereference => Element,
1699 Nonblocking, Global => (@key{null}, @key{use null}),
1700 Default_Initial_Condition => (@key{raise} Program_Error);]}
1701
1702 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1703 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Reference_Type}
1704 (Element : @key{not null access} Element_Type) @key{is private}
1705 @key{with} Implicit_Dereference => Element,
1706 Nonblocking, Global => (@key{null}, @key{use null}),
1707 Default_Initial_Condition => (@key{raise} Program_Error);]}
1708
1709 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1710 @ChgAdded{Version=[5],Text=[ -- @examcom{Additional subprograms as described in the text}
1711 -- @examcom{are declared here.}]}
1712
1713 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1714 @ChgAdded{Version=[5],Text=[ @key{private}]}
1715
1716 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1717 @ChgAdded{Version=[5],Text=[ ... -- @Examcom{not specified by the language}]}
1718
1719 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
1720 @ChgAdded{Version=[5],Text=[ @key{end} Stable;]}
1721
1722 @ChgRef{Version=[2],Kind=[AddedNormal]}
1723 @ChgAdded{Version=[2],Text=[@key{private}]}
1724
1725 @ChgRef{Version=[2],Kind=[AddedNormal]}
1726 @ChgAdded{Version=[2],Text=[ ... -- @RI[not specified by the language]]}
1727
1728 @ChgRef{Version=[2],Kind=[AddedNormal]}
1729 @ChgAdded{Version=[2],Text=[@key{end} Ada.Containers.Vectors;]}
1730
1731 @end{Example}
1732
1733 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1734 @ChgAdded{Version=[2],Text=[The actual function for the generic formal function
1735 "=" on Element_Type values is expected to define a reflexive and symmetric
1736 relationship and return the same result value each time it is called with a
1737 particular pair of values. If it behaves in some other manner, the functions
1738 defined to use it return an unspecified value. The exact arguments and number
1739 of calls of this generic formal function by the functions defined to use it are
1740 unspecified.@PDefn{unspecified}]}
1741
1742 @begin{Ramification}
1743 @ChgRef{Version=[2],Kind=[AddedNormal]}
1744 @ChgAdded{Version=[2],Text=[The @lquotes@;functions defined to use it@rquotes
1745 are Find, Find_Index, Reverse_Find, Reverse_Find_Index, and
1746 "=" for Vectors. This list is a bit too long to give explicitly.]}
1747
1748 @ChgRef{Version=[2],Kind=[AddedNormal]}
1749 @ChgAdded{Version=[2],Text=[If the actual function for "=" is not symmetric
1750 and consistent, the result returned by any of the functions defined to use
1751 "=" cannot be predicted. The implementation is not required to protect
1752 against "=" raising an exception, or returning random results, or any
1753 other @lquotes@;bad@rquotes behavior. And it can call "=" in whatever
1754 manner makes sense. But note that only the results of the functions defined
1755 to use "=" are unspecified; other subprograms are not allowed to break if
1756 "=" is bad.]}
1757 @end{Ramification}
1758
1759 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1760 @ChgAdded{Version=[2],Text=[The type Vector is used to represent vectors.
1761 The type Vector needs finalization@PDefn2{Term=<needs finalization>,
1762 Sec=<language-defined type>}
1763 (see @RefSecNum{Assignment and Finalization}).]}
1764
1765 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1766 @ChgAdded{Version=[2],Text=[Empty_Vector represents the empty vector object. It
1767 has a length of 0. If an object of type Vector is not otherwise initialized, it
1768 is initialized to the same value as Empty_Vector.]}
1769
1770 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1771 @ChgAdded{Version=[2],Text=[No_Element represents a cursor that designates no
1772 element. If an object of type Cursor is not otherwise initialized, it is
1773 initialized to the same value as No_Element.]}
1774
1775 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1776 @ChgAdded{Version=[2],Text=[The predefined "=" operator for type Cursor returns
1777 True if both cursors are No_Element, or designate the same element in the same
1778 container.]}
1779
1780 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1781 @ChgAdded{Version=[2],Text=[Execution of the default implementation of the
1782 Input, Output, Read, or Write attribute of type Cursor raises Program_Error.]}
1783
1784 @begin{Reason}
1785 @ChgRef{Version=[2],Kind=[AddedNormal]}
1786 @ChgAdded{Version=[2],Text=[A cursor will probably be implemented in terms
1787 of one or more access values, and the effects of streaming access values is
1788 unspecified. Rather than letting the user stream junk by accident, we mandate
1789 that streaming of cursors raise Program_Error by default. The attributes
1790 can always be specified if there is a need to support streaming.]}
1791 @end{Reason}
1792
1793 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]}
1794 @ChgAdded{Version=[3],Text=[Vector'Write for a Vector object @i<V> writes
1795 Length(@i<V>) elements of the vector to the stream. It also may write
1796 additional information about the vector.]}
1797
1798 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]}
1799 @ChgAdded{Version=[3],Text=[Vector'Read reads the representation of a vector
1800 from the stream, and assigns to @i<Item> a vector with the same length and
1801 elements as was written by Vector'Write.]}
1802
1803 @begin{ImplNote}
1804 @ChgRef{Version=[3],Kind=[AddedNormal]}
1805 @ChgAdded{Version=[3],Text=[The Standard requires streaming of all
1806 language-defined nonlimited types (including containers) to "work" (see
1807 @RefSecNum{Stream-Oriented Attributes}). In addition, we do not want all
1808 of the elements that make up the
1809 capacity of the vector streamed, as those beyond the length of the container
1810 have undefined contents (and might cause bad things when read back in).
1811 This will require a custom stream attribute
1812 implementation; the language-defined default implementation will not work
1813 (even for a bounded form, as that would most likely stream the entire
1814 capacity of the vector). There is a separate requirement that the unbounded
1815 and Bounded form use the same streaming representation for the same element
1816 type, see @RefSecNum{The Generic Package Containers.Bounded_Vectors}.]}
1817 @end{ImplNote}
1818
1819 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1820 @ChgAdded{Version=[2],Text=[No_Index represents a position that does not
1821 correspond to any element. The subtype Extended_Index includes the indices
1822 covered by Index_Type plus the value No_Index and, if it exists, the successor
1823 to the Index_Type'Last.]}
1824
1825 @begin{Discussion}
1826 @ChgRef{Version=[2],Kind=[AddedNormal]}
1827 @ChgAdded{Version=[2],Text=[We require the existence of Index_Type'First @en 1,
1828 so that No_Index and Last_Index of an empty vector is well-defined. We don't
1829 require the existence of Index_Type'Last + 1, as it is only used as the
1830 position of insertions (and needs to be allowed only when inserting an empty
1831 vector).]}
1832 @end{Discussion}
1833
1834 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
1835 @ChgRef{Version=[5],Kind=[DeletedAddedNoDelMsg],ARef=[AI12-0112-1]}
1836 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[If an operation attempts to modify the vector such
1837 that the position of the last element would be greater than Index_Type'Last,
1838 then the operation propagates Constraint_Error.]}]}@ChgNote{Covered by preconditions.}
1839
1840 @begin{Reason}
1841 @ChgRef{Version=[3],Kind=[AddedNormal]}
1842 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
1843 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[We don't want to
1844 require an implementation to go to heroic efforts to handle index values
1845 larger than the base type of the index subtype.]}]}
1846 @end{Reason}
1847
1848 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1849 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
1850 @ChgAdded{Version=[2],Text=[@Redundant[Some
1851 operations @Chg{Version=[5],New=[@Defn2{Term=[tamper with cursors],Sec=[of a vector]}@Defn2{Term=[tamper with elements],Sec=[of a vector]}],Old=[of this generic package have
1852 access-to-subprogram parameters. To
1853 ensure such operations are well-defined, they guard against certain actions by
1854 the designated subprogram. In particular, some operations]} check for
1855 @lquotes@;tampering with cursors@rquotes of a container because they depend on
1856 the set of elements of the container remaining constant, and others check for
1857 @lquotes@;tampering with elements@rquotes of a container because they depend on
1858 elements of the container not being replaced.]@Chg{Version=[5],New=[ When
1859 tampering with cursors is @i<prohibited>@Defn2{Term=[prohibited],Sec=[tampering with a vector]}
1860 @Defn2{Term=[tampering],Sec=[prohibited for a vector]}for a particular
1861 vector object @i<V>, Program_Error is propagated by the finalization
1862 of @i<V>@Redundant[, as well as by a call that passes @i<V> to
1863 certain of the operations of this package, as indicated by the precondition
1864 of such an operation]. Similarly, when tampering with elements is @i<prohibited>
1865 for @i<V>, Program_Error is propagated by a call that passes @i<V> to
1866 certain of other operations of this package, as indicated by the precondition
1867 of such an operation.],Old=[]}]}
1868
1869 @begin{NotIso}
1870 @ChgAdded{Version=[5],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 91 through 97
1871 are removed as preconditions now describe these rules.>}]}@Comment{This message should be
1872 deleted if the paragraphs are ever renumbered.}
1873 @end{NotIso}
1874
1875
1876 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1877 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
1878 @ChgDeleted{Version=[5],Type=[Leading],Text=[@Chg{Version=[2],New=[@Defn2{Term=[tamper with cursors],Sec=[of a vector]}
1879 A subprogram is said to
1880 @i{tamper with cursors} of a vector object @i<V> if:],Old=[]}]}
1881
1882 @begin{Itemize}
1883
1884 @ChgRef{Version=[2],Kind=[AddedNormal]}
1885 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
1886 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it inserts or deletes
1887 elements of @i<V>, that is,
1888 it calls the Insert, Insert_Space, Clear, Delete, or Set_Length
1889 procedures with @i<V> as a parameter; or]}]}
1890
1891 @begin{Honest}
1892 @ChgRef{Version=[2],Kind=[AddedNormal]}
1893 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
1894 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[Operations which
1895 are defined to be equivalent to
1896 a call on one of these operations also are included. Similarly, operations
1897 which call one of these as part of their definition are included.]}]}
1898 @end{Honest}
1899
1900 @ChgRef{Version=[2],Kind=[AddedNormal]}
1901 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
1902 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it finalizes @i<V>;
1903 or]}]}
1904
1905 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
1906 @ChgRef{Version=[5],Kind=[DeletedAddedNoDelMsg]}
1907 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[it calls the Assign
1908 procedure with @i<V> as the Target parameter; or]}]}
1909
1910 @begin{Ramification}
1911 @ChgRef{Version=[3],Kind=[Added]}
1912 @ChgAdded{Version=[3],Text=[We don't need to explicitly mention
1913 @nt{assignment_statement}, because that finalizes the target object
1914 as part of the operation, and finalization of an object is already defined
1915 as tampering with cursors.]}
1916 @end{Ramification}
1917
1918 @ChgRef{Version=[2],Kind=[AddedNormal]}
1919 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
1920 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it calls the Move
1921 procedure with @i<V> as a parameter.]}]}
1922
1923 @begin{Discussion}
1924 @ChgRef{Version=[2],Kind=[AddedNormal]}
1925 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0111-1]}
1926 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[Swap,
1927 Sort, and Merge copy elements rather than reordering them, so they don't
1928 tamper with cursors.]}]}
1929 @end{Discussion}
1930
1931 @end{Itemize}
1932
1933 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1934 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
1935 @ChgDeleted{Version=[5],Type=[Leading],Text=[@Chg{Version=[2],New=[@Defn2{Term=[tamper with elements],Sec=[of a vector]}
1936 A subprogram is said to @i{tamper with elements} of a vector object @i<V>
1937 if:],Old=[]}]}
1938
1939 @begin{Itemize}
1940
1941 @ChgRef{Version=[2],Kind=[AddedNormal]}
1942 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
1943 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it tampers with
1944 cursors of @i<V>; or]}]}
1945
1946 @ChgRef{Version=[2],Kind=[AddedNormal]}
1947 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
1948 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it replaces one or more
1949 elements of @i<V>, that is, it calls the Replace_Element, Reverse_Elements, or
1950 Swap procedures or the Sort or Merge procedures of an instance of
1951 Generic_Sorting with @i<V> as a parameter.]}]}
1952
1953 @begin{Reason}
1954 @ChgRef{Version=[2],Kind=[AddedNormal]}
1955 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
1956 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[Complete replacement
1957 of an element can cause its memory to be deallocated while another operation
1958 is holding onto a reference to it. That can't be allowed. However, a simple
1959 modification of (part of) an element is not a problem, so Update_Element does
1960 not cause a problem.]}]}
1961 @end{Reason}
1962
1963 @end{Itemize}
1964
1965 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0265-1]}
1966 @ChgRef{Version=[4],Kind=[RevisedAdded],ARef=[AI12-0110-1]}
1967 @ChgRef{Version=[5],Kind=[DeletedAddedNoDelMsg],ARef=[AI12-0112-1]}
1968 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[@Defn2{Term=[prohibited],Sec=[tampering with a vector]}
1969 @Defn2{Term=[tampering],Sec=[prohibited for a vector]}
1970 When tampering with cursors is @i<prohibited> for a particular vector object
1971 @i<V>, Program_Error is propagated by a call of any language-defined subprogram
1972 that is defined to tamper with the cursors of @i<V>, leaving @i<V> unmodified.
1973 Similarly, when tampering with elements is @i<prohibited> for a particular vector
1974 object @i<V>, Program_Error is propagated by a call of any language-defined
1975 subprogram that is defined to tamper with the elements of @i<V> @Redundant[(or
1976 tamper with the cursors of @i<V>)], leaving @i<V>
1977 unmodified.@Chg{Version=[4],New=[ These checks are made before any other
1978 defined behavior of the body of the language-defined subprogram.],Old=[]}]}]}
1979 @begin{TheProof}
1980 @ChgRef{Version=[3],Kind=[AddedNormal]}
1981 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
1982 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[Tampering with
1983 elements includes tampering with cursors, so we mention it only from
1984 completeness in the second sentence.]}]}
1985 @end{TheProof}
1986
1987 @begin{DescribeCode}
1988
1989 @begin{Example}
1990 @ChgRef{Version=[3],Kind=[Added]}
1991 @ChgRef{Version=[5],Kind=[RevisedAdded]}
1992 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
1993 @key[with] Nonblocking, Global => (@key[in all], @key[use null])],Old=[]};]}
1994 @end{Example}
1995
1996 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1997 @ChgAdded{Version=[3],Type=[Trailing],Text=[Returns True if Position designates
1998 an element, and returns False otherwise.]}
1999
2000 @begin{Honest}
2001 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1],ARef=[AI05-0212-1]}
2002 @ChgAdded{Version=[3],Text=[This function might not detect cursors that
2003 designate deleted elements; such cursors are invalid (see below) and the
2004 result of calling Has_Element with an invalid cursor is unspecified (but
2005 not erroneous).]}
2006 @end{Honest}
2007
2008 @begin{Example}
2009 @ChgRef{Version=[5],Kind=[Added]}
2010 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} @AdaSubDefn{Has_Element} (Container : Vector; Position : Cursor)
2011 @key{return} Boolean
2012 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
2013 @end{Example}
2014
2015 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
2016 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns True if Position designates
2017 an element in Container, and returns False otherwise.]}
2018
2019 @begin{Ramification}
2020 @ChgRef{Version=[5],Kind=[AddedNormal]}
2021 @ChgAdded{Version=[5],Text=[If Position is No_Element, Has_Element returns False.]}
2022 @end{Ramification}
2023
2024
2025 @begin{Example}
2026 @ChgRef{Version=[2],Kind=[AddedNormal]}
2027 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "=" (Left, Right : Vector) @key{return} Boolean;]}
2028 @end{Example}
2029
2030 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2031 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
2032 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Left and Right denote the same
2033 vector object, then the function returns True. If Left and Right have different
2034 lengths, then the function returns False.
2035 Otherwise, it compares each element in Left to
2036 the corresponding element in Right using the generic formal equality operator.
2037 If any such comparison returns False, the function returns False;
2038 otherwise@Chg{Version=[3],New=[,],Old=[]} it
2039 returns True. Any exception raised during
2040 evaluation of element equality is propagated.]}
2041
2042 @begin{ImplNote}
2043 @ChgRef{Version=[2],Kind=[AddedNormal]}
2044 @ChgAdded{Version=[2],Text=[This wording describes the canonical semantics.
2045 However, the order and number of calls on the formal equality function is
2046 unspecified for all of the operations that use it in this package, so an
2047 implementation can call it as many or as few times as it needs to get the
2048 correct answer. Specifically, there is no requirement to call the formal
2049 equality additional times once the answer has been determined.]}
2050 @end{ImplNote}
2051
2052 @begin{Example}
2053 @ChgRef{Version=[5],Kind=[Added]}
2054 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Tampering_With_Cursors_Prohibited
2055 (Container : Vector) @key{return} Boolean
2056 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
2057 @end{Example}
2058
2059 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
2060 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns True if tampering with
2061 cursors or tampering with elements is currently prohibited for Container, and
2062 returns False otherwise.]}
2063
2064 @begin{Reason}
2065 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
2066 @ChgAdded{Version=[5],Text=[Prohibiting tampering with elements also
2067 needs to prohibit tampering with cursors, as deleting an element is similar
2068 to replacing it.]}
2069 @end{Reason}
2070
2071 @begin{ImplNote}
2072 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
2073 @ChgAdded{Version=[5],Text=[Various contracts elsewhere in this specification
2074 require that this function is implemented with synchronized data. Moreover,
2075 it is possible for tampering to be prohibited by multiple operations
2076 (sequentiually or in parallel). Therefore, tampering needs to be
2077 implemented with an atomic or protected counter. The counter is initialized
2078 to zero, and is incremented when tampering is prohibited, and decremented
2079 when leaving an area that prohibited tampering. Function
2080 Tampering_With_Cursors_Prohibited returns True if the counter is nonzero.
2081 (Note that any case where the result is not well-defined for one task
2082 is incorrect use of shared variables and would be erroneous by the rules
2083 of @RefSecNum{Shared Variables}, so no special protection is needed to
2084 read the counter.)]}
2085 @end{ImplNote}
2086
2087 @begin{Example}
2088 @ChgRef{Version=[5],Kind=[Added]}
2089 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Tampering_With_Elements_Prohibited
2090 (Container : Vector) @key{return} Boolean
2091 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
2092 @end{Example}
2093
2094 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
2095 @ChgAdded{Version=[5],Type=[Trailing],Text=[Always returns False@Redundant[,
2096 regardless of whether tampering with elements is prohibited].]}
2097
2098 @begin{Reason}
2099 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1]}
2100 @ChgAdded{Version=[5],Text=[A definite element cannot
2101 change size, so we allow operations that tamper with elements even when
2102 tampering with elements is prohibited. That's not true for the indefinite
2103 containers, which is why this kind of tampering exists.]}
2104 @end{Reason}
2105
2106 @begin{Example}
2107 @ChgRef{Version=[5],Kind=[Added]}
2108 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Maximum_Length @key{return} Count_Type
2109 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
2110 @end{Example}
2111
2112 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
2113 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns the maximum Length of a Vector, based on the
2114 index type.]}
2115
2116 @begin{ImplNote}
2117 @ChgRef{Version=[5],Kind=[AddedNormal]}
2118 @ChgAdded{Version=[5],Type=[Leading],Text=[This is just:]}
2119
2120 @begin{Example}
2121 @ChgRef{Version=[5],Kind=[AddedNormal]}
2122 @ChgAdded{Version=[5],Text=[Count_Type (Index_Type'Last - Index_Type'First + 1)]}
2123 @end{Example}
2124
2125 @ChgRef{Version=[5],Kind=[AddedNormal]}
2126 @ChgAdded{Version=[5],Type=[Trailing],Text=[but since the inner calculation
2127 can overflow or the type conversion can fail, this can't be evaluated in
2128 general with an expression function. Note that if this expression raises
2129 Constraint_Error, then the result is Count_Type'Last, since the Capacity of
2130 a Vector cannot exceed Count_Type'Last.]}
2131 @end{ImplNote}
2132
2133 @begin{Example}
2134 @ChgRef{Version=[5],Kind=[Added]}
2135 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Empty (Capacity : Count_Type := @RI<implementation-defined>)
2136 @key{return} Vector
2137 @key[with] Pre => Capacity <= Maximum_Length @key[or else raise] Constraint_Error,
2138 Post => Capacity (Empty'Result) >= Capacity @key[and then]
2139 @key[not] Tampering_With_Elements_Prohibited (Empty'Result) @key[and then]
2140 @key[not] Tampering_With_Cursors_Prohibited (Empty'Result) @key[and then]
2141 Length (Empty'Result) = 0;]}
2142 @end{Example}
2143
2144 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0339-1]}
2145 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns an empty vector.]}
2146
2147 @begin{Example}
2148 @ChgRef{Version=[2],Kind=[AddedNormal]}
2149 @ChgRef{Version=[5],Kind=[Revised]}
2150 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} To_Vector (Length : Count_Type) @key{return} Vector@Chg{Version=[5],New=[
2151 @key[with] Pre => Length <= Maximum_Length @key[or else raise] Constraint_Error,
2152 Post =>
2153 To_Vector'Result.Length = Length @key[and then]
2154 @key[not] Tampering_With_Elements_Prohibited (To_Vector'Result) @key[and then]
2155 @key[not] Tampering_With_Cursors_Prohibited (To_Vector'Result) @key[and then]
2156 To_Vector'Result.Capacity >= Length],Old=[]};]}
2157 @end{Example}
2158
2159 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2160 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a vector with a length of
2161 Length, filled with empty elements.]}
2162
2163 @begin{Example}
2164 @ChgRef{Version=[2],Kind=[AddedNormal]}
2165 @ChgRef{Version=[3],Kind=[Revised]}
2166 @ChgRef{Version=[5],Kind=[Revised]}
2167 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} To_Vector
2168 (New_Item : Element_Type;
2169 Length : Count_Type) @key{return} Vector@Chg{Version=[5],New=[
2170 @key[with] Pre => Length <= Maximum_Length @key[or else raise] Constraint_Error,
2171 Post =>
2172 To_Vector'Result.Length = Length @key[and then]
2173 @key[not] Tampering_With_Elements_Prohibited (To_Vector'Result) @key[and then]
2174 @key[not] Tampering_With_Cursors_Prohibited (To_Vector'Result) @key[and then]
2175 To_Vector'Result.Capacity >= Length],Old=[]};]}
2176 @end{Example}
2177
2178 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2179 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a vector with a length of
2180 Length, filled with elements initialized to the value New_Item.]}
2181
2182 @begin{Example}
2183 @ChgRef{Version=[2],Kind=[AddedNormal]}
2184 @ChgRef{Version=[5],Kind=[Revised]}
2185 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "&" (Left, Right : Vector) @key{return} Vector@Chg{Version=[5],New=[
2186 @key{with} Pre => Length (Left) <= Maximum_Length - Length (Right)
2187 @key[or else raise] Constraint_Error,
2188 Post => Length (Vectors."&"'Result) = Length (Left) + Length (Right) @key[and then]
2189 @key[not] Tampering_With_Elements_Prohibited (Vectors."&"'Result) @key[and then]
2190 @key[not] Tampering_With_Cursors_Prohibited (Vectors."&"'Result) @key[and then]
2191 Vectors."&"'Result.Capacity >= Length (Left) + Length (Right)],Old=[]};]}@end{Example}
2192
2193 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2194 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a vector comprising the
2195 elements of Left followed by the elements of Right.]}
2196
2197 @begin{Example}
2198 @ChgRef{Version=[2],Kind=[AddedNormal]}
2199 @ChgRef{Version=[5],Kind=[Revised]}
2200 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "&" (Left : Vector;
2201 Right : Element_Type) @key{return} Vector@Chg{Version=[5],New=[
2202 @key{with} Pre => Length (Left) <= Maximum_Length - 1
2203 @key[or else raise] Constraint_Error,
2204 Post => Vectors."&"'Result.Length = Length (Left) + 1 @key[and then]
2205 @key[not] Tampering_With_Elements_Prohibited (Vectors."&"'Result) @key[and then]
2206 @key[not] Tampering_With_Cursors_Prohibited (Vectors."&"'Result) @key[and then]
2207 Vectors."&"'Result.Capacity >= Length (Left) + 1],Old=[]};]}
2208 @end{Example}
2209
2210 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2211 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a vector comprising the
2212 elements of Left followed by the element Right.]}
2213
2214 @begin{Example}
2215 @ChgRef{Version=[2],Kind=[AddedNormal]}
2216 @ChgRef{Version=[5],Kind=[Revised]}
2217 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "&" (Left : Element_Type;
2218 Right : Vector) @key{return} Vector@Chg{Version=[5],New=[
2219 @key{with} Pre => Length (Right) <= Maximum_Length - 1
2220 @key[or else raise] Constraint_Error,
2221 Post => Length (Vectors."&"'Result) = Length (Right) + 1 @key[and then]
2222 @key[not] Tampering_With_Elements_Prohibited (Vectors."&"'Result) @key[and then]
2223 @key[not] Tampering_With_Cursors_Prohibited (Vectors."&"'Result) @key[and then]
2224 Vectors."&"'Result.Capacity >= Length (Right) + 1],Old=[]};]}@end{Example}
2225
2226 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2227 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a vector comprising the
2228 element Left followed by the elements of Right.]}
2229
2230 @begin{Example}
2231 @ChgRef{Version=[2],Kind=[AddedNormal]}
2232 @ChgRef{Version=[5],Kind=[Revised]}
2233 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "&" (Left, Right : Element_Type) @key{return} Vector@Chg{Version=[5],New=[
2234 @key{with} Pre => Maximum_Length >= 2 @key[or else raise] Constraint_Error,
2235 Post => Length ("&"'Result) = 2 @key[and then]
2236 @key[not] Tampering_With_Elements_Prohibited (Vectors."&"'Result) @key[and then]
2237 @key[not] Tampering_With_Cursors_Prohibited (Vectors."&"'Result) @key[and then]
2238 Vectors."&"'Result.Capacity >= 2],Old=[]};]}
2239 @end{Example}
2240
2241 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2242 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a vector comprising the
2243 element Left followed by the element Right.]}
2244
2245
2246 @begin{Example}
2247 @ChgRef{Version=[2],Kind=[AddedNormal]}
2248 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2249 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Capacity (Container : Vector) @key{return} Count_Type@Chg{Version=[5],New=[
2250 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
2251 @end{Example}
2252
2253 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2254 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the capacity of Container.]}
2255
2256 @begin{Example}
2257 @ChgRef{Version=[2],Kind=[AddedNormal]}
2258 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2259 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reserve_Capacity (Container : @key{in out} Vector;
2260 Capacity : @key{in} Count_Type)@Chg{Version=[5],New=[
2261 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
2262 @key[or else raise] Program_Error,
2263 Post => Container.Capacity >= Capacity],Old=[]};]}
2264 @end{Example}
2265
2266 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2267 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1],ARef=[AI05-0264-1]}
2268 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[If the
2269 capacity of Container is already greater than or equal to Capacity, then
2270 Reserve_Capacity has no effect. Otherwise, ],Old=[]}Reserve_Capacity allocates
2271 @Chg{Version=[3],New=[additional storage as necessary to
2272 ensure],Old=[new internal data structures such]} that the length of the
2273 resulting vector can become at least the value Capacity without requiring an additional call to
2274 Reserve_Capacity, and is large enough to hold the current length of Container.
2275 Reserve_Capacity then@Chg{Version=[3],New=[, as necessary, moves],Old=[ copies the]}
2276 elements into the new @Chg{Version=[3],New=[storage],Old=[data structures]} and
2277 deallocates @Chg{Version=[3],New=[any storage no longer needed],Old=[the old
2278 data structures]}. Any exception raised during allocation is
2279 propagated and Container is not modified.]}
2280
2281 @begin{Discussion}
2282
2283 @ChgRef{Version=[2],Kind=[AddedNormal]}
2284 @ChgAdded{Version=[2],Text=[Expanding the internal array can be done by
2285 allocating a new, longer array, copying the elements, and deallocating the
2286 original array. This may raise Storage_Error, or cause an exception from a
2287 controlled subprogram. We require that a failed Reserve_Capacity does not
2288 lose any elements if an exception occurs, but we do not require a specific
2289 order of evaluations or copying.]}
2290
2291 @ChgRef{Version=[2],Kind=[AddedNormal]}
2292 @ChgAdded{Version=[2],Text=[This routine is used to preallocate the internal
2293 array to the specified capacity such that future Inserts do not require
2294 memory allocation overhead. Therefore, the implementation should allocate the
2295 needed memory to make that true at this point, even though the visible
2296 semantics could be preserved by waiting until the memory is needed. This
2297 doesn't apply to the indefinite element container, because elements will have
2298 to be allocated individually.]}
2299
2300 @ChgRef{Version=[2],Kind=[AddedNormal]}
2301 @ChgAdded{Version=[2],Text=[The implementation does not have to contract the
2302 internal array if the capacity is reduced, as any capacity greater than or
2303 equal to the specified capacity is allowed.]}
2304
2305 @end{Discussion}
2306
2307 @begin{Example}
2308 @ChgRef{Version=[2],Kind=[AddedNormal]}
2309 @ChgRef{Version=[5],Kind=[Revised]}
2310 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Length (Container : Vector) @key{return} Count_Type@Chg{Version=[5],New=[
2311 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
2312 @end{Example}
2313
2314 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2315 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the number of elements in Container.]}
2316
2317 @begin{Example}
2318 @ChgRef{Version=[2],Kind=[AddedNormal]}
2319 @ChgRef{Version=[5],Kind=[Revised]}
2320 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Set_Length (Container : @key{in out} Vector;
2321 Length : @key{in} Count_Type)@Chg{Version=[5],New=[
2322 @key[with] Pre => (@key[not] Tampering_With_Cursors_Prohibited (Container)
2323 @key[or else raise] Program_Error) @key[and then]
2324 (Length <= Maximum_Length @key[or else raise] Constraint_Error),
2325 Post => Container.Length = Length @key[and then]
2326 Capacity (Container) >= Length],Old=[]};]}
2327 @end{Example}
2328
2329 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2330 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
2331 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Length is larger than the
2332 capacity of Container, Set_Length calls Reserve_Capacity (Container, Length),
2333 then sets the length of the Container to Length. If Length is greater than the
2334 original length of Container, empty elements are added to Container;
2335 otherwise@Chg{Version=[3],New=[,],Old=[]}
2336 elements are removed from Container.]}
2337
2338 @begin{Ramification}
2339 @ChgRef{Version=[2],Kind=[AddedNormal]}
2340 @ChgAdded{Version=[2],Text=[No elements are moved by this operation; any new
2341 empty elements are added at the end. This follows from the rules that a
2342 cursor continues to designate the same element unless the routine is
2343 defined to make the cursor ambiguous or invalid; this operation does not do
2344 that.]}
2345 @end{Ramification}
2346
2347 @begin{Example}
2348 @ChgRef{Version=[2],Kind=[AddedNormal]}
2349 @ChgRef{Version=[5],Kind=[Revised]}
2350 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Is_Empty (Container : Vector) @key{return} Boolean@Chg{Version=[5],New=[
2351 @key[with] Nonblocking, Global => (@key[null], @key[use null]),
2352 Post => Is_Empty'Result = (Length (Container) = 0)],Old=[]};]}
2353 @end{Example}
2354
2355 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2356 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2357 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[Returns True
2358 if Container is empty],Old=[Equivalent to Length (Container) = 0]}.]}
2359
2360 @begin{Example}
2361 @ChgRef{Version=[2],Kind=[AddedNormal]}
2362 @ChgRef{Version=[5],Kind=[Revised]}
2363 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Clear (Container : @key{in out} Vector)@Chg{Version=[5],New=[
2364 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
2365 @key[or else raise] Program_Error,
2366 Post => Length (Container) = 0],Old=[]};]}
2367 @end{Example}
2368
2369 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2370 @ChgAdded{Version=[2],Type=[Trailing],Text=[Removes all the elements from
2371 Container. The capacity of Container does not change.]}
2372
2373 @begin{Example}
2374 @ChgRef{Version=[2],Kind=[AddedNormal]}
2375 @ChgRef{Version=[5],Kind=[Revised]}
2376 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} To_Cursor (Container : Vector;
2377 Index : Extended_Index) @key{return} Cursor@Chg{Version=[5],New=[
2378 @key{with} Post => (@key{if} Index @key{in} First_Index (Container) .. Last_Index (Container)
2379 @key{then} Has_Element (Container, To_Cursor'Result)
2380 @key{else} To_Cursor'Result = No_Element),
2381 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
2382 @end{Example}
2383
2384 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2385 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1],ARef=[AI12-0196-1]}
2386 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[Returns],Old=[If
2387 Index is not in the range
2388 First_Index (Container) .. Last_Index (Container), then No_Element is returned.
2389 Otherwise,]} a cursor designating the element at position Index
2390 in Container@Chg{Version=[5],New=[; returns No_Element if Index does not
2391 designate an element],Old=[ is
2392 returned]}.@Chg{Version=[5],New=[ For the purposes of
2393 determining whether the parameters overlap in a call to To_Cursor, the
2394 Container parameter is not considered to overlap with any object
2395 @Redundant[(including itself)].],Old=[]}]}
2396
2397 @begin{Reason}
2398 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0196-1]}
2399 @ChgAdded{Version=[5],Text=[Without the preceding rule, concurrent calls to To_Cursor
2400 on the same container would interfere by the concurrent call rules in
2401 @RefSecNum{Predefined Language Environment},
2402 since the container object of the concurrent calls would overlap with itself.
2403 We want these to not interfere, for example to allow the Vector elements to
2404 be split into separate @ldquote@;chunks@rdquote for parallel processing.]}
2405 @end{Reason}
2406
2407 @begin{Example}
2408 @ChgRef{Version=[2],Kind=[AddedNormal]}
2409 @ChgRef{Version=[5],Kind=[Revised]}
2410 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} To_Index (Position : Cursor) @key{return} Extended_Index@Chg{Version=[5],New=[
2411 @key{with} Nonblocking, Global => (@key{in all}, @key{use null})],Old=[]};]}
2412 @end{Example}
2413
2414 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2415 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Position is No_Element, No_Index
2416 is returned. Otherwise, the index (within its containing vector) of the element
2417 designated by Position is returned.]}
2418
2419 @begin{Ramification}
2420 @ChgRef{Version=[2],Kind=[AddedNormal]}
2421 @ChgAdded{Version=[2],Text=[This implies that the index is determinable from
2422 a bare cursor alone. The basic model is that a vector cursor is implemented
2423 as a record containing an access to the vector container and an index value.
2424 This does constrain implementations, but it also allows all of the cursor
2425 operations to be defined in terms of the corresponding index operation (which
2426 should be primary for a vector).]}
2427 @end{Ramification}
2428
2429 @begin{Example}
2430 @ChgRef{Version=[5],Kind=[Added]}
2431 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} To_Index (Container : Vector;
2432 Position : Cursor) @key{return} Extended_Index
2433 @key{with} Pre => Position = No_Element @key{or else}
2434 Has_Element (Container, Position) @key{or else}
2435 @key{raise} Program_Error,
2436 Post => (@key{if} Position = No_Element @key{then} To_Index'Result = No_Index
2437 @key{else} To_Index'Result @key{in} First_Index (Container) ..
2438 Last_Index (Container)),
2439 Nonblocking, Global => (@key{null}, @key{use null});]}
2440 @end{Example}
2441
2442 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
2443 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns the index (within
2444 Container) of the element designated by Position; returns No_Index if Position
2445 does not designate an element. For the purposes of
2446 determining whether the parameters overlap in a call to To_Index, the
2447 Container parameter is not considered to overlap with any object
2448 @Redundant[(including itself)].]}
2449
2450 @begin{Example}
2451 @ChgRef{Version=[2],Kind=[AddedNormal]}
2452 @ChgRef{Version=[5],Kind=[Revised]}
2453 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Element (Container : Vector;
2454 Index : Index_Type)
2455 @key{return} Element_Type@Chg{Version=[5],New=[
2456 @key{with} Pre => Index @key{in} First_Index (Container) .. Last_Index (Container)
2457 @key{or else raise} Constraint_Error,
2458 Nonblocking => Element_Type'Nonblocking,
2459 Global => (@key{null}, @key{use} Element_Type)],Old=[]};]}
2460 @end{Example}
2461
2462 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2463 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2464 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
2465 Index is not in the range First_Index (Container) .. Last_Index (Container),
2466 then Constraint_Error is propagated. Otherwise, ]}Element returns the
2467 element at position Index.]}
2468
2469 @begin{Example}
2470 @ChgRef{Version=[2],Kind=[AddedNormal]}
2471 @ChgRef{Version=[5],Kind=[Revised]}
2472 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Element (Position : Cursor) @key{return} Element_Type@Chg{Version=[5],New=[
2473 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
2474 Nonblocking => Element_Type'Nonblocking,
2475 Global => (@key{in all}, @key{use} Element_Type)],Old=[]};]}
2476 @end{Example}
2477
2478 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2479 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2480 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
2481 If Position equals No_Element, then Constraint_Error is propagated.
2482 Otherwise, ]}Element returns the element
2483 designated by Position.]}
2484
2485 @begin{Example}
2486 @ChgRef{Version=[5],Kind=[Added]}
2487 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Element (Container : Vector;
2488 Position : Cursor) @key{return} Element_Type
2489 @key{with} Pre => (Position /= No_Element @key{or else}
2490 @key{raise} Constraint_Error) @key{and then}
2491 (Has_Element (Container, Position) @key{or else raise} Program_Error),
2492 Nonblocking => Element_Type'Nonblocking,
2493 Global => (@key{null}, @key{use} Element_Type);]}
2494 @end{Example}
2495
2496 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
2497 @ChgAdded{Version=[5],Type=[Trailing],Text=[Element returns the element
2498 designated by Position in Container.]}
2499
2500 @begin{Example}
2501 @ChgRef{Version=[2],Kind=[AddedNormal]}
2502 @ChgRef{Version=[5],Kind=[Revised]}
2503 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace_Element (Container : @key{in out} Vector;
2504 Index : @key{in} Index_Type;
2505 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
2506 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
2507 @key{or else raise} Program_Error) @key{and then}
2508 (Index @key{in} First_Index (Container) .. Last_Index (Container)
2509 @key{or else raise} Constraint_Error)],Old=[]};]}
2510 @end{Example}
2511
2512 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2513 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
2514 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1],ARef=[AI12-0196-1]}
2515 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
2516 Index is not in the range
2517 First_Index (Container) .. Last_Index (Container), then Constraint_Error is
2518 propagated. Otherwise@Chg{Version=[3],New=[,],Old=[]}]}
2519 Replace_Element assigns the value New_Item to the element at
2520 position Index. Any exception raised during the assignment is propagated. The
2521 element at position Index is not an empty element after successful call to
2522 Replace_Element.@Chg{Version=[5],New=[ For the purposes of
2523 determining whether the parameters overlap in a call to Replace_Element, the
2524 Container parameter is not considered to overlap with any object
2525 @Redundant[(including itself)], and the Index parameter is
2526 considered to overlap with the element at position Index.],Old=[]}]}
2527
2528 @begin{Example}
2529 @ChgRef{Version=[2],Kind=[AddedNormal]}
2530 @ChgRef{Version=[5],Kind=[Revised]}
2531 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace_Element (Container : @key{in out} Vector;
2532 Position : @key{in} Cursor;
2533 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
2534 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
2535 @key{or else raise} Program_Error) @key{and then}
2536 (Position /= No_Element
2537 @key{or else raise} Constraint_Error) @key{and then}
2538 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
2539 @end{Example}
2540
2541 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2542 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
2543 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1],ARef=[AI12-0196-1]}
2544 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
2545 Position equals No_Element,
2546 then Constraint_Error is propagated; if Position does not designate an element
2547 in Container, then Program_Error is propagated.
2548 Otherwise@Chg{Version=[3],New=[,],Old=[]} ]}Replace_Element
2549 assigns New_Item to the element designated by Position. Any exception raised
2550 during the assignment is propagated. The element at Position is not an empty
2551 element after successful call to
2552 Replace_Element.@Chg{Version=[5],New=[ For the purposes of
2553 determining whether the parameters overlap in a call to Replace_Element, the
2554 Container parameter is not considered to overlap with any object
2555 @Redundant[(including itself)].],Old=[]}]}
2556
2557 @begin{Ramification}
2558 @ChgRef{Version=[2],Kind=[AddedNormal]}
2559 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]}
2560 @ChgAdded{Version=[2],Text=[Replace_Element@Chg{Version=[3],New=[,],Old=[ and]}
2561 Update_Element@Chg{Version=[3],New=[, and Reference],Old=[]} are the only
2562 ways that an element can change from empty to nonempty. Also see the note
2563 following Update_Element.]}
2564 @end{Ramification}
2565
2566 @begin{Example}
2567 @ChgRef{Version=[2],Kind=[AddedNormal]}
2568 @ChgRef{Version=[5],Kind=[Revised]}
2569 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Query_Element
2570 (Container : @key{in} Vector;
2571 Index : @key{in} Index_Type;
2572 Process : @key{not null access procedure} (Element : @key{in} Element_Type))@Chg{Version=[5],New=[
2573 @key{with} Pre => Index @key{in} First_Index (Container) .. Last_Index (Container)
2574 @key{or else raise} Constraint_Error],Old=[]};]}
2575 @end{Example}
2576
2577 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2578 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]}
2579 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2580 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
2581 Index is not in the range
2582 First_Index (Container) .. Last_Index (Container), then Constraint_Error is
2583 propagated. Otherwise, ]}Query_Element calls Process.@key{all} with the element at
2584 position Index as the argument.
2585 @Chg{Version=[3],New=[Tampering],Old=[Program_Error
2586 is propagated if Process.@key{all} tampers]}
2587 with the elements of Container@Chg{Version=[3],New=[ is prohibited during the
2588 execution of the call on Process.@key{all}],Old=[]}. Any exception raised by
2589 Process.@key{all} is propagated.]}
2590
2591 @begin{Reason}
2592 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI05-0005-1]}
2593 @ChgAdded{Version=[2],Text=[The @lquotes@;tamper with the elements@rquotes@;
2594 check is intended to prevent the Element parameter of Process from being
2595 @Chg{Version=[3],New=[replaced],Old=[modified]} or deleted
2596 outside of Process. The check prevents data loss (if Element_Type is passed by
2597 copy) or erroneous execution (if Element_Type is an unconstrained type in an
2598 indefinite container).]}
2599 @end{Reason}
2600
2601 @begin{Example}
2602 @ChgRef{Version=[2],Kind=[AddedNormal]}
2603 @ChgRef{Version=[5],Kind=[Revised]}
2604 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Query_Element
2605 (Position : @key{in} Cursor;
2606 Process : @key{not null access procedure} (Element : @key{in} Element_Type))@Chg{Version=[5],New=[
2607 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error],Old=[]};]}
2608 Global => @key{in all};]}
2609 @end{Example}
2610
2611 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2612 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1],ARef=[AI05-0265-1]}
2613 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2614 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
2615 Position equals No_Element, then
2616 Constraint_Error is propagated. Otherwise, ]}Query_Element calls
2617 Process.@key{all} with the element designated by Position as the argument.
2618 @Chg{Version=[3],New=[Tampering],Old=[Program_Error
2619 is propagated if Process.@key{all} tampers]}
2620 with the elements of @Chg{Version=[3],New=[the vector that contains the
2621 element designated by Position is prohibited during the
2622 execution of the call on Process.@key{all}],Old=[Container]}. Any
2623 exception raised by Process.@key{all} is propagated.]}
2624
2625 @begin{Example}
2626 @ChgRef{Version=[5],Kind=[Added]}
2627 @ChgAdded{Version=[5],Text=[@key{procedure} Query_Element
2628 (Container : @key{in} Vector;
2629 Position : @key{in} Cursor;
2630 Process : @key{not null access procedure} (Element : @key{in} Element_Type))
2631 @key{with} Pre => (Position /= No_Element
2632 @key{or else raise} Constraint_Error) @key{and then}
2633 (Has_Element (Container, Position)
2634 @key{or else raise} Program_Error);]}
2635 @end{Example}
2636
2637 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
2638 @ChgAdded{Version=[5],Type=[Trailing],Text=[Query_Element calls Process.@key{all}
2639 with the element designated by Position as the
2640 argument. Tampering with the elements of Container
2641 is prohibited during the execution of the call on
2642 Process.@key{all}. Any exception raised by Process.@key{all} is propagated.]}
2643
2644 @begin{Example}
2645 @ChgRef{Version=[2],Kind=[AddedNormal]}
2646 @ChgRef{Version=[5],Kind=[Revised]}
2647 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Update_Element
2648 (Container : @key{in out} Vector;
2649 Index : @key{in} Index_Type;
2650 Process : @key{not null access procedure}
2651 (Element : @key{in out} Element_Type))@Chg{Version=[5],New=[
2652 @key{with} Pre => Index @key{in} First_Index (Container) .. Last_Index (Container)
2653 @key{or else raise} Constraint_Error],Old=[]};]}
2654 @end{Example}
2655
2656 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2657 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]}
2658 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2659 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
2660 Index is not in the range
2661 First_Index (Container) .. Last_Index (Container), then Constraint_Error is
2662 propagated. Otherwise, ]}Update_Element calls Process.@key{all} with the element
2663 at position Index as the argument.
2664 @Chg{Version=[3],New=[Tampering],Old=[Program_Error
2665 is propagated if Process.@key{all} tampers]}
2666 with the elements of Container@Chg{Version=[3],New=[ is prohibited during the
2667 execution of the call on Process.@key{all}],Old=[]}. Any exception raised by
2668 Process.@key{all} is propagated.]}
2669
2670 @ChgRef{Version=[2],Kind=[AddedNormal]}
2671 @ChgAdded{Version=[2],Text=[If Element_Type is unconstrained and definite, then
2672 the actual Element parameter of Process.@key{all} shall be unconstrained.]}
2673
2674 @begin{Ramification}
2675 @ChgRef{Version=[2],Kind=[AddedNormal]}
2676 @ChgAdded{Version=[2],Text=[This means that the elements cannot be directly
2677 allocated from the heap; it must be possible to change the discriminants of
2678 the element in place.]}
2679 @end{Ramification}
2680
2681 @ChgRef{Version=[2],Kind=[AddedNormal]}
2682 @ChgAdded{Version=[2],Type=[Trailing],Text=[The element at position Index is
2683 not an empty element after successful completion of this operation.]}
2684
2685 @begin{Ramification}
2686 @ChgRef{Version=[2],Kind=[AddedNormal]}
2687 @ChgAdded{Version=[2],Text=[Since reading an empty element is a bounded
2688 error, attempting to use this procedure to replace empty elements may fail.
2689 Use Replace_Element to do that reliably.]}
2690 @end{Ramification}
2691
2692 @begin{Example}
2693 @ChgRef{Version=[2],Kind=[AddedNormal]}
2694 @ChgRef{Version=[5],Kind=[Revised]}
2695 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Update_Element
2696 (Container : @key{in out} Vector;
2697 Position : @key{in} Cursor;
2698 Process : @key{not null access procedure}
2699 (Element : @key{in out} Element_Type))@Chg{Version=[5],New=[
2700 @key{with} Pre => (Position /= No_Element @key{or else raise} Constraint_Error) @key{and then}
2701 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
2702 @end{Example}
2703
2704 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2705 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1],ARef=[AI05-0265-1]}
2706 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2707 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
2708 Position equals No_Element, then
2709 Constraint_Error is propagated; if Position does not designate an element in
2710 Container, then Program_Error is propagated.
2711 Otherwise@Chg{Version=[3],New=[,],Old=[]} ]}Update_Element calls
2712 Process.@key{all} with the element designated by Position as the argument.
2713 @Chg{Version=[3],New=[Tampering],Old=[Program_Error
2714 is propagated if Process.@key{all} tampers]}
2715 with the elements of Container@Chg{Version=[3],New=[ is prohibited during the
2716 execution of the call on Process.@key{all}],Old=[]}. Any exception raised by
2717 Process.@key{all} is propagated.]}
2718
2719 @ChgRef{Version=[2],Kind=[AddedNormal]}
2720 @ChgAdded{Version=[2],Text=[If Element_Type is unconstrained and definite, then
2721 the actual Element parameter of Process.@key{all} shall be unconstrained.]}
2722
2723 @ChgRef{Version=[2],Kind=[AddedNormal]}
2724 @ChgAdded{Version=[2],Type=[Trailing],Text=[The element designated by Position
2725 is not an empty element after successful completion of this operation.]}
2726
2727 @begin{Example}
2728 @ChgRef{Version=[3],Kind=[Added]}
2729 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2730 @ChgAdded{Version=[3],Text=[@key[type] Constant_Reference_Type
2731 (Element : @key[not null access constant] Element_Type) @key[is private]
2732 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
2733 Nonblocking, Global => @key[in out synchronized],
2734 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
2735
2736 @ChgRef{Version=[3],Kind=[Added]}
2737 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2738 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[type] Reference_Type (Element : @key[not null access] Element_Type) @key[is private]
2739 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
2740 Nonblocking, Global => @key[in out synchronized],
2741 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
2742 @end{Example}
2743
2744 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
2745 @ChgAdded{Version=[3],Type=[Trailing],Text=[The types Constant_Reference_Type
2746 and Reference_Type need finalization.@PDefn2{Term=<needs finalization>,
2747 Sec=<language-defined type>}]}
2748
2749 @ChgRef{Version=[3],Kind=[Added]}
2750 @ChgRef{Version=[5],Kind=[DeletedAdded],ARef=[AI12-0112-1]}
2751 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[The default
2752 initialization of an object of type Constant_Reference_Type or Reference_Type
2753 propagates Program_Error.]}]}
2754
2755 @begin{Reason}
2756 @ChgRef{Version=[3],Kind=[AddedNormal]}
2757 @ChgAdded{Version=[3],Text=[It is expected that Reference_Type (and
2758 Constant_Reference_Type) will be a controlled type, for which finalization
2759 will have some action to terminate the tampering check for the associated
2760 container. If the object is created by default, however, there is no
2761 associated container. Since this is useless, and supporting this case would
2762 take extra work, we define it to raise an exception.]}
2763 @end{Reason}
2764
2765 @begin{Example}
2766 @ChgRef{Version=[3],Kind=[Added]}
2767 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2768 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] Vector;
2769 Index : @key[in] Index_Type)
2770 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
2771 @key[with] Pre => Index @key[in] First_Index (Container) .. Last_Index (Container)
2772 @key[or else raise] Constraint_Error,
2773 Post => Tampering_With_Cursors_Prohibited (Container),
2774 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
2775 @end{Example}
2776
2777 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
2778 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
2779 Constant_Indexing and Implicit_Dereference aspects) provides a convenient way to
2780 gain read access to an individual element of a vector given an
2781 index value.]}
2782
2783 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]}
2784 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2785 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[If
2786 Index is not in the range First_Index (Container) .. Last_Index (Container),
2787 then Constraint_Error is propagated. Otherwise, ]}Constant_Reference returns an
2788 object whose discriminant is an access value that designates the element at
2789 position Index. Tampering with the elements of Container is prohibited while the
2790 object returned by Constant_Reference exists and has not been finalized.]}
2791
2792 @begin{Example}
2793 @ChgRef{Version=[3],Kind=[Added]}
2794 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2795 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference (Container : @key[aliased in out] Vector;
2796 Index : @key[in] Index_Type)
2797 @key[return] Reference_Type@Chg{Version=[5],New=[
2798 @key[with] Pre => Index @key[in] First_Index (Container) .. Last_Index (Container)
2799 @key[or else raise] Constraint_Error,
2800 Post => Tampering_With_Cursors_Prohibited (Container),
2801 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
2802 @end{Example}
2803
2804 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
2805 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
2806 Variable_Indexing and Implicit_Dereference aspects) provides a convenient way to
2807 gain read and write access to an individual element of a vector given
2808 an index value.]}
2809
2810 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]}
2811 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2812 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[If
2813 Index is not in the range First_Index (Container) .. Last_Index (Container),
2814 then Constraint_Error is propagated. Otherwise, ]}Reference returns an object
2815 whose discriminant is an access value that designates the element at position
2816 Index. Tampering with the elements of Container is prohibited while the object
2817 returned by Reference exists and has not been finalized.]}
2818
2819 @ChgRef{Version=[3],Kind=[Added]}
2820 @ChgAdded{Version=[3],Text=[The element at position Index is not an empty
2821 element after successful completion of this operation.]}
2822
2823 @begin{Example}
2824 @ChgRef{Version=[3],Kind=[Added]}
2825 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2826 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] Vector;
2827 Position : @key[in] Cursor)
2828 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
2829 @key[with] Pre => (Position /= No_Element @key[or else]
2830 @key[raise] Constraint_Error) @key[and then]
2831 (Has_Element (Container, Position) @key[or else raise] Program_Error),
2832 Post => Tampering_With_Cursors_Prohibited (Container),
2833 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
2834 @end{Example}
2835
2836 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
2837 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
2838 Constant_Indexing and Implicit_Dereference aspects) provides a convenient way to
2839 gain read access to an individual element of a vector given a cursor.]}
2840
2841 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]}
2842 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2843 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[If
2844 Position equals No_Element, then Constraint_Error
2845 is propagated; if Position does not designate an element in Container, then
2846 Program_Error is propagated. Otherwise, ]}Constant_Reference returns an object
2847 whose discriminant is an access value that designates the element designated by
2848 Position. Tampering with the elements of Container is prohibited while the
2849 object returned by Constant_Reference exists and has not been finalized.]}
2850
2851 @begin{Example}
2852 @ChgRef{Version=[3],Kind=[Added]}
2853 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2854 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference (Container : @key[aliased in out] Vector;
2855 Position : @key[in] Cursor)
2856 @key[return] Reference_Type@Chg{Version=[5],New=[
2857 @key[with] Pre => (Position /= No_Element @key[or else]
2858 @key[raise] Constraint_Error) @key[and then]
2859 (Has_Element (Container, Position) @key[or else raise] Program_Error),
2860 Post => Tampering_With_Cursors_Prohibited (Container),
2861 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
2862 @end{Example}
2863
2864 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
2865 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
2866 Variable_Indexing and Implicit_Dereference aspects) provides a convenient way to
2867 gain read and write access to an individual element of a vector given
2868 a cursor.]}
2869
2870 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]}
2871 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2872 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[If
2873 Position equals No_Element, then Constraint_Error
2874 is propagated; if Position does not designate an element in Container, then
2875 Program_Error is propagated. Otherwise, ]}Reference returns an object whose
2876 discriminant is an access value that designates the element designated by
2877 Position. Tampering with the elements of Container is prohibited while the
2878 object returned by Reference exists and has not been finalized.]}
2879
2880 @ChgRef{Version=[3],Kind=[Added]}
2881 @ChgAdded{Version=[3],Text=[The element designated by Position is not an empty
2882 element after successful completion of this operation.]}
2883
2884 @begin{Example}
2885 @ChgRef{Version=[3],Kind=[Added]}
2886 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key{procedure} Assign (Target : @key{in out} Vector; Source : @key{in} Vector)@Chg{Version=[5],New=[
2887 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Target)
2888 @key[or else raise] Program_Error,
2889 Post => Length (Source) = Length (Target) @key{and then}
2890 Capacity (Target) >= Length (Target)],Old=[]};]}
2891 @end{Example}
2892
2893 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0262-1]}
2894 @ChgAdded{Version=[3],Type=[Trailing],Text=[If Target denotes the same object as
2895 Source, the operation has no effect. If the length of Source is greater than the
2896 capacity of Target, Reserve_Capacity (Target, Length (Source)) is called.
2897 The elements of Source are then copied to Target as for an
2898 @nt{assignment_statement} assigning Source to Target (this includes
2899 setting the length of Target to be that of Source).]}
2900 @begin{Discussion}
2901 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1]}
2902 @ChgAdded{Version=[3],Text=[This routine exists for compatibility with the
2903 bounded vector container. For an unbounded vector, @exam{Assign(A, B)} and
2904 @exam{A := B} behave identically. For a bounded vector, := will raise an
2905 exception if the container capacities are different, while Assign will
2906 not raise an exception if there is enough room in the target.]}
2907 @end{Discussion}
2908
2909 @begin{Example}
2910 @ChgRef{Version=[3],Kind=[Added]}
2911 @ChgRef{Version=[5],Kind=[RevisedAdded]}
2912 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key{function} Copy (Source : Vector; Capacity : Count_Type := 0)
2913 @key[return] Vector@Chg{Version=[5],New=[
2914 @key[with] Pre => Capacity = 0 @key[or else] Capacity >= Length (Source)
2915 @key[or else raise] Capacity_Error,
2916 Post => Length (Copy'Result) = Length (Source) @key[and then]
2917 @key[not] Tampering_With_Elements_Prohibited (Copy'Result) @key[and then]
2918 @key[not] Tampering_With_Cursors_Prohibited (Copy'Result) @key[and then]
2919 Copy'Result.Capacity >= (@key[if] Capacity = 0 @key[then]
2920 Length (Source) @key[else] Capacity)],Old=[]};]}
2921 @end{Example}
2922
2923 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
2924 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2925 @ChgAdded{Version=[3],Type=[Trailing],Text=[Returns a vector whose elements are
2926 initialized from the corresponding elements of Source.@Chg{Version=[5],New=[],Old=[ If
2927 Capacity is 0, then the vector capacity is the length of Source; if Capacity is
2928 equal to or greater than the length of Source, the vector capacity is at least
2929 the specified value. Otherwise, the operation propagates Capacity_Error.]}]}
2930
2931
2932 @begin{Example}
2933 @ChgRef{Version=[2],Kind=[AddedNormal]}
2934 @ChgRef{Version=[5],Kind=[Revised]}
2935 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Move (Target : @key{in out} Vector;
2936 Source : @key{in out} Vector)@Chg{Version=[5],New=[
2937 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
2938 @key{or else raise} Program_Error) @key{and then}
2939 (@key{not} Tampering_With_Cursors_Prohibited (Source)
2940 @key{or else raise} Program_Error),
2941 Post => (@key{if} Target = Source @key{then} True
2942 @key{else}
2943 Length (Target) = Length (Source'Old) @key{and then}
2944 Length (Source) = 0 @key{and then}
2945 Capacity (Target) >= Length (Source'Old))],Old=[]};]}
2946 @end{Example}
2947
2948 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2949 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1],ARef=[AI05-0248-1]}
2950 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2951 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Target denotes the same object
2952 as Source, then @Chg{Version=[3],New=[the operation],Old=[Move]}
2953 has no effect. Otherwise, Move first calls
2954 @Chg{Version=[3],New=[Reserve_Capacity (Target, Length (Source))
2955 and then ],Old=[]}Clear (Target);
2956 then, each element from Source is removed from Source and inserted into Target
2957 in the original order.@Chg{Version=[5],New=[],Old=[ The length of Source is
2958 0 after a successful call to Move.]}]}
2959
2960 @begin{Discussion}
2961 @ChgRef{Version=[2],Kind=[AddedNormal]}
2962 @ChgAdded{Version=[2],Text=[The idea is that the internal array is removed
2963 from Source and moved to Target. (See the @ImplAdviceName for Move). If
2964 Capacity (Target) /= 0, the previous internal array may need to be
2965 deallocated. We don't mention this explicitly, because it is covered by the
2966 "no memory loss" @ImplReqName@;.]}
2967 @end{Discussion}
2968
2969 @begin{Example}
2970 @ChgRef{Version=[2],Kind=[AddedNormal]}
2971 @ChgRef{Version=[5],Kind=[Revised]}
2972 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector;
2973 Before : @key{in} Extended_Index;
2974 New_Item : @key{in} Vector)@Chg{Version=[5],New=[
2975 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
2976 @key{or else raise} Program_Error) @key{and then}
2977 (Before @key{in} First_Index (Container) .. Last_Index (Container) + 1
2978 @key{then raise} Constraint_Error) @key{and then}
2979 (Length (Container) <= Maximum_Length - Length (New_Item)
2980 @key{or else raise} Constraint_Error),
2981 Post => Length (Container)'Old + Length (New_Item) = Length (Container) @key{and then}
2982 Capacity (Container) >= Length (Container)],Old=[]};]}
2983 @end{Example}
2984
2985 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2986 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
2987 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2988 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[If
2989 Before is not in the range First_Index (Container) .. Last_Index (Container) +
2990 1, then Constraint_Error is propagated. ]}If Length(New_Item) is 0, then Insert
2991 does nothing. Otherwise, it computes the new length @i<NL> as the sum of the
2992 current length and Length (New_Item); if the value of Last appropriate for
2993 length @i<NL> would be greater than
2994 Index_Type'Last@Chg{Version=[3],New=[,],Old=[]} then Constraint_Error is
2995 propagated.]}
2996
2997 @ChgRef{Version=[2],Kind=[AddedNormal]}
2998 @ChgAdded{Version=[2],Type=[Trailing],Text=[If the current vector capacity is
2999 less than @i<NL>, Reserve_Capacity (Container, @i<NL>) is called to
3000 increase the vector capacity. Then Insert slides the elements in the range
3001 Before .. Last_Index (Container) up by Length(New_Item) positions, and then
3002 copies the elements of New_Item to the positions starting at Before. Any
3003 exception raised during the copying is propagated.]}
3004
3005 @begin{Ramification}
3006 @ChgRef{Version=[2],Kind=[AddedNormal]}
3007 @ChgAdded{Version=[2],Text=[Moving the elements does not necessarily involve
3008 copying. Similarly, since Reserve_Capacity does not require the copying of
3009 elements, it does not need to be explicitly called (the implementation can
3010 combine the operations if it wishes to).]}
3011 @end{Ramification}
3012
3013 @begin{Example}
3014 @ChgRef{Version=[2],Kind=[AddedNormal]}
3015 @ChgRef{Version=[5],Kind=[Revised]}
3016 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector;
3017 Before : @key{in} Cursor;
3018 New_Item : @key{in} Vector)@Chg{Version=[5],New=[
3019 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3020 @key{or else raise} Program_Error) @key{and then}
3021 (Before = No_Element @key{or else}
3022 Has_Element (Container, Before)
3023 @key{or else raise} Program_Error) @key{and then}
3024 (Length (Container) <= Maximum_Length - Length (New_Item)
3025 @key{or else raise} Constraint_Error),
3026 Post => Length (Container)'Old + Length (New_Item) = Length (Container) @key{and then}
3027 Capacity (Container) >= Length (Container)],Old=[]};]}
3028 @end{Example}
3029
3030 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3031 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
3032 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3033 @ChgAdded{Version=[2],Type=[Trailing],Text=[If @Chg{Version=[5],New=[],Old=[Before
3034 is not No_Element, and
3035 does not designate an element in Container, then Program_Error is propagated.
3036 Otherwise, if]}
3037 Length(New_Item) is 0, then Insert does nothing. If Before is No_Element, then
3038 the call is equivalent to Insert (Container, Last_Index (Container) + 1,
3039 New_Item); otherwise@Chg{Version=[3],New=[,],Old=[]}
3040 the call is equivalent to Insert (Container, To_Index
3041 (Before), New_Item);]}
3042
3043 @begin{Ramification}
3044 @ChgRef{Version=[2],Kind=[AddedNormal]}
3045 @ChgAdded{Version=[2],Text=[The check on Before checks that the cursor does
3046 not belong to some other Container. This check implies that a reference to
3047 the container is included in the cursor value. This wording is not meant to
3048 require detection of dangling cursors; such cursors are defined to be
3049 invalid, which means that execution is erroneous, and any result is allowed
3050 (including not raising an exception).]}
3051 @end{Ramification}
3052
3053 @begin{Example}
3054 @ChgRef{Version=[2],Kind=[AddedNormal]}
3055 @ChgRef{Version=[5],Kind=[Revised]}
3056 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector;
3057 Before : @key{in} Cursor;
3058 New_Item : @key{in} Vector;
3059 Position : @key{out} Cursor)@Chg{Version=[5],New=[
3060 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3061 @key{or else raise} Program_Error) @key{and then}
3062 (Before = No_Element @key{or else}
3063 Has_Element (Container, Before)
3064 @key{or else raise} Program_Error) @key{and then}
3065 (Length (Container) <= Maximum_Length - Length (New_Item)
3066 @key{or else raise} Constraint_Error),
3067 Post => Length (Container)'Old + Length (New_Item) = Length (Container) @key{and then}
3068 Has_Element (Container, Position) @key{and then}
3069 Capacity (Container) >= Length (Container)],Old=[]};]}
3070 @end{Example}
3071
3072 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3073 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3074 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
3075 Before is not No_Element, and
3076 does not designate an element in Container, then Program_Error is propagated.
3077 ]}If Before
3078 equals No_Element, then let @i<T> be Last_Index (Container) + 1; otherwise, let
3079 @i<T> be To_Index (Before). Insert (Container, @i<T>, New_Item) is called, and
3080 then Position is set to To_Cursor (Container, @i<T>).]}
3081
3082 @begin{Discussion}
3083 @ChgRef{Version=[2],Kind=[AddedNormal]}
3084 @ChgAdded{Version=[2],Text=[The messy wording is needed because Before is
3085 invalidated by Insert, and we don't want Position to be invalid after this
3086 call. An implementation probably only needs to copy Before to Position.]}
3087 @end{Discussion}
3088
3089 @begin{Example}
3090 @ChgRef{Version=[2],Kind=[AddedNormal]}
3091 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3092 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector;
3093 Before : @key{in} Extended_Index;
3094 New_Item : @key{in} Element_Type;
3095 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
3096 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3097 @key{or else raise} Program_Error) @key{and then}
3098 (Before @key{in} First_Index (Container) .. Last_Index (Container) + 1
3099 @key{or else raise} Constraint_Error) @key{and then}
3100 (Length (Container) <= Maximum_Length - Count
3101 @key{or else raise} Constraint_Error),
3102 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
3103 Capacity (Container) >= Length (Container)],Old=[]};]}
3104 @end{Example}
3105
3106 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3107 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, Before, To_Vector (New_Item, Count));]}
3108
3109 @begin{Example}
3110 @ChgRef{Version=[2],Kind=[AddedNormal]}
3111 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3112 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector;
3113 Before : @key{in} Cursor;
3114 New_Item : @key{in} Element_Type;
3115 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
3116 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3117 @key{or else raise} Program_Error) @key{and then}
3118 (Before = No_Element @key{or else}
3119 Has_Element (Container, Before)
3120 @key{or else raise} Program_Error) @key{and then}
3121 (Length (Container) <= Maximum_Length - Count
3122 @key{or else raise} Constraint_Error),
3123 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
3124 Capacity (Container) >= Length (Container)],Old=[]};]}
3125 @end{Example}
3126
3127 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3128 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, Before, To_Vector (New_Item, Count));]}
3129
3130 @begin{Example}
3131 @ChgRef{Version=[2],Kind=[AddedNormal]}
3132 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3133 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector;
3134 Before : @key{in} Cursor;
3135 New_Item : @key{in} Element_Type;
3136 Position : @key{out} Cursor;
3137 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
3138 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3139 @key{or else raise} Program_Error) @key{and then}
3140 (Before = No_Element @key{or else}
3141 Has_Element (Container, Before)
3142 @key{or else raise} Program_Error) @key{and then}
3143 (Length (Container) <= Maximum_Length - Count
3144 @key{or else raise} Constraint_Error),
3145 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
3146 Has_Element (Container, Position) @key{and then}
3147 Capacity (Container) >= Length (Container)],Old=[]};]}
3148 @end{Example}
3149
3150 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3151 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, Before, To_Vector (New_Item, Count), Position);]}
3152
3153 @begin{Ramification}
3154 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0257-1]}
3155 @ChgAdded{Version=[3],Text=[If Count equals 0, Position will designate the
3156 element designated by Before, rather than a newly inserted element. Otherwise,
3157 Position will designate the first newly inserted element.]}
3158 @end{Ramification}
3159
3160 @begin{Example}
3161 @ChgRef{Version=[2],Kind=[AddedNormal]}
3162 @ChgRef{Version=[5],Kind=[Revised]}
3163 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector;
3164 Before : @key{in} Extended_Index;
3165 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
3166 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3167 @key{or else raise} Program_Error) @key{and then}
3168 (Before @key{in} First_Index (Container) .. Last_Index (Container) + 1
3169 @key{or else raise} Constraint_Error) @key{and then}
3170 (Length (Container) <= Maximum_Length - Count
3171 @key{or else raise} Constraint_Error),
3172 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
3173 Capacity (Container) >= Length (Container)],Old=[]};]}
3174 @end{Example}
3175
3176 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3177 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
3178 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3179 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[If
3180 Before is not in the range
3181 First_Index (Container) .. Last_Index (Container) + 1, then Constraint_Error is
3182 propagated. ]}If Count is 0, then Insert does nothing. Otherwise, it
3183 computes the new length @i<NL> as the sum of the current length and Count; if
3184 the value of Last appropriate for length @i<NL> would be greater than
3185 Index_Type'Last@Chg{Version=[3],New=[,],Old=[]} then
3186 Constraint_Error is propagated.]}
3187
3188 @ChgRef{Version=[2],Kind=[AddedNormal]}
3189 @ChgAdded{Version=[2],Type=[Trailing],Text=[If the current vector capacity is
3190 less than @i<NL>, Reserve_Capacity (Container, @i<NL>) is called to
3191 increase the vector capacity. Then Insert slides the elements in the
3192 range Before .. Last_Index (Container) up by Count positions, and then inserts
3193 elements that are initialized by default (see @RefSecNum{Object Declarations})
3194 in the positions starting at Before.]}
3195
3196 @begin{Example}
3197 @ChgRef{Version=[2],Kind=[AddedNormal]}
3198 @ChgRef{Version=[5],Kind=[Revised]}
3199 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector;
3200 Before : @key{in} Cursor;
3201 New_Item : @key{in} Element_Type;
3202 Position : @key{out} Cursor;
3203 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
3204 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3205 @key{or else raise} Program_Error) @key{and then}
3206 (Before = No_Element @key{or else}
3207 Has_Element (Container, Before)
3208 @key{or else raise} Program_Error) @key{and then}
3209 (Length (Container) <= Maximum_Length - Count
3210 @key{or else raise} Constraint_Error),
3211 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
3212 Has_Element (Container, Position) @key{and then}
3213 Capacity (Container) >= Length (Container)],Old=[]};]}
3214 @end{Example}
3215
3216 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3217 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3218 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
3219 Before is not No_Element, and
3220 does not designate an element in Container, then Program_Error is propagated.
3221 ]}If Before
3222 equals No_Element, then let @i<T> be Last_Index (Container) + 1; otherwise, let
3223 @i<T> be To_Index (Before). Insert (Container, @i<T>, Count) is called,
3224 and then Position is set to To_Cursor (Container, @i<T>).]}
3225
3226 @begin{Reason}
3227 @ChgRef{Version=[2],Kind=[AddedNormal]}
3228 @ChgAdded{Version=[2],Text=[This routine exists mainly to ease conversion
3229 between Vector and List containers. Unlike Insert_Space, this routine
3230 default initializes the elements it inserts, which can be more expensive
3231 for some element types.]}
3232 @end{Reason}
3233
3234 @begin{Example}
3235 @ChgRef{Version=[2],Kind=[AddedNormal]}
3236 @ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0080-1]}
3237 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3238 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Prepend (Container : @key{in out} Vector;
3239 New_Item : @key{in} Vector@Chg{Version=[4],New=[],Old=[;
3240 Count : @key{in} Count_Type := 1]})@Chg{Version=[5],New=[
3241 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3242 @key{or else raise} Program_Error) @key{and then}
3243 (Length (Container) <= Maximum_Length - Length (New_Item)
3244 @key{or else raise} Constraint_Error),
3245 Post => Length (Container)'Old + Length (New_Item) = Length (Container) @key{and then}
3246 Capacity (Container) >= Length (Container)],Old=[]};]}
3247 @end{Example}
3248
3249 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3250 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, First_Index (Container), New_Item).]}
3251
3252 @begin{Example}
3253 @ChgRef{Version=[2],Kind=[AddedNormal]}
3254 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3255 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Prepend (Container : @key{in out} Vector;
3256 New_Item : @key{in} Element_Type;
3257 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
3258 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3259 @key{or else raise} Program_Error) @key{and then}
3260 (Length (Container) <= Maximum_Length - Count
3261 @key{or else raise} Constraint_Error),
3262 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
3263 Capacity (Container) >= Length (Container)],Old=[]};]}
3264 @end{Example}
3265
3266 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3267 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, First_Index (Container), New_Item, Count).]}
3268
3269 @begin{Example}
3270 @ChgRef{Version=[2],Kind=[AddedNormal]}
3271 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3272 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Append (Container : @key{in out} Vector;
3273 New_Item : @key{in} Vector)@Chg{Version=[5],New=[
3274 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3275 @key{or else raise} Program_Error) @key{and then}
3276 (Length (Container) <= Maximum_Length - Length (New_Item)
3277 @key{or else raise} Constraint_Error),
3278 Post => Length (Container)'Old + Length (New_Item) = Length (Container) @key{and then}
3279 Capacity (Container) >= Length (Container)],Old=[]};]}
3280 @end{Example}
3281
3282 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3283 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, Last_Index (Container) + 1, New_Item).]}
3284
3285 @begin{Example}
3286 @ChgRef{Version=[2],Kind=[AddedNormal]}
3287 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3288 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Append (Container : @key{in out} Vector;
3289 New_Item : @key{in} Element_Type;
3290 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
3291 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3292 @key{or else raise} Program_Error) @key{and then}
3293 (Length (Container) <= Maximum_Length - Count
3294 @key{or else raise} Constraint_Error),
3295 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
3296 Capacity (Container) >= Length (Container)],Old=[]};]}
3297 @end{Example}
3298
3299 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3300 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, Last_Index (Container) + 1, New_Item, Count).]}
3301
3302
3303 @begin{Example}
3304 @ChgRef{Version=[5],Kind=[Added]}
3305 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{procedure} Append_One (Container : @key{in out} Vector;
3306 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
3307 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3308 @key{or else raise} Program_Error) @key{and then}
3309 (Length (Container) <= Maximum_Length - 1
3310 @key{or else raise} Constraint_Error),
3311 Post => Length (Container)'Old + 1 = Length (Container) @key{and then}
3312 Capacity (Container) >= Length (Container)],Old=[]};]}
3313 @end{Example}
3314
3315 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1],ARef=[AI12-0212-1]}
3316 @ChgAdded{Version=[5],Type=[Trailing],Text=[Equivalent to Insert (Container, Last_Index (Container) + 1, New_Item, 1).]}
3317
3318 @begin{Example}
3319 @ChgRef{Version=[2],Kind=[AddedNormal]}
3320 @ChgRef{Version=[5],Kind=[Revised]}
3321 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert_Space (Container : @key{in out} Vector;
3322 Before : @key{in} Extended_Index;
3323 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
3324 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3325 @key{or else raise} Program_Error) @key{and then}
3326 (Before @key{in} First_Index (Container) .. Last_Index (Container) + 1
3327 @key{or else raise} Constraint_Error) @key{and then}
3328 (Length (Container) <= Maximum_Length - Count
3329 @key{or else raise} Constraint_Error),
3330 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
3331 Capacity (Container) >= Length (Container)],Old=[]};]}
3332 @end{Example}
3333
3334 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3335 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
3336 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3337 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[If
3338 Before is not in the range
3339 First_Index (Container) .. Last_Index (Container) + 1, then Constraint_Error is
3340 propagated. ]}If Count is 0, then Insert_Space does nothing. Otherwise, it
3341 computes the new length @i<NL> as the sum of the current length and Count; if
3342 the value of Last appropriate for length @i<NL> would be greater than
3343 Index_Type'Last@Chg{Version=[3],New=[,],Old=[]} then
3344 Constraint_Error is propagated.]}
3345
3346 @ChgRef{Version=[2],Kind=[AddedNormal]}
3347 @ChgAdded{Version=[2],Type=[Trailing],Text=[If the current vector capacity is
3348 less than @i<NL>, Reserve_Capacity (Container, @i<NL>) is called to
3349 increase the vector capacity. Then Insert_Space slides the elements in the
3350 range Before .. Last_Index (Container) up by Count positions, and then inserts
3351 empty elements in the positions starting at Before.]}
3352
3353 @begin{Example}
3354 @ChgRef{Version=[2],Kind=[AddedNormal]}
3355 @ChgRef{Version=[5],Kind=[Revised]}
3356 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert_Space (Container : @key{in out} Vector;
3357 Before : @key{in} Cursor;
3358 Position : @key{out} Cursor;
3359 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
3360 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3361 @key{or else raise} Program_Error) @key{and then}
3362 (Before = No_Element @key{or else}
3363 Has_Element (Container, Before)
3364 @key{or else raise} Program_Error) @key{and then}
3365 (Length (Container) <= Maximum_Length - Count
3366 @key{or else raise} Constraint_Error),
3367 Post => Length (Container)'Old + Count = Length (Container) @key{and then}
3368 Has_Element (Container, Position) @key{and then}
3369 Capacity (Container) >= Length (Container)],Old=[]};]}
3370 @end{Example}
3371
3372 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3373 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3374 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
3375 Before is not No_Element, and
3376 does not designate an element in Container, then Program_Error is propagated.
3377 ]}If Before
3378 equals No_Element, then let @i<T> be Last_Index (Container) + 1; otherwise, let
3379 @i<T> be To_Index (Before). Insert_Space (Container, @i<T>, Count) is called,
3380 and then Position is set to To_Cursor (Container, @i<T>).]}
3381
3382 @begin{Example}
3383 @ChgRef{Version=[2],Kind=[AddedNormal]}
3384 @ChgRef{Version=[5],Kind=[Revised]}
3385 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Vector;
3386 Index : @key{in} Extended_Index;
3387 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
3388 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3389 @key{or else raise} Program_Error) @key{and then}
3390 (Index @key{in} First_Index (Container) .. Last_Index (Container) + 1
3391 @key{or else raise} Constraint_Error),
3392 Post => Length (Container)'Old - Count <= Length (Container)],Old=[]};]}
3393 @end{Example}
3394
3395 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3396 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
3397 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3398 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
3399 Index is not in the range
3400 First_Index (Container) .. Last_Index (Container) + 1, then Constraint_Error is
3401 propagated. ]}If Count is 0, Delete has no effect.
3402 Otherwise@Chg{Version=[3],New=[,],Old=[]} Delete slides the
3403 elements (if any) starting at position Index + Count down to Index. Any
3404 exception raised during element assignment is propagated.]}
3405
3406 @begin{Ramification}
3407 @ChgRef{Version=[2],Kind=[AddedNormal]}
3408 @ChgAdded{Version=[2],Text=[If Index + Count >= Last_Index(Container), this
3409 effectively truncates the vector (setting Last_Index to Index @en 1 and
3410 consequently sets Length to Index @en Index_Type'First).]}
3411 @end{Ramification}
3412
3413 @begin{Example}
3414 @ChgRef{Version=[2],Kind=[AddedNormal]}
3415 @ChgRef{Version=[5],Kind=[Revised]}
3416 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Vector;
3417 Position : @key{in out} Cursor;
3418 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
3419 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3420 @key{or else raise} Program_Error) @key{and then}
3421 (Position /= No_Element
3422 @key{or else raise} Constraint_Error) @key{and then}
3423 (Has_Element (Container, Position)
3424 @key{or else raise} Program_Error),
3425 Post => Length (Container)'Old - Count <= Length (Container) @key{and then}
3426 Position = No_Element],Old=[]};]}
3427 @end{Example}
3428
3429 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3430 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3431 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
3432 Position equals No_Element, then
3433 Constraint_Error is propagated. If Position does not designate an element in
3434 Container, then Program_Error is propagated. Otherwise, ]}Delete (Container,
3435 To_Index (Position), Count) is called, and then Position is set to No_Element.]}
3436
3437 @begin{Example}
3438 @ChgRef{Version=[2],Kind=[AddedNormal]}
3439 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3440 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_First (Container : @key{in out} Vector;
3441 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
3442 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
3443 @key{or else raise} Program_Error,
3444 Post => Length (Container)'Old - Count <= Length (Container)],Old=[]};]}
3445 @end{Example}
3446
3447 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3448 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Delete (Container, First_Index (Container), Count).]}
3449
3450 @begin{Example}
3451 @ChgRef{Version=[2],Kind=[AddedNormal]}
3452 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3453 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_Last (Container : @key{in out} Vector;
3454 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
3455 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
3456 @key{or else raise} Program_Error,
3457 Post => Length (Container)'Old - Count <= Length (Container)],Old=[]};]}
3458 @end{Example}
3459
3460 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3461 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
3462 @ChgAdded{Version=[2],Type=[Trailing],Text=[If
3463 Length (Container) <= Count@Chg{Version=[3],New=[,],Old=[]} then
3464 Delete_Last is equivalent to Clear (Container).
3465 Otherwise@Chg{Version=[3],New=[,],Old=[]} it is equivalent to
3466 Delete (Container, Index_Type'Val(Index_Type'Pos(Last_Index (Container)) @en
3467 Count + 1), Count).]}
3468
3469 @begin{Example}
3470 @ChgRef{Version=[2],Kind=[AddedNormal]}
3471 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0092-1]}
3472 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3473 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reverse_Elements (Container : @key{in out} @Chg{Version=[3],New=[Vector],Old=[List]})@Chg{Version=[5],New=[
3474 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
3475 @key{or else raise} Program_Error],Old=[]};]}
3476
3477 @end{Example}
3478
3479 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3480 @ChgAdded{Version=[2],Type=[Trailing],Text=[Reorders the elements of Container
3481 in reverse order.]}
3482
3483 @begin{Discussion}
3484 @ChgRef{Version=[2],Kind=[AddedNormal]}
3485 @ChgAdded{Version=[2],Text=[This can copy the elements of the vector @em
3486 all cursors referencing the vector are ambiguous afterwards and may
3487 designate different elements afterwards.]}
3488 @end{Discussion}
3489
3490 @begin{Example}
3491 @ChgRef{Version=[2],Kind=[AddedNormal]}
3492 @ChgRef{Version=[5],Kind=[Revised]}
3493 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Swap (Container : @key{in out} Vector;
3494 I, J : @key{in} Index_Type)@Chg{Version=[5],New=[
3495 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
3496 @key{or else raise} Program_Error) @key{and then}
3497 (I @key{in} First_Index (Container) .. Last_Index (Container)
3498 @key{or else raise} Constraint_Error) @key{and then}
3499 (J @key{in} First_Index (Container) .. Last_Index (Container)
3500 @key{or else raise} Constraint_Error)],Old=[]};]}
3501 @end{Example}
3502
3503 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3504 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3505 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
3506 either I or J is not in the range First_Index (Container) .. Last_Index
3507 (Container), then Constraint_Error is propagated. Otherwise, ]}Swap exchanges
3508 the values of the elements at positions I and J.]}
3509
3510 @begin{Honest}
3511 @ChgRef{Version=[2],Kind=[AddedNormal]}
3512 @ChgAdded{Version=[2],Text=[The implementation is not required to actually
3513 copy the elements if it can do the swap some other way. But it is allowed
3514 to copy the elements if needed.]}
3515 @end{Honest}
3516
3517 @begin{Example}
3518 @ChgRef{Version=[2],Kind=[AddedNormal]}
3519 @ChgRef{Version=[5],Kind=[Revised]}
3520 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Swap (Container : @key{in out} Vector;
3521 I, J : @key{in} Cursor)@Chg{Version=[5],New=[
3522 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
3523 @key{or else raise} Program_Error) @key{and then}
3524 (I /= No_Element @key{or else} Constraint_Error) @key{and then}
3525 (J /= No_Element @key{or else} Constraint_Error) @key{and then}
3526 (Has_Element (Container, I)
3527 @key{or else raise} Program_Error) @key{and then}
3528 (Has_Element (Container, J)
3529 @key{or else raise} Program_Error)],Old=[]};]}
3530 @end{Example}
3531
3532 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3533 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3534 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
3535 either I or J is No_Element, then Constraint_Error is propagated. If either I or
3536 J do not designate an element in Container, then Program_Error is propagated.
3537 Otherwise, ]}Swap exchanges the values of the elements designated by I and J.]}
3538
3539 @begin{Ramification}
3540 @ChgRef{Version=[2],Kind=[AddedNormal]}
3541 @ChgAdded{Version=[2],Text=[After a call to Swap, I designates the element
3542 value previously designated by J, and J designates the element value
3543 previously designated by I. The cursors do not become ambiguous from this
3544 operation.]}
3545 @end{Ramification}
3546
3547 @begin{Honest}
3548 @ChgRef{Version=[2],Kind=[AddedNormal]}
3549 @ChgAdded{Version=[2],Text=[The implementation is not required to actually
3550 copy the elements if it can do the swap some other way. But it is allowed
3551 to copy the elements if needed.]}
3552 @end{Honest}
3553
3554 @begin{Example}
3555 @ChgRef{Version=[2],Kind=[AddedNormal]}
3556 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3557 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First_Index (Container : Vector) @key{return} Index_Type@Chg{Version=[5],New=[
3558 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3559 Post => First_Index'Result = Index_Type'First],Old=[]};]}
3560 @end{Example}
3561
3562 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3563 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the value Index_Type'First.]}
3564
3565 @begin{Discussion}
3566 @ChgRef{Version=[2],Kind=[AddedNormal]}
3567 @ChgAdded{Version=[2],Text=[We'd rather call this @lquotes@;First@rquotes@;,
3568 but then calling most routines in here with First (Some_Vect) would be
3569 ambiguous.]}
3570 @end{Discussion}
3571
3572 @begin{Example}
3573 @ChgRef{Version=[2],Kind=[AddedNormal]}
3574 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3575 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First (Container : Vector) @key{return} Cursor@Chg{Version=[5],New=[
3576 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3577 Post => (@key{if not} Is_Empty (Container)
3578 @key{then} Has_Element (Container, First'Result)
3579 @key{else} First'Result = No_Element)],Old=[]};]}
3580 @end{Example}
3581
3582 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3583 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, First
3584 returns No_Element. Otherwise, it returns a cursor that designates the first
3585 element in Container.]}
3586
3587 @begin{Example}
3588 @ChgRef{Version=[2],Kind=[AddedNormal]}
3589 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3590 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First_Element (Container : Vector)
3591 @key{return} Element_Type@Chg{Version=[5],New=[
3592 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
3593 @end{Example}
3594
3595 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3596 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Container, First_Index (Container)).]}
3597
3598 @begin{Example}
3599 @ChgRef{Version=[2],Kind=[AddedNormal]}
3600 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3601 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last_Index (Container : Vector) @key{return} Extended_Index@Chg{Version=[5],New=[
3602 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3603 Post => (@key{if} Length (Container) = 0 @key{then} Last_Index'Result = No_Index
3604 @key{else} Count_Type(Last_Index'Result - Index_Type'First) =
3605 Length (Container) - 1)],Old=[]};]}
3606 @end{Example}
3607
3608 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3609 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Last_Index
3610 returns No_Index. Otherwise, it returns the position of the last element in
3611 Container.]}
3612
3613 @begin{Example}
3614 @ChgRef{Version=[2],Kind=[AddedNormal]}
3615 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3616 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last (Container : Vector) @key{return} Cursor@Chg{Version=[5],New=[
3617 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3618 Post => (@key{if} not Is_Empty (Container)
3619 @key{then} Has_Element (Container, Last'Result)
3620 @key{else} Last'Result = No_Element)],Old=[]};]}
3621 @end{Example}
3622
3623 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3624 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Last returns
3625 No_Element. Otherwise, it returns a cursor that designates the last element in
3626 Container.]}
3627
3628 @begin{Example}
3629 @ChgRef{Version=[2],Kind=[AddedNormal]}
3630 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3631 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last_Element (Container : Vector)
3632 @key{return} Element_Type@Chg{Version=[5],New=[
3633 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
3634 @end{Example}
3635
3636 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3637 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Container,
3638 Last_Index (Container)).]}
3639
3640 @begin{Example}
3641 @ChgRef{Version=[2],Kind=[AddedNormal]}
3642 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3643 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Next (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
3644 @key{with} Global => (@key{in all}, @key{use null}),
3645 Nonblocking => True,
3646 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
3647 @key{else} True)],Old=[]};]}
3648 @end{Example}
3649
3650 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3651 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element or
3652 designates the last element of the container, then Next returns the value
3653 No_Element. Otherwise, it returns a cursor that designates the element with index
3654 To_Index (Position) + 1 in the same vector as Position.]}
3655
3656 @begin{Example}
3657 @ChgRef{Version=[5],Kind=[Added]}
3658 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Next (Container : Vector;
3659 Position : Cursor) @key{return} Cursor
3660 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3661 Pre => Position = No_Element @key{or else}
3662 Has_Element (Container, Position)
3663 @key{or else raise} Program_Error,
3664 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
3665 @key{elsif} Has_Element (Container, Next'Result) @key{then}
3666 To_Index (Container, Next'Result) =
3667 To_Index (Container, Position) + 1
3668 @key{elsif} Next'Result = No_Element @key{then}
3669 Position = Last (Container)
3670 @key{else} False);]}
3671 @end{Example}
3672
3673 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
3674 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns a cursor designating the
3675 next element in Container, if any.]}
3676
3677 @begin{Example}
3678 @ChgRef{Version=[2],Kind=[AddedNormal]}
3679 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3680 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Next (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
3681 @key{with} Global => (@key{in all}, @key{use null}),
3682 Nonblocking => True],Old=[]};]}
3683 @end{Example}
3684
3685 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3686 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Next (Position).]}
3687
3688 @begin{Example}
3689 @ChgRef{Version=[5],Kind=[Added]}
3690 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{procedure} Next (Container : @key{in} Vector;
3691 Position : @key{in out} Cursor)
3692 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3693 Pre => Position = No_Element @key{or else}
3694 Has_Element (Container, Position)
3695 @key{or else raise} Program_Error,
3696 Post => (@key{if} Position /= No_Element
3697 @key{then} Has_Element (Container, Position));]}
3698 @end{Example}
3699
3700 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
3701 @ChgAdded{Version=[5],Type=[Trailing],Text=[Equivalent to Position := Next
3702 (Container, Position).]}
3703
3704 @begin{Example}
3705 @ChgRef{Version=[2],Kind=[AddedNormal]}
3706 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3707 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Previous (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
3708 @key{with} Global => (@key{in all}, @key{use null}),
3709 Nonblocking => True,
3710 Post => (@key{if} Position = No_Element @key{then} Previous'Result = No_Element
3711 @key{else} True)],Old=[]};]}
3712 @end{Example}
3713
3714 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3715 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element or
3716 designates the first element of the container, then Previous returns the value
3717 No_Element. Otherwise, it returns a cursor that designates the element with index
3718 To_Index (Position) @en 1 in the same vector as Position.]}
3719
3720 @begin{Example}
3721 @ChgRef{Version=[5],Kind=[Added]}
3722 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Previous (Container : Vector;
3723 Position : Cursor) @key{return} Cursor
3724 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3725 Pre => Position = No_Element @key{or else}
3726 Has_Element (Container, Position)
3727 @key{or else raise} Program_Error,
3728 Post => (@key{if} Position = No_Element @key{then} Previous'Result = No_Element
3729 @key{elsif} Has_Element (Container, Previous'Result) @key{then}
3730 To_Index (Container, Previous'Result) =
3731 To_Index (Container, Position) - 1
3732 @key{elsif} Previous'Result = No_Element @key{then}
3733 Position = First (Container)
3734 @key{else} False);]}
3735 @end{Example}
3736
3737 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
3738 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns a cursor designating the
3739 previous element in Container, if any.]}
3740
3741 @begin{Example}
3742 @ChgRef{Version=[2],Kind=[AddedNormal]}
3743 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3744 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Previous (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
3745 @key{with} Global => (@key{in all}, @key{use null}),
3746 Nonblocking => True],Old=[]};]}
3747 @end{Example}
3748
3749 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3750 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Previous (Position).]}
3751
3752 @begin{Example}
3753 @ChgRef{Version=[5],Kind=[Added]}
3754 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{procedure} Previous (Container : @key{in} Vector;
3755 Position : @key{in out} Cursor)
3756 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3757 Pre => Position = No_Element @key{or else}
3758 Has_Element (Container, Position)
3759 @key{or else raise} Program_Error,
3760 Post => (@key{if} Position /= No_Element
3761 @key{then} Has_Element (Container, Position));]}
3762 @end{Example}
3763
3764 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
3765 @ChgAdded{Version=[5],Type=[Trailing],Text=[Equivalent to Position :=
3766 Previous (Container, Position).]}
3767
3768 @begin{Example}
3769 @ChgRef{Version=[2],Kind=[AddedNormal]}
3770 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Find_Index (Container : Vector;
3771 Item : Element_Type;
3772 Index : Index_Type := Index_Type'First)
3773 @key{return} Extended_Index;]}
3774 @end{Example}
3775
3776 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3777 @ChgAdded{Version=[2],Type=[Trailing],Text=[Searches the elements of Container
3778 for an element equal to Item (using the generic formal equality
3779 operator). The search starts at position Index and proceeds towards Last_Index
3780 (Container). If no equal element is found, then Find_Index returns No_Index.
3781 Otherwise, it returns the index of the first equal element encountered.]}
3782
3783 @begin{Example}
3784 @ChgRef{Version=[2],Kind=[AddedNormal]}
3785 @ChgRef{Version=[5],Kind=[Revised]}
3786 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Find (Container : Vector;
3787 Item : Element_Type;
3788 Position : Cursor := No_Element)
3789 @key{return} Cursor@Chg{Version=[5],New=[
3790 @key{with} Pre => Position = No_Element @key{or else}
3791 Has_Element (Container, Position)
3792 @key{or else raise} Program_Error,
3793 Post => (@key{if} Find'Result = No_Element @key{then} True
3794 @key{else} Has_Element (Container, Find'Result))],Old=[]};]}
3795 @end{Example}
3796
3797 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3798 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
3799 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3800 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
3801 Position is not No_Element, and
3802 does not designate an element in Container, then Program_Error is propagated.
3803 Otherwise@Chg{Version=[3],New=[,],Old=[]}
3804 ]}Find searches the elements of Container for an element equal to Item
3805 (using the generic formal equality operator). The search starts at
3806 the first element if Position equals No_Element, and at the element designated by
3807 Position otherwise. It proceeds towards the last element of Container. If no
3808 equal element is found, then Find returns No_Element. Otherwise, it returns a
3809 cursor designating the first equal element encountered.]}
3810
3811 @begin{Example}
3812 @ChgRef{Version=[2],Kind=[AddedNormal]}
3813 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Reverse_Find_Index (Container : Vector;
3814 Item : Element_Type;
3815 Index : Index_Type := Index_Type'Last)
3816 @key{return} Extended_Index;]}
3817 @end{Example}
3818
3819 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3820 @ChgAdded{Version=[2],Type=[Trailing],Text=[Searches the elements of Container
3821 for an element equal to Item (using the generic formal equality
3822 operator). The search starts at position Index or, if Index is greater than
3823 Last_Index (Container), at position Last_Index (Container). It proceeds towards
3824 First_Index (Container). If no equal element is found, then Reverse_Find_Index
3825 returns No_Index. Otherwise, it returns the index of the first equal element
3826 encountered.]}
3827
3828 @begin{Example}
3829 @ChgRef{Version=[2],Kind=[AddedNormal]}
3830 @ChgRef{Version=[5],Kind=[Revised]}
3831 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Reverse_Find (Container : Vector;
3832 Item : Element_Type;
3833 Position : Cursor := No_Element)
3834 @key{return} Cursor@Chg{Version=[5],New=[
3835 @key{with} Pre => Position = No_Element @key{or else}
3836 Has_Element (Container, Position)
3837 @key{or else raise} Program_Error,
3838 Post => (@key{if} Reverse_Find'Result = No_Element @key{then} True
3839 @key{else} Has_Element (Container, Reverse_Find'Result))],Old=[]};]}
3840 @end{Example}
3841
3842 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3843 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
3844 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3845 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
3846 Position is not No_Element, and
3847 does not designate an element in Container, then Program_Error is propagated.
3848 Otherwise@Chg{Version=[3],New=[,],Old=[]}
3849 ]}Reverse_Find searches the elements of Container for an element equal
3850 to Item (using the generic formal equality operator). The search
3851 starts at the last element if Position equals No_Element, and at the element
3852 designated by Position otherwise. It proceeds towards the first element of
3853 Container. If no equal element is found, then Reverse_Find returns No_Element.
3854 Otherwise, it returns a cursor designating the first equal element
3855 encountered.]}
3856
3857 @begin{Example}
3858 @ChgRef{Version=[2],Kind=[AddedNormal]}
3859 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Contains (Container : Vector;
3860 Item : Element_Type) @key{return} Boolean;]}
3861 @end{Example}
3862
3863 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3864 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Has_Element (Find (Container, Item)).]}
3865
3866 @begin{Example}
3867 @ChgRef{Version=[2],Kind=[AddedNormal]}
3868 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg]}
3869 @ChgAdded{Version=[2],KeepNext=[T],Text=[@Chg{Version=[3],New=[],Old=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean;]}]}
3870 @end{Example}
3871
3872 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3873 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]}
3874 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[],Old=[Returns True if Position designates
3875 an element, and returns False otherwise.]}]}
3876 @begin{Honest}
3877 @ChgRef{Version=[2],Kind=[AddedNormal]}
3878 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]}
3879 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[This function may not detect cursors that
3880 designate deleted elements; such cursors are invalid (see below) and the
3881 result of calling Has_Element with an invalid cursor is unspecified (but
3882 not erroneous).]}]}
3883 @end{Honest}
3884 @begin{NotIso}
3885 @ChgAdded{Version=[3],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 225 and 226
3886 were moved above.>}]}@Comment{This message should be
3887 deleted if the paragraphs are ever renumbered.}
3888 @end{NotIso}
3889
3890
3891 @begin{Example}
3892 @ChgRef{Version=[2],Kind=[AddedNormal]}
3893 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3894 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Iterate
3895 (Container : @key{in} Vector;
3896 Process : @key{not null access} @key{procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
3897 @key{with} Allows_Exit],Old=[]};]}
3898 @end{Example}
3899
3900 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3901 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]}
3902 @ChgAdded{Version=[2],Type=[Trailing],Text=[Invokes Process.@key{all} with a
3903 cursor that designates each element in Container, in index order.
3904 @Chg{Version=[3],New=[Tampering],Old=[Program_Error
3905 is propagated if Process.@key{all} tampers]}
3906 with the cursors of Container@Chg{Version=[3],New=[ is prohibited during the
3907 execution of a call on Process.@key{all}],Old=[]}. Any exception raised by
3908 Process.@key{all} is propagated.]}
3909
3910 @begin{Discussion}
3911 @ChgRef{Version=[2],Kind=[AddedNormal]}
3912 @ChgAdded{Version=[2],Text=[The purpose of the @lquotes@;tamper with the
3913 cursors@rquotes@; check is
3914 to prevent erroneous execution from the Position parameter of Process.@key{all}
3915 becoming invalid. This check takes place when the operations that tamper with
3916 the cursors of the container are called. The check cannot be made later (say
3917 in the body of Iterate), because that could cause the Position cursor to be
3918 invalid and potentially cause execution to become erroneous -- defeating the
3919 purpose of the check.]}
3920
3921 @ChgRef{Version=[2],Kind=[AddedNormal]}
3922 @ChgAdded{Version=[2],Text=[ There is no check needed if an attempt is made
3923 to insert or delete nothing (that is, Count = 0 or Length(Item) = 0).]}
3924
3925 @ChgRef{Version=[2],Kind=[AddedNormal]}
3926 @ChgAdded{Version=[2],Text=[The check is easy to implement: each container
3927 needs a counter. The counter is incremented when Iterate is called, and
3928 decremented when Iterate completes. If the counter is nonzero when an
3929 operation that inserts or deletes is called, Finalize is called, or one of
3930 the other operations in the list occurs, Program_Error is raised.]}
3931 @end{Discussion}
3932
3933 @begin{Example}
3934 @ChgRef{Version=[2],Kind=[AddedNormal]}
3935 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3936 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reverse_Iterate
3937 (Container : @key{in} Vector;
3938 Process : @key{not null access} @key{procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
3939 @key{with} Allows_Exit],Old=[]};]}
3940 @end{Example}
3941
3942 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3943 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]}
3944 @ChgAdded{Version=[2],Type=[Trailing],Text=[Iterates over the elements in
3945 Container as per @Chg{Version=[3],New=[procedure ],Old=[]}Iterate,
3946 except that elements are traversed in reverse index order.]}
3947
3948 @begin{Example}
3949 @ChgRef{Version=[3],Kind=[Added]}
3950 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0212-1],ARef=[AI12-0266-1]}
3951 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Vector)
3952 @key[return] Vector_Iterator_Interfaces.@Chg{Version=[5],New=[Parallel_Reversible_Iterator],Old=[Reversible_Iterator]}'Class@Chg{Version=[5],New=[
3953 @key[with] Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
3954 @end{Example}
3955
3956 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]}
3957 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0266-1]}
3958 @ChgAdded{Version=[3],Type=[Trailing],Text=[Iterate returns
3959 @Chg{Version=[5],New=[an],Old=[a reversible]}
3960 iterator object (see @RefSecNum{User-Defined Iterator Types}) that
3961 will generate a value for a loop parameter (see
3962 @RefSecNum{Generalized Loop Iteration}) designating
3963 each node in Container, starting with the first node and moving the cursor as
3964 per the Next function when used as a forward iterator, and starting with the
3965 last node and moving the cursor as per the Previous function when used as a
3966 reverse iterator@Chg{Version=[5],New=[, and processing all nodes
3967 concurrently when used as a parallel iterator],Old=[]}. Tampering with the
3968 cursors of Container is prohibited while
3969 the iterator object exists (in particular, in
3970 the @nt{sequence_of_statements} of the @nt{loop_statement} whose
3971 @nt{iterator_specification} denotes this object). The iterator object needs
3972 finalization.]}
3973
3974 @begin{Example}
3975 @ChgRef{Version=[3],Kind=[Added]}
3976 @ChgRef{Version=[5],Kind=[RevisedAdded]}
3977 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Vector; Start : @key[in] Cursor)
3978 @key[return] Vector_Iterator_Interfaces.Reversible_Iterator'Class@Chg{Version=[5],New=[
3979 @key[with] Pre => (Start /= No_Element
3980 @key[or else raise] Constraint_Error) @key[and then]
3981 (Has_Element (Container, Start)
3982 @key[or else raise] Program_Error),
3983 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
3984 @end{Example}
3985
3986 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0262-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]}
3987 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0212-1]}
3988 @ChgAdded{Version=[3],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
3989 Start is not No_Element and does
3990 not designate an item in Container, then Program_Error is propagated. If Start
3991 is No_Element, then Constraint_Error is propagated. Otherwise, ]}Iterate
3992 returns a reversible iterator object
3993 (see @RefSecNum{User-Defined Iterator Types}) that will generate
3994 a value for a loop parameter (see @RefSecNum{Generalized Loop Iteration})
3995 designating each node in Container, starting with the node
3996 designated by Start and moving the cursor as per the Next function when used as
3997 a forward iterator, or moving the cursor as per the Previous function when used
3998 as a reverse iterator. Tampering with the
3999 cursors of Container is prohibited while the iterator object exists (in
4000 particular, in the @nt{sequence_of_statements} of the @nt{loop_statement} whose
4001 @nt{iterator_specification} denotes this object). The iterator object needs
4002 finalization.]}
4003
4004 @begin{Discussion}
4005 @ChgRef{Version=[3],Kind=[AddedNormal]}
4006 @ChgAdded{Version=[3],Type=[Leading],Text=[Exits are allowed from the loops
4007 created using the iterator objects. In particular, to stop the iteration at a
4008 particular cursor, just add]}
4009 @begin{Example}
4010 @ChgRef{Version=[3],Kind=[AddedNormal]}
4011 @ChgAdded{Version=[3],Text=[@key[exit when] Cur = Stop;]}
4012 @end{Example}
4013 @ChgRef{Version=[3],Kind=[AddedNormal]}
4014 @ChgAdded{Version=[3],Type=[Trailing],Text=[in the body of the loop (assuming
4015 that @exam{Cur} is the loop parameter and @exam{Stop} is the cursor that you
4016 want to stop at).]}
4017 @end{Discussion}
4018
4019
4020 @end{DescribeCode}
4021
4022 @ChgRef{Version=[2],Kind=[AddedNormal]}
4023 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0044-1],ARef=[AI05-0262-1]}
4024 @ChgAdded{Version=[2],Text=[The actual function for the generic formal function
4025 "<" of Generic_Sorting is expected to return the same value each time it is
4026 called with a particular pair of element values. It should define a strict
4027 @Chg{Version=[3],New=[weak ],Old=[]}ordering relationship@Chg{Version=[3],
4028 New=[ (see @RefSecNum{Containers})],Old=[, that is, be irreflexive, asymmetric,
4029 and transitive]};
4030 it should not modify Container. If the actual for "<" behaves in some other
4031 manner, the behavior of the subprograms of Generic_Sorting are unspecified.
4032 @Chg{Version=[3],New=[The number of],Old=[How many]} times the subprograms of
4033 Generic_Sorting call "<" is unspecified.@PDefn{unspecified}]}
4034
4035 @begin{DescribeCode}
4036
4037 @begin{Example}
4038 @ChgRef{Version=[2],Kind=[AddedNormal]}
4039 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Is_Sorted (Container : Vector) @key{return} Boolean;]}
4040 @end{Example}
4041
4042 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4043 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns True if the elements are
4044 sorted smallest first as determined by the
4045 generic formal "<" operator; otherwise, Is_Sorted returns False.
4046 Any exception raised during evaluation of "<" is propagated.]}
4047
4048 @begin{Example}
4049 @ChgRef{Version=[2],Kind=[AddedNormal]}
4050 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4051 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Sort (Container : @key{in out} Vector)@Chg{Version=[5],New=[
4052 @key{with} Pre => (@key{if} Tampering_With_Elements_Prohibited (Container)
4053 @key{then raise} Program_Error)],Old=[]};]}
4054 @end{Example}
4055
4056 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4057 @ChgAdded{Version=[2],Type=[Trailing],Text=[Reorders the elements of Container
4058 such that the elements are
4059 sorted smallest first as determined by the generic formal "<" operator
4060 provided. Any exception raised during evaluation of "<" is propagated.]}
4061
4062 @begin{Ramification}
4063 @ChgRef{Version=[2],Kind=[AddedNormal]}
4064 @ChgAdded{Version=[2],Text=[This implies swapping the elements, usually
4065 including an intermediate copy. This means that the elements will usually be
4066 copied. (As with Swap, if the implementation can do this some other way, it
4067 is allowed to.) Since the elements are nonlimited, this usually will not be
4068 a problem. Note that there is @ImplAdviceName below that the implementation
4069 should use a sort that minimizes copying of elements.]}
4070
4071 @ChgRef{Version=[2],Kind=[AddedNormal]}
4072 @ChgAdded{Version=[2],Text=[The sort is not required to be stable (and the
4073 fast algorithm required will not be stable). If a stable sort is needed, the
4074 user can include the original location of the element as an extra "sort key".
4075 We considered requiring the implementation to do that, but it is mostly extra
4076 overhead -- usually there is something already in the element that provides
4077 the needed stability.]}
4078 @end{Ramification}
4079
4080 @begin{Example}
4081 @ChgRef{Version=[2],Kind=[AddedNormal]}
4082 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4083 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Merge (Target : @key{in out} Vector;
4084 Source : @key{in out} Vector)@Chg{Version=[5],New=[
4085 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
4086 @key{or else raise} Program_Error) @key{and then}
4087 (@key{not} Tampering_With_Cursors_Prohibited (Source)
4088 @key{or else raise} Program_Error) @key{and then}
4089 (Length (Target) <= Maximum_Length - Length (Source)
4090 @key{or else raise} Constraint_Error),
4091 Post => (@key{declare}
4092 Result_Length : @key{constant} Count_Type :=
4093 Length (Source)'Old + Length (Target)'Old;
4094 @key{begin}
4095 (@key{if} Target = Source @key{then} True
4096 @key{else} Length (Source) = 0 @key{and then}
4097 Length (Target) = Result_Length @key{and then}
4098 Capacity (Target) >= Result_Length))],Old=[]};]}
4099 @end{Example}
4100
4101 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4102 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1]}
4103 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[If Source is
4104 empty, then Merge does nothing. If Source and Target are the same nonempty
4105 container object, then Program_Error is propagated. Otherwise, ],Old=[]}Merge
4106 removes elements from Source and inserts them into Target; afterwards, Target
4107 contains the union of the elements that were initially in Source and Target;
4108 Source is left empty. If Target and Source are initially sorted smallest first,
4109 then Target is ordered smallest first as determined by the generic formal "<"
4110 operator; otherwise, the order of elements in Target is unspecified. Any
4111 exception raised during evaluation of "<" is propagated.]}
4112
4113 @begin{Discussion}
4114 @ChgRef{Version=[2],Kind=[AddedNormal]}
4115 @ChgAdded{Version=[2],Text=[It is a bounded error if either of the vectors is
4116 unsorted, see below. The bounded error can be recovered by sorting Target
4117 after the merge call, or the vectors can be pretested with Is_Sorted.]}
4118 @end{Discussion}
4119 @begin{ImplNote}
4120 @ChgRef{Version=[2],Kind=[AddedNormal]}
4121 @ChgAdded{Version=[2],Text=[The Merge operation will usually require copying
4122 almost all of the elements. One implementation strategy would be to
4123 extend Target to the appropriate length, then copying elements from the back
4124 of the vectors working towards the front. An alternative approach would be
4125 to allocate a new internal data array of the appropriate length, copy the
4126 elements into it in an appropriate order, and then replacing the data array
4127 in Target with the temporary.]}
4128 @end{ImplNote}
4129
4130 @end{DescribeCode}
4131
4132 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
4133 @ChgAdded{Version=[5],Text=[The nested package Vectors.Stable
4134 provides a type Stable.Vector that represents
4135 a @i<stable> vector,@Defn2{Term=(stable),Sec=(vector)} which is one that
4136 cannot grow and shrink. Such a vector can be created by calling the
4137 To_Vector or Copy functions, or by establishing a
4138 @i<stabilized view> of a regular Vector.@Defn2{Term=[stabilized view],Sec=[vector]}]}
4139
4140 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
4141 @ChgAdded{Version=[5],Type=[Leading],Text=[The subprograms of package
4142 Containers.Vectors that have a parameter or result of type Vector are included
4143 in the nested package Stable with the same specification, except that the
4144 following are omitted:]}
4145
4146 @begin{Indent}
4147 @ChgRef{Version=[5],Kind=[Added]}
4148 @ChgAdded{Version=[5],Text=[Tampering_With_Cursors_Prohibited,
4149 Tampering_With_Elements_Prohibited, Reserve_Capacity, Assign, Move,
4150 Insert, Insert_Space, Clear, Delete, Delete_First, Delete_Last, and
4151 Set_Length]}
4152 @end{Indent}
4153
4154 @ChgRef{Version=[5],Kind=[Added]}
4155 @ChgAdded{Version=[5],Type=[Trailing],Text=[Generic package Generic_Sorting is
4156 also included with the same specification, except that Merge is omitted.]}
4157
4158 @begin{Ramification}
4159 @ChgRef{Version=[5],Kind=[Added]}
4160 @ChgAdded{Version=[5],Text=[The names Vector and Cursor mean the types
4161 declared in the nested package in these subprogram specifications.]}
4162 @end{Ramification}
4163 @begin{Reason}
4164 @ChgRef{Version=[5],Kind=[Added]}
4165 @ChgAdded{Version=[5],Text=[The omitted routines are those that tamper with
4166 cursors or elements (or test that state). The model is that it is
4167 impossible to tamper with cursors or elements of a stable view since no
4168 such operations are included. Thus tampering checks are not needed for
4169 a stable view, and we omit the operations associated with those checks.]}
4170 @end{Reason}
4171
4172 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
4173 @ChgAdded{Version=[5],Text=[The operations of this package are equivalent
4174 to those for regular Vectors, except that the calls to
4175 Tampering_With_Cursors_Prohibited and
4176 Tampering_With_Elements_Prohibited that occur in preconditions are replaced
4177 by False, and any that occur in postconditions are replaced by True.]}
4178
4179 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
4180 @ChgAdded{Version=[5],Text=[If a stable vector is declared with the Base
4181 discriminant designating a pre-existing regular vector, the stable vector
4182 represents a stabilized view of the underlying regular vector, and any operation
4183 on the stable vector is reflected on the underlying regular vector. While a
4184 stabilized view exists, any operation that tampers with elements performed on
4185 the underlying vector is prohibited. The finalization of a stable vector that
4186 provides such a view removes this restriction on the underlying regular vector
4187 @Redundant[(though some other restriction might exist due to other concurrent
4188 iterations or stabilized views)].]}
4189
4190 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
4191 @ChgAdded{Version=[5],Text=[If a stable vector is declared without specifying
4192 Base, the object must be initialized. The initializing expression of the stable
4193 vector, @Redundant[typically a call on To_Vector or Copy], determines the Length
4194 of the vector. The Length of a stable vector never changes after
4195 initialization.]}
4196
4197 @end{StaticSem}
4198
4199 @begin{Bounded}
4200
4201 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4202 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]}
4203 @ChgAdded{Version=[2],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}
4204 Reading the value of an empty element by calling
4205 Element, Query_Element, Update_Element,@Chg{Version=[3],New=[
4206 Constant_Reference, Reference,],Old=[]} Swap, Is_Sorted, Sort, Merge,
4207 "=", Find, or Reverse_Find is a bounded error. The implementation may treat
4208 the element as having any normal value (see @RefSecNum{Data Validity}) of the
4209 element type, or raise
4210 Constraint_Error@Defn2{Term=[Constraint_Error],Sec=(raised by detection of a bounded error)}
4211 or Program_Error@Defn2{Term=[Program_Error],Sec=(raised by detection of a bounded error)}
4212 before modifying the vector.]}
4213
4214 @begin{Ramification}
4215 @ChgRef{Version=[2],Kind=[AddedNormal]}
4216 @ChgAdded{Version=[2],Text=[For instance, a default initialized element could
4217 be returned. Or some previous value of an element. But returning random junk
4218 is not allowed if the type has default initial value(s).]}
4219
4220 @ChgRef{Version=[2],Kind=[AddedNormal]}
4221 @ChgAdded{Version=[2],Text=[Assignment and streaming of empty elements are
4222 @b<not> bounded errors. This is consistent with regular composite types, for
4223 which assignment and streaming of uninitialized components do not cause a
4224 bounded error, but reading the uninitialized component does cause a bounded
4225 error.]}
4226
4227 @ChgRef{Version=[2],Kind=[AddedNormal]}
4228 @ChgAdded{Version=[2],Text=[There are other operations which are defined in
4229 terms of the operations listed above.]}
4230 @end{Ramification}
4231
4232 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4233 @ChgAdded{Version=[2],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}
4234 Calling Merge in an instance of Generic_Sorting
4235 with either Source or Target not ordered smallest first using the provided
4236 generic formal "<" operator is a bounded error. Either Program_Error is raised
4237 after Target is updated as described for Merge, or the operation works as
4238 defined.@Defn2{Term=[Program_Error],Sec=(raised by detection of a bounded error)}]}
4239
4240 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0022-1],ARef=[AI05-0248-1]}
4241 @ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}It
4242 is a bounded error for the actual function
4243 associated with a generic formal subprogram, when called as part of an
4244 operation of this package, to tamper with elements of any Vector parameter of
4245 the operation. Either Program_Error is raised, or the operation works as
4246 defined on the value of the Vector either prior to, or subsequent to, some or
4247 all of the modifications to the Vector.@Defn2{Term=[Program_Error],Sec=(raised by detection of a bounded error)}]}
4248
4249 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0027-1]}
4250 @ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}It
4251 is a bounded error to call any subprogram
4252 declared in the visible part of Containers.Vectors
4253 when the associated container has been finalized. If the operation takes
4254 Container as an @key[in out] parameter, then it raises Constraint_Error or
4255 Program_Error. Otherwise, the operation either proceeds as it would
4256 for an empty container, or it raises
4257 Constraint_Error@Defn2{Term=[Constraint_Error],Sec=(raised by detection of a bounded error)}
4258 or Program_Error.@Defn2{Term=[Program_Error],Sec=(raised by detection of a bounded error)}]}
4259
4260 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4261 @ChgAdded{Version=[2],Type=[Leading],Text=[
4262 @Defn2{Term=[ambiguous cursor],Sec=[of a vector]}
4263 @Defn2{Term=[cursor],Sec=[ambiguous]}
4264 A Cursor value is @i{ambiguous} if any of the following have occurred since it
4265 was created:]}
4266
4267 @begin{Itemize}
4268
4269 @ChgRef{Version=[2],Kind=[AddedNormal]}
4270 @ChgAdded{Version=[2],Text=[Insert, Insert_Space, or Delete has been called on
4271 the vector that contains the element the cursor designates with an index value
4272 (or a cursor designating an element at such an index value) less than or equal
4273 to the index value of the element designated by the cursor; or]}
4274
4275 @ChgRef{Version=[2],Kind=[AddedNormal]}
4276 @ChgAdded{Version=[2],Text=[The vector that contains the element it designates
4277 has been passed to the Sort or Merge procedures of an instance of
4278 Generic_Sorting, or to the Reverse_Elements procedure.]}
4279
4280 @end{Itemize}
4281
4282 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4283 @ChgAdded{Version=[2],Type=[Leading],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}
4284 It is a bounded error to call any subprogram other than "="
4285 or Has_Element declared in Containers.Vectors with an ambiguous (but not
4286 invalid, see below) cursor parameter. Possible results are:]}
4287
4288 @begin{Itemize}
4289
4290 @ChgRef{Version=[2],Kind=[AddedNormal]}
4291 @ChgAdded{Version=[2],Text=[The cursor may be treated as if it were No_Element;]}
4292
4293 @ChgRef{Version=[2],Kind=[AddedNormal]}
4294 @ChgAdded{Version=[2],Text=[The cursor may designate some element in the vector
4295 (but not necessarily the element that it originally designated);]}
4296
4297 @ChgRef{Version=[2],Kind=[AddedNormal]}
4298 @ChgAdded{Version=[2],Text=[Constraint_Error may be raised; or@Defn2{Term=[Constraint_Error],Sec=(raised by detection of a bounded error)}]}
4299
4300 @ChgRef{Version=[2],Kind=[AddedNormal]}
4301 @ChgAdded{Version=[2],Text=[Program_Error may be raised.@Defn2{Term=[Program_Error],Sec=(raised by detection of a bounded error)}]}
4302
4303 @end{Itemize}
4304
4305 @begin{Reason}
4306 @ChgRef{Version=[2],Kind=[AddedNormal]}
4307 @ChgAdded{Version=[2],Text=[Cursors are made ambiguous if an Insert or Delete
4308 occurs that moves the elements in the internal array including the designated
4309 ones. After such an operation, the cursor probably still designates an
4310 element (although it might not after a deletion), but it is a @i<different>
4311 element. That violates the definition of cursor @em it designates a particular
4312 element.]}
4313
4314 @ChgRef{Version=[2],Kind=[AddedNormal]}
4315 @ChgAdded{Version=[2],Text=[For "=" or Has_Element, the cursor works normally
4316 (it would not be No_Element). We don't want to trigger an exception simply
4317 for comparing a bad cursor.]}
4318
4319 @ChgRef{Version=[2],Kind=[AddedNormal]}
4320 @ChgAdded{Version=[2],Text=[While it is possible to check for these cases
4321 or ensure that cursors survive such operations, in many cases the overhead
4322 necessary to make the check (or ensure cursors continue to designate the
4323 same element) is substantial in time or space.]}
4324 @end{Reason}
4325
4326 @end{Bounded}
4327
4328 @begin{Erron}
4329 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4330 @ChgAdded{Version=[2],Type=[Leading],Text=[
4331 A Cursor value is @i{invalid} if any of the following have occurred since it
4332 was created:@Defn2{Term=[invalid cursor],Sec=[of a vector]}
4333 @PDefn2{Term=[cursor],Sec=[invalid]}]}
4334
4335 @begin{Itemize}
4336
4337 @ChgRef{Version=[2],Kind=[AddedNormal]}
4338 @ChgAdded{Version=[2],Text=[The vector that contains the element it designates
4339 has been finalized;]}
4340
4341 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0160-1]}
4342 @ChgAdded{Version=[3],Text=[The vector that contains the element it designates
4343 has been used as the Target of a call to Assign, or as the target of an
4344 @nt{assignment_statement};]}
4345
4346 @ChgRef{Version=[2],Kind=[AddedNormal]}
4347 @ChgAdded{Version=[2],Text=[@Redundant[The vector that contains the element it
4348 designates has been used as the Source or Target of a call to Move;] or]}
4349 @begin{TheProof}
4350 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
4351 @ChgAdded{Version=[3],Text=[Move has been reworded in terms of Assign and
4352 Clear, which are covered by other bullets, so this text is redundant.]}
4353 @end{TheProof}
4354
4355 @ChgRef{Version=[2],Kind=[AddedNormal]}
4356 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0160-1],ARef=[AI05-0262-1]}
4357 @ChgAdded{Version=[2],Text=[The element it designates has been
4358 deleted@Chg{Version=[3],New=[ or removed from the vector that previously
4359 contained the element],Old=[]}.]}
4360 @begin{Ramification}
4361 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]}
4362 @ChgAdded{Version=[3],Text=[An element can be removed via calls to Set_Length,
4363 Clear, and Merge; and indirectly via calls to Assign and Move.]}
4364 @end{Ramification}
4365
4366 @end{Itemize}
4367
4368 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4369 @ChgAdded{Version=[2],Text=[The result of "=" or Has_Element is unspecified if
4370 it is called with an invalid cursor parameter.@PDefn{unspecified} Execution
4371 is erroneous if any other subprogram declared in Containers.Vectors is called
4372 with an invalid cursor parameter.@PDefn2{Term=(erroneous execution),
4373 Sec=(cause)}]}
4374
4375 @begin{Discussion}
4376 @ChgRef{Version=[2],Kind=[AddedNormal]}
4377 @ChgAdded{Version=[2],Text=[The list above (combined with the bounded error
4378 cases) is intended to be exhaustive. In other cases, a cursor value continues
4379 to designate its original element. For instance, cursor values survive the
4380 appending of new elements.]}
4381 @end{Discussion}
4382
4383 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
4384 @ChgAdded{Version=[3],Text=[Execution is erroneous if the vector associated with the result of a call to
4385 Reference or Constant_Reference is finalized before the result object returned
4386 by the call to Reference or Constant_Reference is finalized.]}
4387
4388 @begin{Reason}
4389 @ChgRef{Version=[3],Kind=[AddedNormal]}
4390 @ChgAdded{Version=[3],Text=[Each object of Reference_Type and
4391 Constant_Reference_Type probably contains some reference to the originating
4392 container. If that container is prematurely finalized (which is only possible
4393 via Unchecked_Deallocation, as accessibility checks prevent passing a
4394 container to Reference that will not live as long as the result), the
4395 finalization of the object of Reference_Type will try to access a nonexistent
4396 object. This is a normal case of a dangling pointer created by
4397 Unchecked_Deallocation; we have to explicitly mention it here as the pointer
4398 in question is not visible in the specification of the type. (This is the same
4399 reason we have to say this for invalid cursors.)]}
4400 @end{Reason}
4401 @end{Erron}
4402
4403 @begin{ImplReq}
4404
4405 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4406 @ChgAdded{Version=[2],Text=[No storage associated with a vector object shall be
4407 lost upon assignment or scope exit.]}
4408
4409 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4410 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]}
4411 @ChgAdded{Version=[2],Text=[The execution of an @nt{assignment_statement} for
4412 a vector shall have the effect of copying the elements from the source vector
4413 object to the target vector object@Chg{Version=[3],New=[ and changing the length
4414 of the target object to that of the source object],Old=[]}.]}
4415
4416 @begin{ImplNote}
4417 @ChgRef{Version=[2],Kind=[AddedNormal]}
4418 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0298-1]}
4419 @ChgAdded{Version=[2],Text=[An assignment of a Vector is a @lquotes@;deep@rquotes
4420 copy; that is the elements are copied as well as the data structures.
4421 We say @lquotes@;effect of@rquotes in order to allow the implementation to
4422 avoid copying elements immediately if it wishes. For instance, an
4423 implementation that avoided copying until one of the containers is modified
4424 would be allowed.@Chg{Version=[3],New=[ (Note that such an implementation
4425 would be require care, as Query_Element and Constant_Reference both could be
4426 used to access an element which later needs to be reallocated while
4427 the parameter or reference still exists, potentially leaving the
4428 parameter or reference pointing at the wrong element.)],Old=[]}]}
4429 @end{ImplNote}
4430 @end{ImplReq}
4431
4432 @begin{ImplAdvice}
4433
4434 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4435 @ChgAdded{Version=[2],Text=[Containers.Vectors should be implemented similarly
4436 to an array. In particular, if the length of a vector is @i{N}, then]}
4437
4438 @begin{Itemize}
4439
4440 @ChgRef{Version=[2],Kind=[AddedNormal]}
4441 @ChgAdded{Version=[2],Text=[the worst-case time complexity of Element should
4442 be @i{O}(log @i{N});]}
4443 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4444 Text=[The worst-case time complexity of Element
4445 for Containers.Vector should be @i{O}(log @i{N}).]}]}
4446
4447 @ChgRef{Version=[2],Kind=[AddedNormal]}
4448 @ChgAdded{Version=[2],Text=[the worst-case time complexity of Append with
4449 Count=1 when @i{N} is less than the capacity of the vector should be
4450 @i{O}(log @i{N}); and]}
4451 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4452 Text=[The worst-case time complexity of Append with Count = 1 when
4453 @i{N} is less than the capacity for Containers.Vector should be @i{O}(log @i{N}).]}]}
4454
4455 @ChgRef{Version=[2],Kind=[AddedNormal]}
4456 @ChgAdded{Version=[2],Text=[the worst-case time complexity of Prepend with
4457 Count=1 and Delete_First with Count=1 should be @i{O}(@i{N} log @i{N}).]}
4458 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4459 Text=[The worst-case time complexity of Prepend with Count = 1 and
4460 Delete_First with Count=1 for Containers.Vectors should be @i{O}(@i{N} log @i{N}).]}]}
4461
4462 @end{Itemize}
4463
4464 @begin{Reason}
4465 @ChgRef{Version=[2],Kind=[AddedNormal]}
4466 @ChgAdded{Version=[2],Text=[We do not mean to overly constrain implementation
4467 strategies here. However, it is important for portability that the
4468 performance of large containers has roughly the same factors on different
4469 implementations. If a program is moved to an implementation that takes
4470 @i{O}(@i{N}) time to access elements, that program could be unusable when the
4471 vectors are large. We allow @i{O}(log @i{N}) access because the proportionality
4472 constant and caching effects are likely to be larger than the log factor, and
4473 we don't want to discourage innovative implementations.]}
4474 @end{Reason}
4475
4476 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4477 @ChgAdded{Version=[2],Text=[The worst-case time complexity of a call on procedure
4478 Sort of an instance of Containers.Vectors.Generic_Sorting should be @i{O}(@i{N}**2), and the
4479 average time complexity should be better than @i{O}(@i{N}**2).]}
4480 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4481 Text=[The worst-case time complexity of a call on procedure Sort of an
4482 instance of Containers.Vectors.Generic_Sorting should be @i{O}(@i{N}**2), and the
4483 average time complexity should be better than @i{O}(@i{N}**2).]}]}
4484
4485 @begin{Ramification}
4486 @ChgRef{Version=[2],Kind=[AddedNormal]}
4487 @ChgAdded{Version=[2],Text=[In other words, we're requiring the use of a
4488 better than @i{O}(@i{N}**2) sorting algorithm, such as Quicksort. No bubble sorts
4489 allowed!]}
4490 @end{Ramification}
4491
4492 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4493 @ChgAdded{Version=[2],Text=[Containers.Vectors.Generic_Sorting.Sort and
4494 Containers.Vectors.Generic_Sorting.Merge should minimize
4495 copying of elements.]}
4496 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4497 Text=[Containers.Vectors.Generic_Sorting.Sort and
4498 Containers.Vectors.Generic_Sorting.Merge should minimize copying of elements.]}]}
4499
4500 @begin{Honest}
4501 @ChgRef{Version=[2],Kind=[AddedNormal]}
4502 @ChgAdded{Version=[2],Text=[We do not mean @lquotes@;absolutely minimize@rquotes
4503 here; we're not intending to require a single copy for each element.
4504 Rather, we want to suggest that the sorting algorithm chosen is one that
4505 does not copy items unnecessarily. Bubble sort would not meet this advice,
4506 for instance.]}
4507 @end{Honest}
4508
4509 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4510 @ChgAdded{Version=[2],Text=[Move should not copy elements, and should minimize
4511 copying of internal data structures.]}
4512 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4513 Text=[Containers.Vectors.Move should not copy elements, and should minimize
4514 copying of internal data structures.]}]}
4515
4516 @begin{ImplNote}
4517 @ChgRef{Version=[2],Kind=[AddedNormal]}
4518 @ChgAdded{Version=[2],Text=[Usually that can be accomplished simply by
4519 moving the pointer(s) to the internal data structures from the Source vector
4520 to the Target vector.]}
4521 @end{ImplNote}
4522
4523 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4524 @ChgAdded{Version=[2],Text=[If an exception is propagated from a vector
4525 operation, no storage should be lost, nor any elements removed from a vector
4526 unless specified by the operation.]}
4527 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4528 Text=[If an exception is propagated from a vector
4529 operation, no storage should be lost, nor any elements removed from a vector
4530 unless specified by the operation.]}]}
4531
4532 @begin{Reason}
4533 @ChgRef{Version=[2],Kind=[AddedNormal]}
4534 @ChgAdded{Version=[2],Text=[This is important so that programs can recover
4535 from errors. But we don't want to require heroic efforts, so we just require
4536 documentation of cases where this can't be accomplished.]}
4537 @end{Reason}
4538
4539 @end{ImplAdvice}
4540
4541 @begin{Notes}
4542
4543 @ChgRef{Version=[2],Kind=[AddedNormal]}
4544 @ChgAdded{Version=[2],Text=[All elements of a vector occupy locations in the
4545 internal array. If a sparse container is required, a Hashed_Map should be used
4546 rather than a vector.]}
4547
4548 @ChgRef{Version=[2],Kind=[AddedNormal]}
4549 @ChgAdded{Version=[2],Text=[If Index_Type'Base'First = Index_Type'First an
4550 instance of Ada.Containers.Vectors will raise Constraint_Error. A value
4551 below Index_Type'First is required so that an empty vector has a meaningful
4552 value of Last_Index.]}
4553
4554 @begin{Discussion}
4555 @ChgRef{Version=[2],Kind=[AddedNormal]}
4556 @ChgAdded{Version=[2],Text=[This property is the main reason why only integer
4557 types (as opposed to any discrete type) are allowed as the index type of a
4558 vector. An enumeration or modular type would require a subtype in order to
4559 meet this requirement.]}
4560 @end{Discussion}
4561
4562 @end{Notes}
4563
4564 @begin{Extend95}
4565 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4566 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
4567 The package Containers.Vectors is new.]}
4568 @end{Extend95}
4569
4570 @begin{Incompatible2005}
4571 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
4572 @ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Subprograms Assign and Copy
4573 are added to Containers.Vectors. If an instance of Containers.Vectors
4574 is referenced in a @nt{use_clause}, and an entity @i<E> with the same
4575 @nt{defining_identifier} as a new entity in Containers.Vectors is
4576 defined in a package that is also referenced in a @nt{use_clause}, the
4577 entity @i<E> may no longer be use-visible, resulting in errors. This should
4578 be rare and is easily fixed if it does occur.]}
4579 @end{Incompatible2005}
4580
4581 @begin{Extend2005}
4582 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]}
4583 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
4584 Added iterator, reference, and indexing support to make vector containers more
4585 convenient to use.]}
4586 @end{Extend2005}
4587
4588 @begin{DiffWord2005}
4589 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
4590 @ChgAdded{Version=[3],Text=[Generalized the definition
4591 of Reserve_Capacity and Move. Specified which elements are read/written
4592 by stream attributes.]}
4593
4594 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0022-1]}
4595 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName
4596 to cover tampering by generic actual subprograms.]}
4597
4598 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0027-1]}
4599 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName
4600 to cover access to finalized vector containers.]}
4601
4602 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]}
4603 @ChgAdded{Version=[3],Text=[@b<Correction:> Redefined "<" actuals
4604 to require a strict weak ordering; the old definition allowed
4605 indeterminant comparisons that would not have worked in a container.]}
4606
4607 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0084-1]}
4608 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a pragma
4609 Remote_Types so that containers can be used in distributed programs.]}
4610
4611 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]}
4612 @ChgAdded{Version=[3],Text=[@b<Correction:> Revised the definition
4613 of invalid cursors to cover missing (and new) cases.]}
4614
4615 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0265-1]}
4616 @ChgAdded{Version=[3],Text=[@b<Correction:> Defined when a container
4617 prohibits tampering in order to more clearly define where the check is
4618 made and the exception raised.]}
4619 @end{DiffWord2005}
4620
4621 @begin{Inconsistent2012}
4622 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1]}
4623 @ChgAdded{Version=[5],Text=[@Defn{inconsistencies with Ada 2012}Tampering
4624 with elements is now defined to be equivalent to tampering with
4625 cursors for regular containers. If a program requires tampering detection
4626 to work, it might fail in Ada 202x. Specifically, if a program requires
4627 Program_Error to be raised by a routine that (only) tampers with elements
4628 in Ada 2012 (such as Replace_Element) when called in a context that does not
4629 allow tampering with elements (such as Update_Element), the routine will
4630 work as defined instead of raising Program_Error in Ada 202x. Needless to say,
4631 this shouldn't happen outside of test programs. Note that such contexts still
4632 prohibit tampering with cursors, so routines like Insert and Delete will
4633 still raise Program_Error in this case.]}
4634
4635 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
4636 @ChgAdded{Version=[5],Text=[Trying to insert or concatenate more than
4637 Count_Type'Last elements will now raise Constraint_Error rather than
4638 Capacity_Error. This is extremely unlikely to happen, as Count_Type'Last
4639 is typically at least 2**31-1, so most such vectors will exceed memory
4640 before reaching this error.]}
4641 @end{Inconsistent2012}
4642
4643 @begin{Incompatible2012}
4644 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1],ARef=[AI12-0112-1],ARef=[AI12-0339-1]}
4645 @ChgAdded{Version=[5],Text=[@Defn{incompatibilities with Ada 2012}A number of
4646 new subprograms, types, and even a nested package were added to
4647 Containers.Vectors to better support contracts and stable views. If an
4648 instance of Containers.Vectors
4649 is referenced in a @nt{use_clause}, and an entity @i<E> with the same
4650 @nt{defining_identifier} as a new entity in Containers.Hashed_Maps is
4651 defined in a package that is also referenced in a @nt{use_clause}, the
4652 entity @i<E> may no longer be use-visible, resulting in errors. This should
4653 be rare and is easily fixed if it does occur.]}
4654 @end{Incompatible2012}
4655
4656 @begin{Extend2012}
4657 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0196-1]}
4658 @ChgAdded{Version=[5],Text=[@Defn{extensions to Ada 2012}@b{Correction:}
4659 To_Cursor and Replace_Element are now defined such that they can be used
4660 concurrently so long as they operate on different elements. This allows
4661 some container operations to be used in parallel without separate
4662 synchronization.]}
4663
4664 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0212-1]}
4665 @ChgAdded{Version=[5],Text=[Vectors now support indexed container
4666 aggregates, so @nt{aggregate} syntax can be used to create Vectors.]}
4667
4668 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0266-1]}
4669 @ChgAdded{Version=[5],Text=[The iterator for the
4670 entire container now can return a parallel iterator which can be used to
4671 process the container in parallel.]}
4672 @end{Extend2012}
4673
4674 @begin{DiffWord2012}
4675 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0110-1]}
4676 @ChgAdded{Version=[4],Text=[@b<Corrigendum:> Clarified that tampering checks
4677 precede all other checks made by a subprogram (but come after those associated
4678 with the call).]}
4679
4680 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
4681 @ChgAdded{Version=[5],Text=[Added contracts to this container. This includes
4682 describing some of the semantics with pre- and postconditions, rather than
4683 English text. Note that the preconditions can be Suppressed (see
4684 @RefSecNum{Suppressing Checks}).]}
4685 @end{DiffWord2012}
4686
4687
4688 @LabeledAddedSubclause{Version=[2],
4689 Name=[The Generic Package Containers.Doubly_Linked_Lists]}
4690
4691 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4692 @ChgAdded{Version=[2],Text=[The language-defined generic package
4693 Containers.Doubly_Linked_Lists provides private types List and Cursor, and a
4694 set of operations for each type. A list container is optimized for insertion
4695 and deletion at any position. @Defn{list container}@Defn2{Term=[container],Sec=[list]}]}
4696
4697 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4698 @ChgAdded{Version=[2],Text=[@Defn2{Term=[node],Sec=[of a list]}A
4699 doubly-linked list container object manages a linked list of internal
4700 @i{nodes}, each of which contains an element and pointers to the
4701 next (successor) and previous (predecessor) internal nodes. A cursor
4702 designates a particular node within a list (and by extension the element
4703 contained in that node). A cursor keeps designating the same node (and element)
4704 as long as the node is part of the container, even if the node is moved in the
4705 container.]}
4706
4707 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4708 @ChgAdded{Version=[2],Text=[The @i{length} of a list is the number of elements
4709 it contains.@Defn2{Term=[length],Sec=(of a list container)}]}
4710
4711 @begin{StaticSem}
4712 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4713 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library
4714 package Containers.Doubly_Linked_Lists has the following declaration:]}
4715 @begin{Example}
4716 @ChgRef{Version=[2],Kind=[AddedNormal]}
4717 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0084-1],ARef=[AI05-0212-1]}
4718 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4719 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[@key[with] Ada.Iterator_Interfaces;
4720 ],Old=[]}@key{generic}
4721 @key{type} Element_Type @key{is private};
4722 @key{with function} "=" (Left, Right : Element_Type)
4723 @key{return} Boolean @key{is} <>;
4724 @key{package} Ada.Containers.Doubly_Linked_Lists@Chg{Version=[5],New=[],Old=[ @key{is}]}@ChildUnit{Parent=[Ada.Containers],Child=[Doubly_@!Linked_@!Lists]}@Chg{Version=[5],New=[
4725 @key[with] Preelaborate, Remote_Types,
4726 Nonblocking, Global => @key[null] @key[is]],Old=[
4727 @key{pragma} Preelaborate(Doubly_Linked_Lists);@Chg{Version=[3],New=[
4728 @key{pragma} Remote_Types(Doubly_Linked_Lists);],Old=[]}]}]}
4729
4730 @begin{Discussion}
4731 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
4732 @ChgAdded{Version=[5],Text=[For discussion on the reasons and meaning of
4733 the specifications of the Global and Nonblocking aspects in this generic
4734 package, see the notes on the equivalent operations in the specification
4735 of the Containers.Vectors package (see
4736 @RefSecNum{The Generic Package Containers.Vectors}).]}
4737 @end{Discussion}
4738
4739 @ChgRef{Version=[2],Kind=[AddedNormal]}
4740 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]}
4741 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0111-1],ARef=[AI12-0112-1],ARef=[AI12-0212-1],ARef=[AI12-0339-1]}
4742 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{List} @key{is tagged private}@Chg{Version=[3],New=[
4743 @key[with] Constant_Indexing => Constant_Reference,
4744 Variable_Indexing => Reference,
4745 Default_Iterator => Iterate,
4746 Iterator_Element => Element_Type],Old=[]}@Chg{Version=[5],New=[,
4747 Iterator_View => Stable.List,
4748 Aggregate => (Empty => Empty,
4749 Add_Unnamed => Append),
4750 Stable_Properties => (Length,
4751 Tampering_With_Cursors_Prohibited,
4752 Tampering_With_Elements_Prohibited),
4753 Default_Initial_Condition =>
4754 Length (List) = 0 @key{and then}
4755 (@key{not} Tampering_With_Cursors_Prohibited (List)) @key{and then}
4756 (@key{not} Tampering_With_Elements_Prohibited (List))],Old=[]};
4757 @key{pragma} Preelaborable_Initialization(List);]}
4758
4759 @ChgRef{Version=[2],Kind=[AddedNormal]}
4760 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private};
4761 @key{pragma} Preelaborable_Initialization(Cursor);]}
4762
4763 @ChgRef{Version=[2],Kind=[AddedNormal]}
4764 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{Empty_List} : @key{constant} List;]}
4765
4766 @ChgRef{Version=[2],Kind=[AddedNormal]}
4767 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]}
4768
4769 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
4770 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
4771 @ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
4772 @key[with] Nonblocking, Global => (@key[in all], @key[use null])],Old=[]};]}
4773
4774 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
4775 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Has_Element} (Container : List; Position : Cursor)
4776 @key{return} Boolean
4777 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
4778
4779 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
4780 @ChgAdded{Version=[3],Text=[ @key[package] @AdaPackDefn{List_Iterator_Interfaces} @key[is new]
4781 Ada.Iterator_Interfaces (Cursor, Has_Element);]}
4782
4783 @ChgRef{Version=[2],Kind=[AddedNormal]}
4784 @ChgAdded{Version=[2],Text=[ @key{function} "=" (Left, Right : List) @key{return} Boolean;]}
4785
4786 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
4787 @ChgAdded{Version=[5],Text=[ @key{function} Same_Object (Left, Right : List) @key{return} Boolean
4788 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
4789
4790 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
4791 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Tampering_With_Cursors_Prohibited}
4792 (Container : List) @key{return} Boolean
4793 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
4794
4795 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
4796 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Tampering_With_Elements_Prohibited}
4797 (Container : List) @key{return} Boolean
4798 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
4799
4800 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0339-1]}
4801 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Empty} @key{return} List
4802 @key[is] (Empty_List)
4803 @key[with] Post =>
4804 @key[not] Tampering_With_Elements_Prohibited (Empty'Result) @key[and then]
4805 @key[not] Tampering_With_Cursors_Prohibited (Empty'Result) @key[and then]
4806 Length (Empty'Result) = 0;]}
4807
4808 @ChgRef{Version=[2],Kind=[AddedNormal]}
4809 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4810 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Length} (Container : List) @key{return} Count_Type@Chg{Version=[5],New=[
4811 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
4812
4813 @ChgRef{Version=[2],Kind=[AddedNormal]}
4814 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4815 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Empty} (Container : List) @key{return} Boolean@Chg{Version=[5],New=[
4816 @key[with] Nonblocking, Global => (@key[null], @key[use null]),
4817 Post => Is_Empty'Result = (Length (Container) = 0)],Old=[]};]}
4818
4819 @ChgRef{Version=[2],Kind=[AddedNormal]}
4820 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4821 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Clear} (Container : @key{in out} List)@Chg{Version=[5],New=[
4822 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
4823 @key[or else raise] Program_Error,
4824 Post => Length (Container) = 0],Old=[]};]}
4825
4826 @ChgRef{Version=[2],Kind=[AddedNormal]}
4827 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4828 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Position : Cursor) @key{return} Element_Type@Chg{Version=[5],New=[
4829 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
4830 Nonblocking => Element_Type'Nonblocking,
4831 Global => (@key{in all}, @key{use} Element_Type)],Old=[]};]}
4832
4833 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
4834 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Element} (Container : List;
4835 Position : Cursor) @key{return} Element_Type
4836 @key{with} Pre => (Position /= No_Element @key{or else}
4837 @key{raise} Constraint_Error) @key{and then}
4838 (Has_Element (Container, Position) @key{or else raise} Program_Error),
4839 Nonblocking => Element_Type'Nonblocking,
4840 Global => (@key{null}, @key{use} Element_Type);]}
4841
4842 @ChgRef{Version=[2],Kind=[AddedNormal]}
4843 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4844 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} List;
4845 Position : @key{in} Cursor;
4846 New_item : @key{in} Element_Type)@Chg{Version=[5],New=[
4847 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
4848 @key{or else raise} Program_Error) @key{and then}
4849 (Position /= No_Element
4850 @key{or else raise} Constraint_Error) @key{and then}
4851 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
4852
4853 @ChgRef{Version=[2],Kind=[AddedNormal]}
4854 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4855 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element}
4856 (Position : @key{in} Cursor;
4857 Process : @key{not null access procedure} (Element : @key{in} Element_Type))@Chg{Version=[5],New=[
4858 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
4859 Global => @key{in all}],Old=[]};]}
4860
4861 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
4862 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Query_Element}
4863 (Container : @key{in} List;
4864 Position : @key{in} Cursor;
4865 Process : @key{not null access procedure} (Element : @key{in} Element_Type))
4866 @key{with} Pre => (Position /= No_Element
4867 @key{or else raise} Constraint_Error) @key{and then}
4868 (Has_Element (Container, Position)
4869 @key{or else raise} Program_Error);]}
4870
4871 @ChgRef{Version=[2],Kind=[AddedNormal]}
4872 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4873 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element}
4874 (Container : @key{in out} List;
4875 Position : @key{in} Cursor;
4876 Process : @key{not null access procedure}
4877 (Element : @key{in out} Element_Type))@Chg{Version=[5],New=[
4878 @key{with} Pre => (Position /= No_Element @key{or else raise} Constraint_Error) @key{and then}
4879 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
4880
4881 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
4882 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
4883 @ChgAdded{Version=[3],Text=[ @key[type] Constant_Reference_Type
4884 (Element : @key[not null access constant] Element_Type) @key[is private]
4885 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
4886 Nonblocking, Global => @key[in out synchronized],
4887 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
4888
4889 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
4890 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
4891 @ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Reference_Type} (Element : @key[not null access] Element_Type) @key[is private]
4892 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
4893 Nonblocking, Global => @key[in out synchronized],
4894 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
4895
4896 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
4897 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
4898 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] List;
4899 Position : @key[in] Cursor)
4900 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
4901 @key[with] Pre => (Position /= No_Element @key[or else]
4902 @key[raise] Constraint_Error) @key[and then]
4903 (Has_Element (Container, Position) @key[or else raise] Program_Error),
4904 Post => Tampering_With_Cursors_Prohibited (Container),
4905 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
4906
4907 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
4908 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
4909 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] List;
4910 Position : @key[in] Cursor)
4911 @key[return] Reference_Type@Chg{Version=[5],New=[
4912 @key[with] Pre => (Position /= No_Element @key[or else]
4913 @key[raise] Constraint_Error) @key[and then]
4914 (Has_Element (Container, Position) @key[or else raise] Program_Error),
4915 Post => Tampering_With_Cursors_Prohibited (Container),
4916 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
4917
4918 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
4919 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
4920 @ChgAdded{Version=[3],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} List; Source : @key{in} List)@Chg{Version=[5],New=[
4921 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Target)
4922 @key[or else raise] Program_Error,
4923 Post => Length (Source) = Length (Target)],Old=[]};]}
4924
4925 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
4926 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
4927 @ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Copy} (Source : List)
4928 @key[return] List@Chg{Version=[5],New=[
4929 @key[with] Post => Length (Copy'Result) = Length (Source) @key[and then]
4930 @key[not] Tampering_With_Elements_Prohibited (Copy'Result) @key[and then]
4931 @key[not] Tampering_With_Cursors_Prohibited (Copy'Result)],Old=[]};]}
4932
4933 @ChgRef{Version=[2],Kind=[AddedNormal]}
4934 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4935 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Move} (Target : @key{in out} List;
4936 Source : @key{in out} List)@Chg{Version=[5],New=[
4937 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
4938 @key{or else raise} Program_Error) @key{and then}
4939 (@key{not} Tampering_With_Cursors_Prohibited (Source)
4940 @key{or else raise} Program_Error),
4941 Post => (@key{if} Target = Source @key{then} True
4942 @key{else}
4943 Length (Target) = Length (Source'Old) @key{and then}
4944 Length (Source) = 0)],Old=[]};]}
4945
4946 @ChgRef{Version=[2],Kind=[AddedNormal]}
4947 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4948 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} List;
4949 Before : @key{in} Cursor;
4950 New_Item : @key{in} Element_Type;
4951 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
4952 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
4953 @key{or else raise} Program_Error) @key{and then}
4954 (Before = No_Element @key{or else}
4955 Has_Element (Container, Before)
4956 @key{or else raise} Program_Error) @key{and then}
4957 (Length (Container) <= Count_Type'Last - Count
4958 @key{or else raise} Constraint_Error),
4959 Post => Length (Container)'Old + Count = Length (Container)],Old=[]};]}
4960
4961 @ChgRef{Version=[2],Kind=[AddedNormal]}
4962 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4963 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} List;
4964 Before : @key{in} Cursor;
4965 New_Item : @key{in} Element_Type;
4966 Position : @key{out} Cursor;
4967 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
4968 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
4969 @key{or else raise} Program_Error) @key{and then}
4970 (Before = No_Element @key{or else}
4971 Has_Element (Container, Before)
4972 @key{or else raise} Program_Error) @key{and then}
4973 (Length (Container) <= Count_Type'Last - Count
4974 @key{or else raise} Constraint_Error),
4975 Post => Length (Container)'Old + Count = Length (Container)
4976 @key{and then} Has_Element (Container, Position)],Old=[]};]}
4977
4978 @ChgRef{Version=[2],Kind=[AddedNormal]}
4979 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4980 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} List;
4981 Before : @key{in} Cursor;
4982 Position : @key{out} Cursor;
4983 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
4984 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
4985 @key{or else raise} Program_Error) @key{and then}
4986 (Before = No_Element @key{or else}
4987 Has_Element (Container, Before)
4988 @key{or else raise} Program_Error) @key{and then}
4989 (Length (Container) <= Count_Type'Last - Count
4990 @key{or else raise} Constraint_Error),
4991 Post => Length (Container)'Old + Count = Length (Container)
4992 @key{and then} Has_Element (Container, Position)],Old=[]};]}
4993
4994 @ChgRef{Version=[2],Kind=[AddedNormal]}
4995 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4996 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Prepend} (Container : @key{in out} List;
4997 New_Item : @key{in} Element_Type;
4998 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
4999 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
5000 @key{or else raise} Program_Error) @key{and then}
5001 (Length (Container) <= Count_Type'Last - Count
5002 @key{or else raise} Constraint_Error),
5003 Post => Length (Container)'Old + Count = Length (Container)],Old=[]};]}
5004
5005 @ChgRef{Version=[2],Kind=[AddedNormal]}
5006 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5007 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Append} (Container : @key{in out} List;
5008 New_Item : @key{in} Element_Type;
5009 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
5010 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
5011 @key{or else raise} Program_Error) @key{and then}
5012 (Length (Container) <= Count_Type'Last - Count
5013 @key{or else raise} Constraint_Error),
5014 Post => Length (Container)'Old + Count = Length (Container)],Old=[]};]}
5015
5016 @ChgRef{Version=[2],Kind=[AddedNormal]}
5017 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5018 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} List;
5019 Position : @key{in out} Cursor;
5020 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
5021 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
5022 @key{or else raise} Program_Error) @key{and then}
5023 (Position /= No_Element
5024 @key{or else raise} Constraint_Error) @key{and then}
5025 (Has_Element (Container, Position)
5026 @key{or else raise} Program_Error),
5027 Post => Length (Container)'Old - Count <= Length (Container)
5028 @key{and then} Position = No_Element],Old=[]};]}
5029
5030 @ChgRef{Version=[2],Kind=[AddedNormal]}
5031 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5032 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_First} (Container : @key{in out} List;
5033 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
5034 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
5035 @key{or else raise} Program_Error,
5036 Post => Length (Container)'Old - Count <= Length (Container)],Old=[]};]}
5037
5038 @ChgRef{Version=[2],Kind=[AddedNormal]}
5039 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5040 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_Last} (Container : @key{in out} List;
5041 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
5042 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
5043 @key{or else raise} Program_Error,
5044 Post => Length (Container)'Old - Count <= Length (Container)],Old=[]};]}
5045
5046 @ChgRef{Version=[2],Kind=[AddedNormal]}
5047 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5048 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reverse_Elements} (Container : @key{in out} List)@Chg{Version=[5],New=[
5049 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
5050 @key{or else raise} Program_Error],Old=[]};]}
5051
5052 @ChgRef{Version=[2],Kind=[AddedNormal]}
5053 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5054 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Swap} (Container : @key{in out} List;
5055 I, J : @key{in} Cursor)@Chg{Version=[5],New=[
5056 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
5057 @key{or else raise} Program_Error) @key{and then}
5058 (I /= No_Element @key{or else} Constraint_Error) @key{and then}
5059 (J /= No_Element @key{or else} Constraint_Error) @key{and then}
5060 (Has_Element (Container, I)
5061 @key{or else raise} Program_Error) @key{and then}
5062 (Has_Element (Container, J)
5063 @key{or else raise} Program_Error)],Old=[]};]}
5064
5065 @ChgRef{Version=[2],Kind=[AddedNormal]}
5066 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5067 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Swap_Links} (Container : @key{in out} List;
5068 I, J : @key{in} Cursor)@Chg{Version=[5],New=[
5069 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
5070 @key{or else raise} Program_Error) @key{and then}
5071 (I /= No_Element @key{or else} Constraint_Error) @key{and then}
5072 (J /= No_Element @key{or else} Constraint_Error) @key{and then}
5073 (Has_Element (Container, I)
5074 @key{or else raise} Program_Error) @key{and then}
5075 (Has_Element (Container, J)
5076 @key{or else raise} Program_Error)],Old=[]};]}
5077
5078 @ChgRef{Version=[2],Kind=[AddedNormal]}
5079 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5080 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Splice} (Target : @key{in out} List;
5081 Before : @key{in} Cursor;
5082 Source : @key{in out} List)@Chg{Version=[5],New=[
5083 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
5084 @key{or else raise} Program_Error) @key{and then}
5085 (@key{not} Tampering_With_Cursors_Prohibited (Source)
5086 @key{or else raise} Program_Error) @key{and then}
5087 (Before = No_Element @key{or else}
5088 Has_Element (Target, Before)
5089 @key{or else raise} Program_Error) @key{and then}
5090 (Same_Object (Target, Source) @key{or else}
5091 Length (Target) <= Count_Type'Last - 1
5092 @key{or else raise} Constraint_Error),
5093 Post => (@key{declare}
5094 Result_Length : @key{constant} Count_Type :=
5095 Length (Source)'Old + Length (Target)'Old;
5096 @key{begin}
5097 (@key{if} Target = Source @key{then} True
5098 @key{else} Length (Source) = 0 @key{and then}
5099 Length (Target) = Result_Length))],Old=[]};]}
5100
5101 @ChgRef{Version=[2],Kind=[AddedNormal]}
5102 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5103 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Splice} (Target : @key{in out} List;
5104 Before : @key{in} Cursor;
5105 Source : @key{in out} List;
5106 Position : @key{in out} Cursor)@Chg{Version=[5],New=[
5107 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
5108 @key{or else raise} Program_Error) @key{and then}
5109 (@key{not} Tampering_With_Cursors_Prohibited (Source)
5110 @key{or else raise} Program_Error) @key{and then}
5111 (Position /= No_Element
5112 @key{or else raise} Constraint_Error) @key{and then}
5113 (Has_Element (Source, Position)
5114 @key{or else raise} Program_Error) @key{and then}
5115 (Before = No_Element @key{or else}
5116 Has_Element (Target, Before)
5117 @key{or else raise} Program_Error) @key{and then}
5118 (Same_Object (Target, Source) @key{or else}
5119 Length (Target) <= Count_Type'Last - 1
5120 @key{or else raise} Constraint_Error),
5121 Post => (@key{declare}
5122 Org_Target_Length : @key{constant} Count_Type :=
5123 Length (Target)'Old;
5124 Org_Source_Length : @key{constant} Count_Type :=
5125 Length (Source)'Old;
5126 @key{begin}
5127 (@key{if} Target = Source @key{then}
5128 Position = Position'Old
5129 @key{else} Length (Source) = Org_Source_Length - 1 @key{and then}
5130 Length (Target) = Org_Target_Length + 1 @key{and then}
5131 Has_Element (Target, Position)))],Old=[]};]}
5132
5133 @ChgRef{Version=[2],Kind=[AddedNormal]}
5134 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Splice} (Container: @key{in out} List;
5135 Before : @key{in} Cursor;
5136 Position : @key{in} Cursor)@Chg{Version=[5],New=[
5137 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
5138 @key{or else raise} Program_Error) @key{and then}
5139 (Position /= No_Element
5140 @key{or else raise} Constraint_Error) @key{and then}
5141 (Has_Element (Container, Position)
5142 @key{or else raise} Program_Error) @key{and then}
5143 (Before = No_Element @key{or else}
5144 Has_Element (Container, Before)
5145 @key{or else raise} Program_Error),
5146 Post => Length (Container) = Length (Container)'Old],Old=[]};]}
5147
5148 @ChgRef{Version=[2],Kind=[AddedNormal]}
5149 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5150 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First} (Container : List) @key{return} Cursor@Chg{Version=[5],New=[
5151 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
5152 Post => (@key{if not} Is_Empty (Container)
5153 @key{then} Has_Element (Container, First'Result)
5154 @key{else} First'Result = No_Element)],Old=[]};]}
5155
5156 @ChgRef{Version=[2],Kind=[AddedNormal]}
5157 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5158 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First_Element} (Container : List)
5159 @key{return} Element_Type@Chg{Version=[5],New=[
5160 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
5161
5162 @ChgRef{Version=[2],Kind=[AddedNormal]}
5163 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5164 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last} (Container : List) @key{return} Cursor@Chg{Version=[5],New=[
5165 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
5166 Post => (@key{if} not Is_Empty (Container)
5167 @key{then} Has_Element (Container, Last'Result)
5168 @key{else} Last'Result = No_Element)],Old=[]};]}
5169
5170 @ChgRef{Version=[2],Kind=[AddedNormal]}
5171 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5172 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last_Element} (Container : List)
5173 @key{return} Element_Type@Chg{Version=[5],New=[
5174 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
5175
5176 @ChgRef{Version=[2],Kind=[AddedNormal]}
5177 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5178 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Next} (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
5179 @key{with} Global => (@key{in all}, @key{use null}),
5180 Nonblocking => True,
5181 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
5182 @key{else} True)],Old=[]};]}
5183
5184 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5185 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Next} (Container : List;
5186 Position : Cursor) @key{return} Cursor
5187 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
5188 Pre => Position = No_Element @key{or else}
5189 Has_Element (Container, Position)
5190 @key{or else raise} Program_Error,
5191 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
5192 @key{elsif} Next'Result = No_Element @key{then}
5193 Position = Last (Container)
5194 @key{else} Has_Element (Container, Next'Result));]}
5195
5196 @ChgRef{Version=[2],Kind=[AddedNormal]}
5197 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5198 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Next} (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
5199 @key{with} Global => (@key{in all}, @key{use null}),
5200 Nonblocking => True],Old=[]};]}
5201
5202 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5203 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Next} (Container : @key{in} List;
5204 Position : @key{in out} Cursor)
5205 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
5206 Pre => Position = No_Element @key{or else}
5207 Has_Element (Container, Position)
5208 @key{or else raise} Program_Error,
5209 Post => (@key{if} Position /= No_Element
5210 @key{then} Has_Element (Container, Position));]}
5211
5212 @ChgRef{Version=[2],Kind=[AddedNormal]}
5213 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5214 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Previous} (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
5215 @key{with} Global => (@key{in all}, @key{use null}),
5216 Nonblocking => True,
5217 Post => (@key{if} Position = No_Element @key{then} Previous'Result = No_Element
5218 @key{else} True)],Old=[]};]}
5219
5220 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5221 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Previous} (Container : List;
5222 Position : Cursor) @key{return} Cursor
5223 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
5224 Pre => Position = No_Element @key{or else}
5225 Has_Element (Container, Position)
5226 @key{or else raise} Program_Error,
5227 Post => (@key{if} Position = No_Element @key{then} Previous'Result = No_Element
5228 @key{elsif} Previous'Result = No_Element @key{then}
5229 Position = First (Container)
5230 @key{else} Has_Element (Container, Previous'Result));]}
5231
5232 @ChgRef{Version=[2],Kind=[AddedNormal]}
5233 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5234 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Previous} (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
5235 @key{with} Global => (@key{in all}, @key{use null}),
5236 Nonblocking => True],Old=[]};]}
5237
5238 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5239 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Previous} (Container : @key{in} List;
5240 Position : @key{in out} Cursor)
5241 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
5242 Pre => Position = No_Element @key{or else}
5243 Has_Element (Container, Position)
5244 @key{or else raise} Program_Error,
5245 Post => (@key{if} Position /= No_Element
5246 @key{then} Has_Element (Container, Position));]}
5247
5248 @ChgRef{Version=[2],Kind=[AddedNormal]}
5249 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5250 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : List;
5251 Item : Element_Type;
5252 Position : Cursor := No_Element)
5253 @key{return} Cursor@Chg{Version=[5],New=[
5254 @key{with} Pre => Position = No_Element @key{or else}
5255 Has_Element (Container, Position)
5256 @key{or else raise} Program_Error,
5257 Post => (@key{if} Find'Result = No_Element @key{then} True
5258 @key{else} Has_Element (Container, Find'Result))],Old=[]};]}
5259
5260 @ChgRef{Version=[2],Kind=[AddedNormal]}
5261 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5262 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Reverse_Find} (Container : List;
5263 Item : Element_Type;
5264 Position : Cursor := No_Element)
5265 @key{return} Cursor@Chg{Version=[5],New=[
5266 @key{with} Pre => Position = No_Element @key{or else}
5267 Has_Element (Container, Position)
5268 @key{or else raise} Program_Error,
5269 Post => (@key{if} Reverse_Find'Result = No_Element @key{then} True
5270 @key{else} Has_Element (Container, Reverse_Find'Result))],Old=[]};]}
5271
5272 @ChgRef{Version=[2],Kind=[AddedNormal]}
5273 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : List;
5274 Item : Element_Type) @key{return} Boolean;]}
5275
5276 @ChgRef{Version=[2],Kind=[AddedNormal]}
5277 @ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0212-1]}
5278 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]}]}
5279
5280 @ChgRef{Version=[2],Kind=[AddedNormal]}
5281 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5282 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Iterate}
5283 (Container : @key{in} List;
5284 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
5285 @key{with} Allows_Exit],Old=[]};]}
5286
5287 @ChgRef{Version=[2],Kind=[AddedNormal]}
5288 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5289 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reverse_Iterate}
5290 (Container : @key{in} List;
5291 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
5292 @key{with} Allows_Exit],Old=[]};]}
5293
5294 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
5295 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1],ARef=[AI12-0266-1]}
5296 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Iterate} (Container : @key[in] List)
5297 @key[return] List_Iterator_Interfaces.@Chg{Version=[5],New=[Parallel_Reversible_Iterator],Old=[Reversible_Iterator]}'Class@Chg{Version=[5],New=[
5298 @key[with] Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
5299
5300 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
5301 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5302 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Iterate} (Container : @key[in] List; Start : @key[in] Cursor)
5303 @key[return] List_Iterator_Interfaces.Reversible_Iterator'Class@Chg{Version=[5],New=[
5304 @key[with] Pre => (Start /= No_Element
5305 @key[or else raise] Constraint_Error) @key[and then]
5306 (Has_Element (Container, Start)
5307 @key[or else raise] Program_Error),
5308 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
5309
5310 @ChgRef{Version=[2],Kind=[AddedNormal]}
5311 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5312 @ChgAdded{Version=[2],Text=[ @key{generic}
5313 @key{with function} "<" (Left, Right : Element_Type)
5314 @key{return} Boolean is <>;
5315 @key{package} @AdaPackDefn{Generic_Sorting}@Chg{Version=[5],New=[
5316 @key{with} Nonblocking, Global => @key{null}],Old=[]} @key{is}]}
5317
5318 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5319 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Less_Element} (Left, Right : Element_Type) @key{return} Boolean
5320 @key{renames} "<";]}
5321
5322 @ChgRef{Version=[2],Kind=[AddedNormal]}
5323 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Sorted} (Container : List) @key{return} Boolean;]}
5324
5325 @ChgRef{Version=[2],Kind=[AddedNormal]}
5326 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5327 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Sort} (Container : @key{in out} List)@Chg{Version=[5],New=[
5328 @key{with} Pre => (@key{if} Tampering_With_Cursors_Prohibited (Container)
5329 @key{then raise} Program_Error)],Old=[]};]}
5330
5331 @ChgRef{Version=[2],Kind=[AddedNormal]}
5332 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5333 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Merge} (Target : @key{in out} List;
5334 Source : @key{in out} List)@Chg{Version=[5],New=[
5335 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
5336 @key{or else raise} Program_Error) @key{and then}
5337 (@key{not} Tampering_With_Elements_Prohibited (Source)
5338 @key{or else raise} Program_Error) @key{and then}
5339 (Length (Target) <= Maximum_Length - Length (Source)
5340 @key{or else raise} Constraint_Error),
5341 Post => (@key{declare}
5342 Result_Length : @key{constant} Count_Type :=
5343 Length (Source)'Old + Length (Target)'Old;
5344 @key{begin}
5345 (@key{if} Target = Source @key{then} True
5346 @key{else} Length (Source) = 0 @key{and then}
5347 Length (Target) = Result_Length))],Old=[]};]}
5348
5349 @ChgRef{Version=[2],Kind=[AddedNormal]}
5350 @ChgAdded{Version=[2],Text=[ @key{end} Generic_Sorting;]}
5351
5352 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5353 @ChgAdded{Version=[5],Text=[ @key{package} @AdaPackDefn{Stable} @key{is}]}
5354
5355 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1],ARef=[AI12-0339-1]}
5356 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{List} (Base : @key{not null access} Doubly_Linked_Lists.List) @key{is}
5357 @key{tagged limited private}
5358 @key{with} Constant_Indexing => Constant_Reference,
5359 Variable_Indexing => Reference,
5360 Default_Iterator => Iterate,
5361 Iterator_Element => Element_Type,
5362 Aggregate => (Empty => Empty,
5363 Add_Unnamed => Append),
5364 Stable_Properties => (Length),
5365 Global => @key{null},
5366 Default_Initial_Condition => Length (List) = 0;
5367 @key{pragma} Preelaborable_Initialization(List);]}
5368
5369 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5370 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private};
5371 @key{pragma} Preelaborable_Initialization(Cursor);]}
5372
5373 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5374 @ChgAdded{Version=[5],Text=[ @AdaObjDefn{Empty_List} : @key{constant} List;]}
5375
5376 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5377 @ChgAdded{Version=[5],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]}
5378
5379 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5380 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean
5381 @key{with} Nonblocking, Global => (@key{in all}, @key{use null});]}
5382
5383 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5384 @ChgAdded{Version=[5],Text=[ @key{package} @AdaPackDefn{List_Iterator_Interfaces} @key[is new]
5385 Ada.Iterator_Interfaces (Cursor, Has_Element);]}
5386
5387 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5388 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} Doubly_Linked_Lists.List;
5389 Source : @key{in} List)
5390 @key{with} Post => Length (Source) = Length (Target);]}
5391
5392 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5393 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Copy} (Source : Doubly_Linked_Lists.List) @key{return} List
5394 @key{with} Post => Length (Copy'Result) = Length (Source);]}
5395
5396 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5397 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Constant_Reference_Type}
5398 (Element : @key{not null access constant} Element_Type) @key{is private}
5399 @key{with} Implicit_Dereference => Element,
5400 Nonblocking, Global => (@key{null}, @key{use null}),
5401 Default_Initial_Condition => (@key{raise} Program_Error);]}
5402
5403 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5404 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Reference_Type}
5405 (Element : @key{not null access} Element_Type) @key{is private}
5406 @key{with} Implicit_Dereference => Element,
5407 Nonblocking, Global => (@key{null}, @key{use null}),
5408 Default_Initial_Condition => (@key{raise} Program_Error);]}
5409
5410 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5411 @ChgAdded{Version=[5],Text=[ -- @examcom{Additional subprograms as described in the text}
5412 -- @examcom{are declared here.}]}
5413
5414 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5415 @ChgAdded{Version=[5],Text=[ @key{private}]}
5416
5417 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5418 @ChgAdded{Version=[5],Text=[ ... -- @Examcom{not specified by the language}]}
5419
5420 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
5421 @ChgAdded{Version=[5],Text=[ @key{end} Stable;]}
5422
5423 @ChgRef{Version=[2],Kind=[AddedNormal]}
5424 @ChgAdded{Version=[2],Text=[@key{private}]}
5425
5426 @ChgRef{Version=[2],Kind=[AddedNormal]}
5427 @ChgAdded{Version=[2],Text=[ ... -- @RI[not specified by the language]]}
5428
5429 @ChgRef{Version=[2],Kind=[AddedNormal]}
5430 @ChgAdded{Version=[2],Text=[@key{end} Ada.Containers.Doubly_Linked_Lists;]}
5431
5432 @end{Example}
5433
5434 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5435 @ChgAdded{Version=[2],Text=[The actual function for the generic formal function
5436 "=" on Element_Type values is expected to define a reflexive and symmetric
5437 relationship and return the same result value each time it is called with a
5438 particular pair of values. If it behaves in some other manner, the functions
5439 Find, Reverse_Find, and "=" on list values return an unspecified value. The
5440 exact arguments and number of calls of this generic formal function by the
5441 functions Find, Reverse_Find, and "=" on list values are
5442 unspecified.@PDefn{unspecified}]}
5443
5444 @begin{Ramification}
5445 @ChgRef{Version=[2],Kind=[AddedNormal]}
5446 @ChgAdded{Version=[2],Text=[If the actual function for "=" is not symmetric
5447 and consistent, the result returned by the listed functions cannot be predicted.
5448 The implementation is not required to protect
5449 against "=" raising an exception, or returning random results, or any
5450 other @lquotes@;bad@rquotes behavior. And it can call "=" in whatever
5451 manner makes sense. But note that only the results of Find, Reverse_Find, and
5452 List "=" are unspecified; other subprograms are not allowed to break if "="
5453 is bad (they aren't expected to use "=").]}
5454 @end{Ramification}
5455
5456 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5457 @ChgAdded{Version=[2],Text=[The type List is used to represent lists. The type
5458 List needs finalization@PDefn2{Term=<needs finalization>,Sec=<language-defined type>}
5459 (see @RefSecNum{Assignment and Finalization}).]}
5460
5461 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5462 @ChgAdded{Version=[2],Text=[Empty_List represents the empty List object. It has
5463 a length of 0. If an object of type List is not otherwise initialized, it is
5464 initialized to the same value as Empty_List.]}
5465
5466 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5467 @ChgAdded{Version=[2],Text=[No_Element represents a cursor that designates no
5468 element. If an object of type Cursor is not otherwise initialized, it is
5469 initialized to the same value as No_Element.]}
5470
5471 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5472 @ChgAdded{Version=[2],Text=[The predefined "=" operator for type Cursor returns
5473 True if both cursors are No_Element, or designate the same element in the same
5474 container.]}
5475
5476 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5477 @ChgAdded{Version=[2],Text=[Execution of the default implementation of the
5478 Input, Output, Read, or Write attribute of type Cursor raises Program_Error.]}
5479
5480 @begin{Reason}
5481 @ChgRef{Version=[2],Kind=[AddedNormal]}
5482 @ChgAdded{Version=[2],Text=[A cursor will probably be implemented in terms
5483 of one or more access values, and the effects of streaming access values is
5484 unspecified. Rather than letting the user stream junk by accident, we mandate
5485 that streaming of cursors raise Program_Error by default. The attributes
5486 can always be specified if there is a need to support streaming.]}
5487 @end{Reason}
5488
5489 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]}
5490 @ChgAdded{Version=[3],Text=[List'Write for a List object @i<L> writes
5491 Length(@i<L>) elements of the list to the stream. It also may write
5492 additional information about the list.]}
5493
5494 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]}
5495 @ChgAdded{Version=[3],Text=[List'Read reads the representation of a list
5496 from the stream, and assigns to @i<Item> a list with the same length and
5497 elements as was written by List'Write.]}
5498
5499 @begin{Ramification}
5500 @ChgRef{Version=[3],Kind=[AddedNormal]}
5501 @ChgAdded{Version=[3],Text=[Streaming more elements than the container
5502 length is wrong. For implementation implications of this rule, see the Implementation Note in
5503 @RefSecNum{The Generic Package Containers.Vectors}.]}
5504 @end{Ramification}
5505
5506 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5507 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
5508 @ChgAdded{Version=[2],Text=[@Redundant[Some
5509 operations @Chg{Version=[5],New=[@Defn2{Term=[tamper with cursors],Sec=[of a list]}@Defn2{Term=[tamper with elements],Sec=[of a list]}],Old=[of
5510 this generic package have access-to-subprogram parameters. To
5511 ensure such operations are well-defined, they guard against certain actions by
5512 the designated subprogram. In particular, some operations]} check for
5513 @lquotes@;tampering with cursors@rquotes of a container because they depend on
5514 the set of elements of the container remaining constant, and others check for
5515 @lquotes@;tampering with elements@rquotes of a container because they depend on
5516 elements of the container not being replaced.]@Chg{Version=[5],New=[ When
5517 tampering with cursors is @i<prohibited>@Defn2{Term=[prohibited],Sec=[tampering with a list]}
5518 @Defn2{Term=[tampering],Sec=[prohibited for a list]}for a particular
5519 list object @i<L>, Program_Error is propagated by the finalization
5520 of @i<L>@Redundant[, as well as by a call that passes @i<L> to
5521 certain of the operations of this package, as indicated by the precondition
5522 of such an operation]. Similarly, when tampering with elements is @i<prohibited>
5523 for @i<L>, Program_Error is propagated by a call that passes @i<L> to
5524 certain of other operations of this package, as indicated by the precondition
5525 of such an operation.],Old=[]}]}
5526
5527 @begin{NotIso}
5528 @ChgAdded{Version=[5],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 62 through 69
5529 are removed as preconditions now describe these rules.>}]}@Comment{This message should be
5530 deleted if the paragraphs are ever renumbered.}
5531 @end{NotIso}
5532
5533 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5534 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
5535 @ChgDeleted{Version=[5],Type=[Leading],Text=[@Chg{Version=[2],New=[@Defn2{Term=[tamper with cursors],Sec=[of a list]}
5536 A subprogram is said to
5537 @i{tamper with cursors} of a list object @i<L> if:],Old=[]}]}
5538
5539 @begin{Itemize}
5540 @ChgRef{Version=[2],Kind=[AddedNormal]}
5541 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
5542 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
5543 inserts or deletes elements of @i<L>, that is,
5544 it calls the Insert, Clear, Delete, or Delete_Last procedures with @i<L> as a
5545 parameter; or]}]}
5546
5547 @begin{Honest}
5548 @ChgRef{Version=[2],Kind=[AddedNormal]}
5549 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
5550 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[Operations which
5551 are defined to be equivalent to
5552 a call on one of these operations also are included. Similarly, operations
5553 which call one of these as part of their definition are included.]}]}
5554 @end{Honest}
5555
5556 @ChgRef{Version=[2],Kind=[AddedNormal]}
5557 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
5558 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
5559 reorders the elements of @i<L>, that is, it
5560 calls the Splice, Swap_Links, or Reverse_Elements procedures or the Sort or
5561 Merge procedures of an instance of Generic_Sorting with @i<L> as a parameter;
5562 or]}]}
5563
5564 @ChgRef{Version=[2],Kind=[AddedNormal]}
5565 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
5566 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
5567 finalizes @i<L>; or]}]}
5568
5569 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
5570 @ChgRef{Version=[5],Kind=[DeletedAddedNoDelMsg]}
5571 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[it
5572 calls the Assign procedure with @i<L> as the Target parameter; or]}]}
5573
5574 @begin{Ramification}
5575 @ChgRef{Version=[3],Kind=[Added]}
5576 @ChgAdded{Version=[3],Text=[We don't need to explicitly mention
5577 @nt{assignment_statement}, because that finalizes the target object
5578 as part of the operation, and finalization of an object is already defined
5579 as tampering with cursors.]}
5580 @end{Ramification}
5581
5582 @ChgRef{Version=[2],Kind=[AddedNormal]}
5583 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
5584 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
5585 calls the Move procedure with @i<L> as a parameter.]}]}
5586
5587 @begin{Reason}
5588 @ChgRef{Version=[2],Kind=[AddedNormal]}
5589 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
5590 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[Swap copies
5591 elements rather than reordering them, so it doesn't tamper with cursors.]}]}
5592 @end{Reason}
5593 @end{Itemize}
5594
5595 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5596 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
5597 @ChgDeleted{Version=[5],Type=[Leading],Text=[@Chg{Version=[2],New=[@Defn2{Term=[tamper with elements],Sec=[of a list]}
5598 A subprogram is said to @i{tamper with elements} of a list
5599 object @i<L> if:],Old=[]}]}
5600
5601 @begin{Itemize}
5602 @ChgRef{Version=[2],Kind=[AddedNormal]}
5603 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
5604 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
5605 tampers with cursors of @i<L>; or]}]}
5606
5607 @ChgRef{Version=[2],Kind=[AddedNormal]}
5608 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
5609 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
5610 replaces one or more elements of @i<L>, that is, it calls the Replace_Element or
5611 Swap procedures with @i<L> as a parameter.]}]}
5612
5613 @begin{Reason}
5614 @ChgRef{Version=[2],Kind=[AddedNormal]}
5615 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
5616 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[Complete
5617 replacement of an element can cause its memory to be deallocated while another
5618 operation is holding onto a reference to it. That can't be allowed. However, a
5619 simple modification of (part of) an element is not a problem, so
5620 Update_Element does not cause a problem.]}]}
5621 @end{Reason}
5622
5623 @end{Itemize}
5624
5625 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0265-1]}
5626 @ChgRef{Version=[4],Kind=[RevisedAdded],ARef=[AI12-0110-1]}
5627 @ChgRef{Version=[5],Kind=[DeletedAddedNoDelMsg],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
5628 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[@Defn2{Term=[prohibited],Sec=[tampering with a list]}
5629 @Defn2{Term=[tampering],Sec=[prohibited for a list]}
5630 When tampering with cursors is @i<prohibited> for a particular list object
5631 @i<L>, Program_Error is propagated by a call of any language-defined subprogram
5632 that is defined to tamper with the cursors of @i<L>, leaving @i<L> unmodified.
5633 Similarly, when tampering with elements is @i<prohibited> for a particular list
5634 object @i<L>, Program_Error is propagated by a call of any language-defined
5635 subprogram that is defined to tamper with the elements of @i<L> @Redundant[(or
5636 tamper with the cursors of @i<L>)], leaving @i<L>
5637 unmodified.@Chg{Version=[4],New=[ These checks are made before any other
5638 defined behavior of the body of the language-defined subprogram.],Old=[]}]}]}
5639 @begin{TheProof}
5640 @ChgRef{Version=[3],Kind=[AddedNormal]}
5641 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
5642 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[Tampering
5643 with elements includes tampering with
5644 cursors, so we mention it only from completeness in the second sentence.]}]}
5645 @end{TheProof}
5646
5647 @begin{DescribeCode}
5648
5649 @begin{Example}
5650 @ChgRef{Version=[3],Kind=[Added]}
5651 @ChgRef{Version=[5],Kind=[RevisedAdded]}
5652 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
5653 @key[with] Nonblocking, Global => (@key{in all}, @key{use null})],Old=[]};]}
5654 @end{Example}
5655
5656 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
5657 @ChgAdded{Version=[3],Type=[Trailing],Text=[Returns True if Position designates
5658 an element, and returns False otherwise.]}
5659
5660 @begin{Honest}
5661 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1],ARef=[AI05-0212-1]}
5662 @ChgAdded{Version=[3],Text=[This function might not detect cursors that
5663 designate deleted elements; such cursors are invalid (see below) and the
5664 result of calling Has_Element with an invalid cursor is unspecified (but
5665 not erroneous).]}
5666 @end{Honest}
5667
5668 @begin{Example}
5669 @ChgRef{Version=[5],Kind=[Added]}
5670 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} @AdaSubDefn{Has_Element} (Container : List; Position : Cursor)
5671 @key{return} Boolean
5672 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
5673 @end{Example}
5674
5675 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5676 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns True if Position designates
5677 an element in Container, and returns False otherwise.]}
5678
5679 @begin{Ramification}
5680 @ChgRef{Version=[5],Kind=[AddedNormal]}
5681 @ChgAdded{Version=[5],Text=[If Position is No_Element, Has_Element returns False.]}
5682 @end{Ramification}
5683
5684 @begin{Example}
5685 @ChgRef{Version=[2],Kind=[AddedNormal]}
5686 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "=" (Left, Right : List) @key{return} Boolean;]}
5687 @end{Example}
5688
5689 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5690 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5691 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Left and Right denote the same
5692 list object, then the function returns True. If Left and Right have different
5693 lengths, then the function returns False.
5694 Otherwise, it compares each element in Left to
5695 the corresponding element in Right using the generic formal equality operator.
5696 If any such comparison returns False, the function returns False;
5697 otherwise@Chg{Version=[3],New=[,],Old=[]} it
5698 returns True. Any exception raised during
5699 evaluation of element equality is propagated.]}
5700 @begin{ImplNote}
5701 @ChgRef{Version=[2],Kind=[AddedNormal]}
5702 @ChgAdded{Version=[2],Text=[This wording describes the canonical semantics.
5703 However, the order and number of calls on the formal equality function is
5704 unspecified for all of the operations that use it in this package, so an
5705 implementation can call it as many or as few times as it needs to get the
5706 correct answer. Specifically, there is no requirement to call the formal
5707 equality additional times once the answer has been determined.]}
5708 @end{ImplNote}
5709
5710 @begin{Example}
5711 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5712 @ChgAdded{Version=[5],Text=[@key{function} Same_Object (Left, Right : List) @key{return} Boolean
5713 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
5714 @end{Example}
5715
5716 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5717 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns True if Left and Right
5718 denote the same list object, and returns False otherwise.]}
5719
5720 @begin{ImplNote}
5721 @ChgRef{Version=[5],Kind=[AddedNormal]}
5722 @ChgAdded{Version=[5],Text=[This can be implemented by comparing object
5723 addresses or identifiers (if available). The elements stored in the
5724 containers should not be compared.]}
5725 @end{ImplNote}
5726
5727 @begin{Example}
5728 @ChgRef{Version=[5],Kind=[Added]}
5729 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Tampering_With_Cursors_Prohibited
5730 (Container : List) @key{return} Boolean
5731 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
5732 @end{Example}
5733
5734 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5735 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns True if tampering with
5736 cursors or tampering with elements is currently prohibited for Container, and
5737 returns False otherwise.]}
5738
5739 @begin{Reason}
5740 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
5741 @ChgAdded{Version=[5],Text=[Prohibiting tampering with elements also
5742 needs to prohibit tampering with cursors, as deleting an element is similar
5743 to replacing it.]}
5744 @end{Reason}
5745
5746 @begin{ImplNote}
5747 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
5748 @ChgAdded{Version=[5],Text=[Various contracts elsewhere in this specification
5749 require that this function is implemented with synchronized data. Moreover,
5750 it is possible for tampering to be prohibited by multiple operations
5751 (sequentiually or in parallel). Therefore, tampering needs to be
5752 implemented with an atomic or protected counter. The counter is initialized
5753 to zero, and is incremented when tampering is prohibited, and decremented
5754 when leaving an area that prohibited tampering. Function
5755 Tampering_With_Cursors_Prohibited returns True if the counter is nonzero.
5756 (Note that any case where the result is not well-defined for one task
5757 is incorrect use of shared variables and would be erroneous by the rules
5758 of @RefSecNum{Shared Variables}, so no special protection is needed to
5759 read the counter.)]}
5760 @end{ImplNote}
5761
5762 @begin{Example}
5763 @ChgRef{Version=[5],Kind=[Added]}
5764 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Tampering_With_Elements_Prohibited
5765 (Container : List) @key{return} Boolean
5766 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
5767 @end{Example}
5768
5769 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5770 @ChgAdded{Version=[5],Type=[Trailing],Text=[Always returns False@Redundant[,
5771 regardless of whether tampering with elements is prohibited].]}
5772
5773 @begin{Reason}
5774 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1]}
5775 @ChgAdded{Version=[5],Text=[A definite element cannot
5776 change size, so we allow operations that tamper with elements even when
5777 tampering with elements is prohibited. That's not true for the indefinite
5778 containers, which is why this kind of tampering exists.]}
5779 @end{Reason}
5780
5781 @begin{Example}
5782 @ChgRef{Version=[2],Kind=[AddedNormal]}
5783 @ChgRef{Version=[5],Kind=[Revised]}
5784 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Length (Container : List) @key{return} Count_Type@Chg{Version=[5],New=[
5785 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
5786 @end{Example}
5787
5788 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5789 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the number of elements in
5790 Container.]}
5791
5792 @begin{Example}
5793 @ChgRef{Version=[2],Kind=[AddedNormal]}
5794 @ChgRef{Version=[5],Kind=[Revised]}
5795 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Is_Empty (Container : List) @key{return} Boolean@Chg{Version=[5],New=[
5796 @key[with] Nonblocking, Global => (@key[null], @key[use null]),
5797 Post => Is_Empty'Result = (Length (Container) = 0)],Old=[]};]}
5798 @end{Example}
5799
5800 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5801 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5802 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[Returns True
5803 if Container is empty],Old=[Equivalent to Length (Container) = 0]}.]}
5804
5805 @begin{Example}
5806 @ChgRef{Version=[2],Kind=[AddedNormal]}
5807 @ChgRef{Version=[5],Kind=[Revised]}
5808 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Clear (Container : @key{in out} List)@Chg{Version=[5],New=[
5809 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
5810 @key[or else raise] Program_Error,
5811 Post => Length (Container) = 0],Old=[]};]}
5812 @end{Example}
5813
5814 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5815 @ChgAdded{Version=[2],Type=[Trailing],Text=[Removes all the elements from
5816 Container.]}
5817
5818 @begin{Example}
5819 @ChgRef{Version=[2],Kind=[AddedNormal]}
5820 @ChgRef{Version=[5],Kind=[Revised]}
5821 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Element (Position : Cursor) @key{return} Element_Type@Chg{Version=[5],New=[
5822 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
5823 Nonblocking => Element_Type'Nonblocking,
5824 Global => (@key{in all}, @key{use} Element_Type)],Old=[]};]}
5825 @end{Example}
5826
5827 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5828 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5829 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
5830 Position equals No_Element, then Constraint_Error is propagated. Otherwise,
5831 ]}Element returns the element designated by Position.]}
5832
5833 @begin{Example}
5834 @ChgRef{Version=[5],Kind=[Added]}
5835 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Element (Container : List;
5836 Position : Cursor) @key{return} Element_Type
5837 @key{with} Pre => (Position /= No_Element @key{or else}
5838 @key{raise} Constraint_Error) @key{and then}
5839 (Has_Element (Container, Position) @key{or else raise} Program_Error),
5840 Nonblocking => Element_Type'Nonblocking,
5841 Global => (@key{null}, @key{use} Element_Type);]}
5842 @end{Example}
5843
5844 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5845 @ChgAdded{Version=[5],Type=[Trailing],Text=[Element returns the element
5846 designated by Position in Container.]}
5847
5848 @begin{Example}
5849 @ChgRef{Version=[2],Kind=[AddedNormal]}
5850 @ChgRef{Version=[5],Kind=[Revised]}
5851 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace_Element (Container : @key{in out} List;
5852 Position : @key{in} Cursor;
5853 New_item : @key{in} Element_Type)@Chg{Version=[5],New=[
5854 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
5855 @key{or else raise} Program_Error) @key{and then}
5856 (Position /= No_Element
5857 @key{or else raise} Constraint_Error) @key{and then}
5858 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
5859 @end{Example}
5860
5861 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5862 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
5863 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1],ARef=[AI12-0196-1]}
5864 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
5865 Position equals No_Element,
5866 then Constraint_Error is propagated; if Position does not designate an element
5867 in Container, then Program_Error is propagated.
5868 Otherwise@Chg{Version=[3],New=[,],Old=[]} ]}Replace_Element
5869 assigns the value New_Item to the element designated by
5870 Position.@Chg{Version=[5],New=[ For the purposes of
5871 determining whether the parameters overlap in a call to Replace_Element, the
5872 Container parameter is not considered to overlap with any object
5873 @Redundant[(including itself)].],Old=[]}]}
5874
5875 @begin{Example}
5876 @ChgRef{Version=[2],Kind=[AddedNormal]}
5877 @ChgRef{Version=[5],Kind=[Revised]}
5878 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Query_Element
5879 (Position : @key{in} Cursor;
5880 Process : @key{not null access procedure} (Element : @key{in} Element_Type))@Chg{Version=[5],New=[
5881 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
5882 Global => @key{in all}],Old=[]};]}
5883 @end{Example}
5884
5885 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5886 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1],ARef=[AI05-0265-1]}
5887 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5888 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
5889 Position equals No_Element, then
5890 Constraint_Error is propagated. Otherwise, ]}Query_Element calls
5891 Process.@key{all} with the element designated by Position as the argument.
5892 @Chg{Version=[3],New=[Tampering],Old=[Program_Error
5893 is propagated if Process.@key{all} tampers]}
5894 with the elements of @Chg{Version=[3],New=[the list that contains the
5895 element designated by Position is prohibited during the
5896 execution of the call on Process.@key{all}],Old=[Container]}. Any exception
5897 raised by Process.@key{all} is propagated.]}
5898
5899 @begin{Example}
5900 @ChgRef{Version=[5],Kind=[Added]}
5901 @ChgAdded{Version=[5],Text=[@key{procedure} Query_Element
5902 (Container : @key{in} List;
5903 Position : @key{in} Cursor;
5904 Process : @key{not null access procedure} (Element : @key{in} Element_Type))
5905 @key{with} Pre => (Position /= No_Element
5906 @key{or else raise} Constraint_Error) @key{and then}
5907 (Has_Element (Container, Position)
5908 @key{or else raise} Program_Error);]}
5909 @end{Example}
5910
5911 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5912 @ChgAdded{Version=[5],Type=[Trailing],Text=[Query_Element calls Process.@key{all}
5913 with the element designated by Position as the
5914 argument. Tampering with the elements of Container
5915 is prohibited during the execution of the call on
5916 Process.@key{all}. Any exception raised by Process.@key{all} is propagated.]}
5917
5918 @begin{Example}
5919 @ChgRef{Version=[2],Kind=[AddedNormal]}
5920 @ChgRef{Version=[5],Kind=[Revised]}
5921 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Update_Element
5922 (Container : @key{in out} List;
5923 Position : @key{in} Cursor;
5924 Process : @key{not null access procedure}
5925 (Element : @key{in out} Element_Type))@Chg{Version=[5],New=[
5926 @key{with} Pre => (Position /= No_Element @key{or else raise} Constraint_Error) @key{and then}
5927 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
5928 @end{Example}
5929
5930 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5931 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1],ARef=[AI05-0265-1]}
5932 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5933 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[If
5934 Position equals No_Element, then
5935 Constraint_Error is propagated; if Position does not designate an element in
5936 Container, then Program_Error is propagated.
5937 Otherwise@Chg{Version=[3],New=[,],Old=[]} ]}Update_Element calls
5938 Process.@key{all} with the element designated by Position as the
5939 argument. @Chg{Version=[3],New=[Tampering],Old=[Program_Error
5940 is propagated if Process.@key{all} tampers]}
5941 with the elements of Container@Chg{Version=[3],New=[ is prohibited during the
5942 execution of the call on Process.@key{all}],Old=[]}. Any exception raised by
5943 Process.@key{all} is propagated.]}
5944
5945 @ChgRef{Version=[2],Kind=[AddedNormal]}
5946 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Element_Type is unconstrained
5947 and definite, then the actual Element parameter of Process.@key{all} shall be
5948 unconstrained.]}
5949
5950 @begin{Ramification}
5951 @ChgRef{Version=[2],Kind=[AddedNormal]}
5952 @ChgAdded{Version=[2],Text=[This means that the elements cannot be directly
5953 allocated from the heap; it must be possible to change the discriminants of
5954 the element in place.]}
5955 @end{Ramification}
5956
5957 @begin{Example}
5958 @ChgRef{Version=[3],Kind=[Added]}
5959 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5960 @ChgAdded{Version=[3],Text=[@key[type] Constant_Reference_Type
5961 (Element : @key[not null access constant] Element_Type) @key[is private]
5962 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
5963 Nonblocking, Global => @key[in out synchronized],
5964 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
5965
5966 @ChgRef{Version=[3],Kind=[Added]}
5967 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5968 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[type] Reference_Type (Element : @key[not null access] Element_Type) @key[is private]
5969 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
5970 Nonblocking, Global => @key[in out synchronized],
5971 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
5972 @end{Example}
5973
5974 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
5975 @ChgAdded{Version=[3],Type=[Trailing],Text=[The types Constant_Reference_Type
5976 and Reference_Type need finalization.@PDefn2{Term=<needs finalization>,
5977 Sec=<language-defined type>}]}
5978
5979 @ChgRef{Version=[3],Kind=[Added]}
5980 @ChgRef{Version=[5],Kind=[DeletedAdded],ARef=[AI12-0112-1]}
5981 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[The default
5982 initialization of an object of type
5983 Constant_Reference_Type or Reference_Type propagates Program_Error.]}]}
5984
5985 @begin{Reason}
5986 @ChgRef{Version=[3],Kind=[AddedNormal]}
5987 @ChgAdded{Version=[3],Text=[It is expected that Reference_Type (and
5988 Constant_Reference_Type) will be a controlled type, for which finalization
5989 will have some action to terminate the tampering check for the associated
5990 container. If the object is created by default, however, there is no
5991 associated container. Since this is useless, and supporting this case would
5992 take extra work, we define it to raise an exception.]}
5993 @end{Reason}
5994
5995 @begin{Example}
5996 @ChgRef{Version=[3],Kind=[Added]}
5997 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5998 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] List;
5999 Position : @key[in] Cursor)
6000 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
6001 @key[with] Pre => (Position /= No_Element @key[or else]
6002 @key[raise] Constraint_Error) @key[and then]
6003 (Has_Element (Container, Position) @key[or else raise] Program_Error),
6004 Post => Tampering_With_Cursors_Prohibited (Container),
6005 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
6006 @end{Example}
6007
6008 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
6009 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
6010 Constant_Indexing and Implicit_Dereference aspects) provides a convenient way to
6011 gain read access to an individual element of a list given a
6012 cursor.]}
6013
6014 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]}
6015 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6016 @ChgAdded{Version=[3],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
6017 Position equals No_Element, then Constraint_Error
6018 is propagated; if Position does not designate an element in Container, then
6019 Program_Error is propagated. Otherwise, ]}Constant_Reference returns an object
6020 whose discriminant is an access value that designates the element designated by
6021 Position. Tampering with the elements of Container is prohibited while the
6022 object returned by Constant_Reference exists and has not been finalized.]}
6023
6024 @begin{Example}
6025 @ChgRef{Version=[3],Kind=[Added]}
6026 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6027 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference (Container : @key[aliased in out] List;
6028 Position : @key[in] Cursor)
6029 @key[return] Reference_Type@Chg{Version=[5],New=[
6030 @key[with] Pre => (Position /= No_Element @key[or else]
6031 @key[raise] Constraint_Error) @key[and then]
6032 (Has_Element (Container, Position) @key[or else raise] Program_Error),
6033 Post => Tampering_With_Cursors_Prohibited (Container),
6034 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
6035 @end{Example}
6036
6037 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
6038 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
6039 Variable_Indexing and Implicit_Dereference aspects) provides a convenient way to
6040 gain read and write access to an individual element of a list given
6041 a cursor.]}
6042
6043 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]}
6044 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6045 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[If
6046 Position equals No_Element, then Constraint_Error
6047 is propagated; if Position does not designate an element in Container, then
6048 Program_Error is propagated. Otherwise, ]}Reference returns an object whose
6049 discriminant is an access value that designates the element designated by
6050 Position. Tampering with the elements of Container is prohibited while the
6051 object returned by Reference exists and has not been finalized.]}
6052
6053 @begin{Example}
6054 @ChgRef{Version=[3],Kind=[Added]}
6055 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6056 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key{procedure} Assign (Target : @key{in out} List; Source : @key{in} List)@Chg{Version=[5],New=[
6057 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Target)
6058 @key[or else raise] Program_Error,
6059 Post => Length (Source) = Length (Target)],Old=[]};]}
6060 @end{Example}
6061
6062 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0248-1]}
6063 @ChgAdded{Version=[3],Type=[Trailing],Text=[If Target denotes the same object as
6064 Source, the operation has no effect. Otherwise, the elements of Source are
6065 copied to Target as for an @nt{assignment_statement} assigning Source to
6066 Target.]}
6067 @begin{Discussion}
6068 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1]}
6069 @ChgAdded{Version=[3],Text=[This routine exists for compatibility with the
6070 bounded list container. For an unbounded list, @exam{Assign(A, B)} and
6071 @exam{A := B} behave identically. For a bounded list, := will raise an
6072 exception if the container capacities are different, while Assign will
6073 not raise an exception if there is enough room in the target.]}
6074 @end{Discussion}
6075
6076 @begin{Example}
6077 @ChgRef{Version=[3],Kind=[Added]}
6078 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6079 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key{function} Copy (Source : List)
6080 @key[return] List@Chg{Version=[5],New=[
6081 @key[with] Post => Length (Copy'Result) = Length (Source) @key[and then]
6082 @key[not] Tampering_With_Elements_Prohibited (Copy'Result) @key[and then]
6083 @key[not] Tampering_With_Cursors_Prohibited (Copy'Result)],Old=[]};]}
6084 @end{Example}
6085
6086 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
6087 @ChgAdded{Version=[3],Type=[Trailing],Text=[Returns a list whose elements match
6088 the elements of Source.]}
6089
6090 @begin{Example}
6091 @ChgRef{Version=[2],Kind=[AddedNormal]}
6092 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6093 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Move (Target : @key{in out} List;
6094 Source : @key{in out} List)@Chg{Version=[5],New=[
6095 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
6096 @key{or else raise} Program_Error) @key{and then}
6097 (@key{not} Tampering_With_Cursors_Prohibited (Source)
6098 @key{or else raise} Program_Error),
6099 Post => (@key{if} Same_Object (Target, Source) @key{then} True
6100 @key{else}
6101 Length (Target) = Length (Source'Old) @key{and then}
6102 Length (Source) = 0)],Old=[]};]}
6103 @end{Example}
6104
6105 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6106 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0262-1]}
6107 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Target denotes the same object
6108 as Source, then @Chg{Version=[3],New=[the operation],Old=[Move]}
6109 has no effect. Otherwise, @Chg{Version=[3],New=[the operation is equivalent
6110 to Assign (Target, Source) followed by Clear (Source)],Old=[Move first calls Clear
6111 (Target). Then, the nodes in Source are moved to Target (in the original order).
6112 The length of Target is set to the length of Source, and the length of Source is
6113 set to 0]}.]}
6114
6115 @begin{Example}
6116 @ChgRef{Version=[2],Kind=[AddedNormal]}
6117 @ChgRef{Version=[5],Kind=[Revised]}
6118 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} List;
6119 Before : @key{in} Cursor;
6120 New_Item : @key{in} Element_Type;
6121 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
6122 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
6123 @key{or else raise} Program_Error) @key{and then}
6124 (Before = No_Element @key{or else}
6125 Has_Element (Container, Before)
6126 @key{or else raise} Program_Error) @key{and then}
6127 (Length (Container) <= Count_Type'Last - Count
6128 @key{or else raise} Constraint_Error),
6129 Post => Length (Container)'Old + Count = Length (Container)],Old=[]};]}
6130 @end{Example}
6131
6132 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6133 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6134 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
6135 Before is not No_Element, and does not designate an element in Container,
6136 then Program_Error is propagated. Otherwise,
6137 ]}Insert inserts Count copies of New_Item prior to the element designated by
6138 Before. If Before equals No_Element, the new elements are inserted after the
6139 last node (if any). Any exception raised during allocation of internal storage
6140 is propagated, and Container is not modified.]}
6141
6142 @begin{Ramification}
6143 @ChgRef{Version=[2],Kind=[AddedNormal]}
6144 @ChgAdded{Version=[2],Text=[The check on Before checks that the cursor does
6145 not belong to some other Container. This check implies that a reference to
6146 the container is included in the cursor value. This wording is not meant to
6147 require detection of dangling cursors; such cursors are defined to be
6148 invalid, which means that execution is erroneous, and any result is allowed
6149 (including not raising an exception).]}
6150 @end{Ramification}
6151
6152 @begin{Example}
6153 @ChgRef{Version=[2],Kind=[AddedNormal]}
6154 @ChgRef{Version=[5],Kind=[Revised]}
6155 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} List;
6156 Before : @key{in} Cursor;
6157 New_Item : @key{in} Element_Type;
6158 Position : @key{out} Cursor;
6159 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
6160 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
6161 @key{or else raise} Program_Error) @key{and then}
6162 (Before = No_Element @key{or else}
6163 Has_Element (Container, Before)
6164 @key{or else raise} Program_Error) @key{and then}
6165 (Length (Container) <= Count_Type'Last - Count
6166 @key{or else raise} Constraint_Error),
6167 Post => Length (Container)'Old + Count = Length (Container)
6168 @key{and then} Has_Element (Container, Position)],Old=[]};]}
6169 @end{Example}
6170
6171 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6172 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0257-1]}
6173 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6174 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
6175 Before is not No_Element, and does not designate an element in Container,
6176 then Program_Error is propagated. Otherwise,
6177 ]}Insert allocates Count copies of New_Item, and inserts them prior to the
6178 element designated by Before. If Before equals No_Element, the new elements are
6179 inserted after the last element (if any). Position designates the first
6180 newly-inserted element@Chg{Version=[3],New=[, or if Count equals 0,
6181 then Position is assigned the value of Before],Old=[]}. Any exception raised
6182 during allocation of internal
6183 storage is propagated, and Container is not modified.]}
6184
6185 @begin{Example}
6186 @ChgRef{Version=[2],Kind=[AddedNormal]}
6187 @ChgRef{Version=[5],Kind=[Revised]}
6188 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} List;
6189 Before : @key{in} Cursor;
6190 Position : @key{out} Cursor;
6191 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
6192 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
6193 @key{or else raise} Program_Error) @key{and then}
6194 (Before = No_Element @key{or else}
6195 Has_Element (Container, Before)
6196 @key{or else raise} Program_Error) @key{and then}
6197 (Length (Container) <= Count_Type'Last - Count
6198 @key{or else raise} Constraint_Error),
6199 Post => Length (Container)'Old + Count = Length (Container)
6200 @key{and then} Has_Element (Container, Position)],Old=[]};]}
6201 @end{Example}
6202
6203 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6204 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0257-1]}
6205 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6206 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
6207 Before is not No_Element, and does not designate an element in Container,
6208 then Program_Error is propagated. Otherwise,
6209 ]}Insert inserts Count new elements prior to the element designated by Before.
6210 If Before equals No_Element, the new elements are inserted after the last node
6211 (if any). The new elements are initialized by default (see
6212 @RefSecNum{Object Declarations}). @Chg{Version=[3],New=[Position designates the
6213 first newly-inserted element, or if Count equals 0,
6214 then Position is assigned the value of Before],Old=[]}. Any exception raised
6215 during allocation of internal storage is propagated, and Container is not
6216 modified.]}
6217
6218 @begin{Example}
6219 @ChgRef{Version=[2],Kind=[AddedNormal]}
6220 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6221 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Prepend (Container : @key{in out} List;
6222 New_Item : @key{in} Element_Type;
6223 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
6224 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
6225 @key{or else raise} Program_Error) @key{and then}
6226 (Length (Container) <= Count_Type'Last - Count
6227 @key{or else raise} Constraint_Error),
6228 Post => Length (Container)'Old + Count = Length (Container)],Old=[]};]}
6229 @end{Example}
6230
6231 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6232 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container,
6233 First (Container), New_Item, Count).]}
6234
6235 @begin{Example}
6236 @ChgRef{Version=[2],Kind=[AddedNormal]}
6237 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6238 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Append (Container : @key{in out} List;
6239 New_Item : @key{in} Element_Type;
6240 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
6241 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
6242 @key{or else raise} Program_Error) @key{and then}
6243 (Length (Container) <= Count_Type'Last - Count
6244 @key{or else raise} Constraint_Error),
6245 Post => Length (Container)'Old + Count = Length (Container)],Old=[]};]}
6246 @end{Example}
6247
6248 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6249 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container,
6250 No_Element, New_Item, Count).]}
6251
6252 @begin{Example}
6253 @ChgRef{Version=[2],Kind=[AddedNormal]}
6254 @ChgRef{Version=[5],Kind=[Revised]}
6255 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} List;
6256 Position : @key{in out} Cursor;
6257 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
6258 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
6259 @key{or else raise} Program_Error) @key{and then}
6260 (Position /= No_Element
6261 @key{or else raise} Constraint_Error) @key{and then}
6262 (Has_Element (Container, Position)
6263 @key{or else raise} Program_Error),
6264 Post => Length (Container)'Old - Count <= Length (Container)
6265 @key{and then} Position = No_Element],Old=[]};]}
6266 @end{Example}
6267
6268 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6269 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
6270 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6271 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
6272 Position equals No_Element, then
6273 Constraint_Error is propagated. If Position does not designate an element in
6274 Container, then Program_Error is propagated.
6275 Otherwise@Chg{Version=[3],New=[,],Old=[]} ]}Delete removes (from
6276 Container) Count elements starting at the element designated by Position (or
6277 all of the elements starting at Position if there are fewer than Count elements
6278 starting at Position). Finally, Position is set to No_Element.]}
6279
6280 @begin{Example}
6281 @ChgRef{Version=[2],Kind=[AddedNormal]}
6282 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6283 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_First (Container : @key{in out} List;
6284 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
6285 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
6286 @key{or else raise} Program_Error,
6287 Post => Length (Container)'Old - Count <= Length (Container)],Old=[]};]}
6288 @end{Example}
6289
6290 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6291 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1]}
6292 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[If Length
6293 (Container) <= Count, then Delete_First is equivalent to Clear (Container).
6294 Otherwise, it removes the first Count nodes from Container],Old=[Equivelent to
6295 Delete (Container, First (Container), Count)]}.]}
6296
6297 @begin{Example}
6298 @ChgRef{Version=[2],Kind=[AddedNormal]}
6299 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6300 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_Last (Container : @key{in out} List;
6301 Count : @key{in} Count_Type := 1)@Chg{Version=[5],New=[
6302 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
6303 @key{or else raise} Program_Error,
6304 Post => Length (Container)'Old - Count <= Length (Container)],Old=[]};]}
6305 @end{Example}
6306
6307 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6308 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
6309 @ChgAdded{Version=[2],Type=[Trailing],Text=[If
6310 Length (Container) <= Count@Chg{Version=[3],New=[,],Old=[]} then
6311 Delete_Last is equivalent to Clear (Container).
6312 Otherwise@Chg{Version=[3],New=[,],Old=[]} it removes the last
6313 Count nodes from Container.]}
6314
6315
6316 @begin{Example}
6317 @ChgRef{Version=[2],Kind=[AddedNormal]}
6318 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6319 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reverse_Elements (Container : @key{in out} List)@Chg{Version=[5],New=[
6320 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
6321 @key{or else raise} Program_Error],Old=[]};]}
6322 @end{Example}
6323
6324 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6325 @ChgAdded{Version=[2],Type=[Trailing],Text=[Reorders the elements of Container
6326 in reverse order.]}
6327
6328 @begin{Discussion}
6329 @ChgRef{Version=[2],Kind=[AddedNormal]}
6330 @ChgAdded{Version=[2],Text=[Unlike the similar routine for a vector,
6331 elements should not be copied; rather, the nodes should be exchanged. Cursors
6332 are expected to reference the same elements afterwards.]}
6333 @end{Discussion}
6334
6335
6336 @begin{Example}
6337 @ChgRef{Version=[2],Kind=[AddedNormal]}
6338 @ChgRef{Version=[5],Kind=[Revised]}
6339 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Swap (Container : @key{in out} List;
6340 I, J : @key{in} Cursor)@Chg{Version=[5],New=[
6341 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
6342 @key{or else raise} Program_Error) @key{and then}
6343 (I /= No_Element @key{or else} Constraint_Error) @key{and then}
6344 (J /= No_Element @key{or else} Constraint_Error) @key{and then}
6345 (Has_Element (Container, I)
6346 @key{or else raise} Program_Error) @key{and then}
6347 (Has_Element (Container, J)
6348 @key{or else raise} Program_Error)],Old=[]};]}
6349 @end{Example}
6350
6351 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6352 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6353 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
6354 either I or J is No_Element,
6355 then Constraint_Error is propagated. If either I or J do not designate an
6356 element in Container, then Program_Error is propagated. Otherwise, ]}Swap
6357 exchanges the values of the elements designated by I and J.]}
6358
6359 @begin{Ramification}
6360 @ChgRef{Version=[2],Kind=[AddedNormal]}
6361 @ChgAdded{Version=[2],Text=[After a call to Swap, I designates the element
6362 value previously designated by J, and J designates the element value
6363 previously designated by I. The cursors do not become ambiguous from
6364 this operation.]}
6365 @end{Ramification}
6366
6367 @begin{Honest}
6368 @ChgRef{Version=[2],Kind=[AddedNormal]}
6369 @ChgAdded{Version=[2],Text=[The implementation is not required to actually
6370 copy the elements if it can do the swap some other way. But it is allowed
6371 to copy the elements if needed.]}
6372 @end{Honest}
6373
6374 @begin{Example}
6375 @ChgRef{Version=[2],Kind=[AddedNormal]}
6376 @ChgRef{Version=[5],Kind=[Revised]}
6377 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Swap_Links (Container : @key{in out} List;
6378 I, J : @key{in} Cursor)@Chg{Version=[5],New=[
6379 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
6380 @key{or else raise} Program_Error) @key{and then}
6381 (I /= No_Element @key{or else} Constraint_Error) @key{and then}
6382 (J /= No_Element @key{or else} Constraint_Error) @key{and then}
6383 (Has_Element (Container, I)
6384 @key{or else raise} Program_Error) @key{and then}
6385 (Has_Element (Container, J)
6386 @key{or else raise} Program_Error)],Old=[]};]}
6387 @end{Example}
6388
6389 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6390 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6391 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
6392 either I or J is No_Element,
6393 then Constraint_Error is propagated. If either I or J do not designate an
6394 element in Container, then Program_Error is propagated. Otherwise, ]}Swap_Links
6395 exchanges the nodes designated by I and J.]}
6396
6397 @begin{Ramification}
6398 @ChgRef{Version=[2],Kind=[AddedNormal]}
6399 @ChgAdded{Version=[2],Text=[Unlike Swap, this exchanges the nodes, not the
6400 elements. No copying is performed. I and J designate the same elements after
6401 this call as they did before it. This operation can provide better performance
6402 than Swap if the element size is large.]}
6403 @end{Ramification}
6404
6405
6406 @begin{Example}
6407 @ChgRef{Version=[2],Kind=[AddedNormal]}
6408 @ChgRef{Version=[5],Kind=[Revised]}
6409 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Splice (Target : @key{in out} List;
6410 Before : @key{in} Cursor;
6411 Source : @key{in out} List)@Chg{Version=[5],New=[
6412 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
6413 @key{or else raise} Program_Error) @key{and then}
6414 (@key{not} Tampering_With_Cursors_Prohibited (Source)
6415 @key{or else raise} Program_Error) @key{and then}
6416 (Before = No_Element @key{or else}
6417 Has_Element (Target, Before)
6418 @key{or else raise} Program_Error) @key{and then}
6419 (Same_Object (Target, Source) @key{or else}
6420 Length (Target) <= Count_Type'Last - 1
6421 @key{or else raise} Constraint_Error),
6422 Post => (@key{declare}
6423 Result_Length : @key{constant} Count_Type :=
6424 Length (Source)'Old + Length (Target)'Old;
6425 @key{begin}
6426 (@key{if} Same_Object (Target, Source) @key{then} True
6427 @key{else} Length (Source) = 0 @key{and then}
6428 Length (Target) = Result_Length))],Old=[]};]}
6429 @end{Example}
6430
6431 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6432 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6433 @ChgAdded{Version=[2],Type=[Trailing],Text=[If @Chg{Version=[5],New=[],Old=[Before is not
6434 No_Element, and does not designate an element in Target, then Program_Error
6435 is propagated. Otherwise, if
6436 ]}Source denotes the same object as Target, the operation has no effect.
6437 Otherwise, Splice reorders elements such that they are removed from Source and
6438 moved to Target, immediately prior to Before. If Before equals No_Element, the
6439 nodes of Source are spliced after the last node of
6440 Target.@Chg{Version=[5],New=[],Old=[ The length of Target
6441 is incremented by the number of nodes in Source, and the length of Source is
6442 set to 0.]}]}
6443
6444 @begin{Example}
6445 @ChgRef{Version=[2],Kind=[AddedNormal]}
6446 @ChgRef{Version=[5],Kind=[Revised]}
6447 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Splice (Target : @key{in out} List;
6448 Before : @key{in} Cursor;
6449 Source : @key{in out} List;
6450 Position : @key{in out} Cursor)@Chg{Version=[5],New=[
6451 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
6452 @key{or else raise} Program_Error) @key{and then}
6453 (@key{not} Tampering_With_Cursors_Prohibited (Source)
6454 @key{or else raise} Program_Error) @key{and then}
6455 (Position /= No_Element
6456 @key{or else raise} Constraint_Error) @key{and then}
6457 (Has_Element (Source, Position)
6458 @key{or else raise} Program_Error) @key{and then}
6459 (Before = No_Element @key{or else}
6460 Has_Element (Target, Before)
6461 @key{or else raise} Program_Error) @key{and then}
6462 (Same_Object (Target, Source) @key{or else}
6463 Length (Target) <= Count_Type'Last - 1
6464 @key{or else raise} Constraint_Error),
6465 Post => (@key{declare}
6466 Org_Target_Length : @key{constant} Count_Type :=
6467 Length (Target)'Old;
6468 Org_Source_Length : @key{constant} Count_Type :=
6469 Length (Source)'Old;
6470 @key{begin}
6471 (@key{if} Same_Object (Target, Source) @key{then}
6472 Position = Position'Old
6473 @key{else} Length (Source) = Org_Source_Length - 1 @key{and then}
6474 Length (Target) = Org_Target_Length + 1 @key{and then}
6475 Has_Element (Target, Position)))],Old=[]};]}
6476 @end{Example}
6477
6478 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6479 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
6480 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6481 @ChgAdded{Version=[2],Type=[Trailing],Text=[If @Chg{Version=[5],New=[],Old=[Position is
6482 No_Element@Chg{Version=[3],New=[,],Old=[]} then
6483 Constraint_Error is propagated. If Before does not equal No_Element, and does
6484 not designate an element in Target, then Program_Error is propagated. If
6485 Position does not equal No_Element, and does not designate a node in Source,
6486 then Program_Error is propagated. If ]}Source denotes the same object as Target,
6487 then there is no effect if Position equals Before, else the element
6488 designated by Position is moved immediately prior to Before, or, if Before
6489 equals No_Element, after the last element.
6490 @Chg{Version=[5],New=[],Old=[In both cases, Position and the length of Target
6491 are unchanged. ]}Otherwise@Chg{Version=[3],New=[,],Old=[]} the element
6492 designated by Position is removed from Source and moved to Target, immediately
6493 prior to Before, or, if Before equals No_Element, after the last element of
6494 Target.@Chg{Version=[5],New=[],Old=[ The length of Target is incremented, the
6495 length of Source is decremented, and]} Position is updated to represent
6496 an element in Target.]}
6497 @begin{Ramification}
6498 @ChgRef{Version=[2],Kind=[AddedNormal]}
6499 @ChgAdded{Version=[2],Text=[If Source is the same as Target, and
6500 Position = Before, or Next(Position) = Before, Splice has no effect, as
6501 the element does not have to move to meet the postcondition.]}
6502 @end{Ramification}
6503
6504 @begin{Example}
6505 @ChgRef{Version=[2],Kind=[AddedNormal]}
6506 @ChgRef{Version=[5],Kind=[Revised]}
6507 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Splice (Container: @key{in out} List;
6508 Before : @key{in} Cursor;
6509 Position : @key{in} Cursor)@Chg{Version=[5],New=[
6510 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
6511 @key{or else raise} Program_Error) @key{and then}
6512 (Position /= No_Element
6513 @key{or else raise} Constraint_Error) @key{and then}
6514 (Has_Element (Container, Position)
6515 @key{or else raise} Program_Error) @key{and then}
6516 (Before = No_Element @key{or else}
6517 Has_Element (Container, Before)
6518 @key{or else raise} Program_Error),
6519 Post => Length (Container) = Length (Container)'Old],Old=[]};]}
6520 @end{Example}
6521
6522 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6523 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
6524 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6525 @ChgAdded{Version=[2],Type=[Trailing],Text=[If @Chg{Version=[5],New=[],Old=[Position is
6526 No_Element@Chg{Version=[3],New=[,],Old=[]} then
6527 Constraint_Error is propagated. If Before does not equal No_Element, and does
6528 not designate an element in Container, then Program_Error is propagated. If
6529 Position does not equal No_Element, and does not designate a node in Container,
6530 then Program_Error is propagated. If ]}Position equals Before there is no effect.
6531 Otherwise, the element designated by Position is moved immediately prior to
6532 Before, or, if Before equals No_Element, after the last
6533 element.@Chg{Version=[5],New=[],Old=[ The length of Container is unchanged.]}]}
6534
6535 @begin{Example}
6536 @ChgRef{Version=[2],Kind=[AddedNormal]}
6537 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6538 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First (Container : List) @key{return} Cursor@Chg{Version=[5],New=[
6539 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
6540 Post => (@key{if not} Is_Empty (Container)
6541 @key{then} Has_Element (Container, First'Result)
6542 @key{else} First'Result = No_Element)],Old=[]};]}
6543 @end{Example}
6544
6545 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6546 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, First
6547 returns No_Element. Otherwise, it returns a cursor that designates the first
6548 node in Container.]}
6549
6550 @begin{Example}
6551 @ChgRef{Version=[2],Kind=[AddedNormal]}
6552 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6553 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First_Element (Container : List)
6554 @key{return} Element_Type@Chg{Version=[5],New=[
6555 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
6556 @end{Example}
6557
6558 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6559 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Container, First_Index (Container)).]}
6560
6561 @begin{Example}
6562 @ChgRef{Version=[2],Kind=[AddedNormal]}
6563 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6564 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last (Container : List) @key{return} Cursor@Chg{Version=[5],New=[
6565 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
6566 Post => (@key{if} not Is_Empty (Container)
6567 @key{then} Has_Element (Container, Last'Result)
6568 @key{else} Last'Result = No_Element)],Old=[]};]}
6569 @end{Example}
6570
6571 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6572 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Last returns
6573 No_Element. Otherwise, it returns a cursor that designates the last node in
6574 Container.]}
6575
6576 @begin{Example}
6577 @ChgRef{Version=[2],Kind=[AddedNormal]}
6578 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6579 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last_Element (Container : List)
6580 @key{return} Element_Type@Chg{Version=[5],New=[
6581 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
6582 @end{Example}
6583
6584 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6585 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Last (Container)).]}
6586
6587 @begin{Example}
6588 @ChgRef{Version=[2],Kind=[AddedNormal]}
6589 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6590 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Next (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
6591 @key{with} Global => (@key{in all}, @key{use null}),
6592 Nonblocking => True,
6593 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
6594 @key{else} True)],Old=[]};]}
6595 @end{Example}
6596
6597 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6598 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element or
6599 designates the last element of the container, then Next returns the value
6600 No_Element. Otherwise, it returns a cursor that designates the successor of the
6601 element designated by Position.]}
6602
6603 @begin{Example}
6604 @ChgRef{Version=[5],Kind=[Added]}
6605 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Next (Container : List;
6606 Position : Cursor) @key{return} Cursor
6607 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
6608 Pre => Position = No_Element @key{or else}
6609 Has_Element (Container, Position)
6610 @key{or else raise} Program_Error,
6611 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
6612 @key{elsif} Next'Result = No_Element @key{then}
6613 Position = Last (Container)
6614 @key{else} Has_Element (Container, Next'Result));]}
6615 @end{Example}
6616
6617 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
6618 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns a cursor designating the
6619 successor of the element designated by Position in Container.]}
6620
6621 @begin{Example}
6622 @ChgRef{Version=[2],Kind=[AddedNormal]}
6623 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6624 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Previous (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
6625 @key{with} Global => (@key{in all}, @key{use null}),
6626 Nonblocking => True,
6627 Post => (@key{if} Position = No_Element @key{then} Previous'Result = No_Element
6628 @key{else} True)],Old=[]};]}
6629 @end{Example}
6630
6631 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6632 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element or
6633 designates the first element of the container, then Previous returns the value
6634 No_Element. Otherwise, it returns a cursor that designates the predecessor of
6635 the element designated by Position.]}
6636
6637 @begin{Example}
6638 @ChgRef{Version=[5],Kind=[Added]}
6639 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Previous (Container : List;
6640 Position : Cursor) @key{return} Cursor
6641 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
6642 Pre => Position = No_Element @key{or else}
6643 Has_Element (Container, Position)
6644 @key{or else raise} Program_Error,
6645 Post => (@key{if} Position = No_Element @key{then} Previous'Result = No_Element
6646 @key{elsif} Previous'Result = No_Element @key{then}
6647 Position = First (Container)
6648 @key{else} Has_Element (Container, Previous'Result));]}
6649 @end{Example}
6650
6651 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
6652 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns a cursor designating the
6653 predecessor of the element designated by Position in Container, if any.]}
6654
6655 @begin{Example}
6656 @ChgRef{Version=[2],Kind=[AddedNormal]}
6657 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6658 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Next (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
6659 @key{with} Global => (@key{in all}, @key{use null}),
6660 Nonblocking => True],Old=[]};]}
6661 @end{Example}
6662
6663 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6664 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Next (Position).]}
6665
6666 @begin{Example}
6667 @ChgRef{Version=[5],Kind=[Added]}
6668 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{procedure} Next (Container : @key{in} List;
6669 Position : @key{in out} Cursor)
6670 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
6671 Pre => Position = No_Element @key{or else}
6672 Has_Element (Container, Position)
6673 @key{or else raise} Program_Error,
6674 Post => (@key{if} Position /= No_Element
6675 @key{then} Has_Element (Container, Position));]}
6676 @end{Example}
6677
6678 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
6679 @ChgAdded{Version=[5],Type=[Trailing],Text=[Equivalent to Position := Next
6680 (Container, Position).]}
6681
6682 @begin{Example}
6683 @ChgRef{Version=[2],Kind=[AddedNormal]}
6684 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6685 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Previous (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
6686 @key{with} Global => (@key{in all}, @key{use null}),
6687 Nonblocking => True],Old=[]};]}
6688 @end{Example}
6689
6690 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6691 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Previous (Position).]}
6692
6693 @begin{Example}
6694 @ChgRef{Version=[5],Kind=[Added]}
6695 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{procedure} Previous (Container : @key{in} List;
6696 Position : @key{in out} Cursor)
6697 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
6698 Pre => Position = No_Element @key{or else}
6699 Has_Element (Container, Position)
6700 @key{or else raise} Program_Error,
6701 Post => (@key{if} Position /= No_Element
6702 @key{then} Has_Element (Container, Position));]}
6703 @end{Example}
6704
6705 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
6706 @ChgAdded{Version=[5],Type=[Trailing],Text=[Equivalent to Position :=
6707 Previous (Container, Position).]}
6708
6709
6710
6711 @begin{Example}
6712 @ChgRef{Version=[2],Kind=[AddedNormal]}
6713 @ChgRef{Version=[5],Kind=[Revised]}
6714 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Find (Container : List;
6715 Item : Element_Type;
6716 Position : Cursor := No_Element)
6717 @key{return} Cursor@Chg{Version=[5],New=[
6718 @key{with} Pre => Position = No_Element @key{or else}
6719 Has_Element (Container, Position)
6720 @key{or else raise} Program_Error,
6721 Post => (@key{if} Find'Result = No_Element @key{then} True
6722 @key{else} Has_Element (Container, Find'Result))],Old=[]};]}
6723 @end{Example}
6724
6725 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6726 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6727 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
6728 Position is not No_Element, and
6729 does not designate an element in Container, then Program_Error is propagated.
6730 ]}Find searches the elements of Container for an element equal to Item (using
6731 the generic formal equality operator). The search starts at the
6732 element designated by Position, or at the first element if Position equals
6733 No_Element. It proceeds towards Last (Container). If no equal element is found,
6734 then Find returns No_Element. Otherwise, it returns a cursor designating the
6735 first equal element encountered.]}
6736
6737 @begin{Example}
6738 @ChgRef{Version=[2],Kind=[AddedNormal]}
6739 @ChgRef{Version=[5],Kind=[Revised]}
6740 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Reverse_Find (Container : List;
6741 Item : Element_Type;
6742 Position : Cursor := No_Element)
6743 @key{return} Cursor@Chg{Version=[5],New=[
6744 @key{with} Pre => Position = No_Element @key{or else}
6745 Has_Element (Container, Position)
6746 @key{or else raise} Program_Error,
6747 Post => (@key{if} Reverse_Find'Result = No_Element @key{then} True
6748 @key{else} Has_Element (Container, Reverse_Find'Result))],Old=[]};]}
6749 @end{Example}
6750
6751 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6752 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6753 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
6754 Position is not No_Element, and
6755 does not designate an element in Container, then Program_Error is propagated.
6756 ]}Find searches the elements of Container for an element equal to Item (using
6757 the generic formal equality operator). The search starts at the
6758 element designated by Position, or at the last element if Position equals
6759 No_Element. It proceeds towards First (Container). If no equal element is
6760 found, then Reverse_Find returns No_Element. Otherwise, it returns a cursor
6761 designating the first equal element encountered.]}
6762
6763
6764 @begin{Example}
6765 @ChgRef{Version=[2],Kind=[AddedNormal]}
6766 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Contains (Container : List;
6767 Item : Element_Type) @key{return} Boolean;]}
6768 @end{Example}
6769
6770 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6771 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Find (Container, Item) /= No_Element.]}
6772
6773 @begin{Example}
6774 @ChgRef{Version=[2],Kind=[AddedNormal]}
6775 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg]}
6776 @ChgAdded{Version=[2],KeepNext=[T],Text=[@Chg{Version=[3],New=[],Old=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean;]}]}
6777 @end{Example}
6778
6779 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6780 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]}
6781 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[],Old=[Returns True if Position designates
6782 an element, and returns False otherwise.]}]}
6783
6784 @begin{Honest}
6785 @ChgRef{Version=[2],Kind=[AddedNormal]}
6786 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]}
6787 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[This function may not detect cursors that
6788 designate deleted elements; such cursors are invalid (see below) and the
6789 result of calling Has_Element with an invalid cursor is unspecified (but
6790 not erroneous).]}]}
6791 @end{Honest}
6792 @begin{NotIso}
6793 @ChgAdded{Version=[3],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 139 and 140
6794 were moved above.>}]}@Comment{This message should be
6795 deleted if the paragraphs are ever renumbered.}
6796 @end{NotIso}
6797
6798 @begin{Example}
6799 @ChgRef{Version=[2],Kind=[AddedNormal]}
6800 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6801 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Iterate
6802 (Container : @key{in} List;
6803 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
6804 @key{with} Allows_Exit],Old=[]};]}
6805 @end{Example}
6806
6807 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6808 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]}
6809 @ChgAdded{Version=[2],Type=[Trailing],Text=[Iterate calls Process.@key{all}
6810 with a cursor that designates each node in Container, starting with the first
6811 node and moving the cursor as per the Next function.
6812 @Chg{Version=[3],New=[Tampering],Old=[Program_Error
6813 is propagated if Process.@key{all} tampers]}
6814 with the cursors of Container@Chg{Version=[3],New=[ is prohibited during the
6815 execution of a call on Process.@key{all}],Old=[]}. Any exception raised by
6816 Process.@key{all} is propagated.]}
6817
6818 @begin{ImplNote}
6819 @ChgRef{Version=[2],Kind=[AddedNormal]}
6820 @ChgAdded{Version=[2],Text=[The purpose of the tamper with cursors check is
6821 to prevent erroneous execution from the Position parameter of Process.@key{all}
6822 becoming invalid. This check takes place when the operations that tamper with
6823 the cursors of the container are called. The check cannot be made later (say
6824 in the body of Iterate), because that could cause the Position cursor to be
6825 invalid and potentially cause execution to become erroneous -- defeating the
6826 purpose of the check.]}
6827
6828 @ChgRef{Version=[2],Kind=[AddedNormal]}
6829 @ChgAdded{Version=[2],Text=[See Iterate for vectors
6830 (@RefSecNum{The Generic Package Containers.Vectors}) for a suggested
6831 implementation of the check.]}
6832 @end{ImplNote}
6833
6834 @begin{Example}
6835 @ChgRef{Version=[2],Kind=[AddedNormal]}
6836 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6837 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reverse_Iterate
6838 (Container : @key{in} List;
6839 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
6840 @key{with} Allows_Exit],Old=[]};]}
6841 @end{Example}
6842
6843 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6844 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]}
6845 @ChgAdded{Version=[2],Type=[Trailing],Text=[Iterates over the nodes in
6846 Container as per @Chg{Version=[3],New=[procedure ],Old=[]}Iterate,
6847 except that elements are traversed in reverse order,
6848 starting with the last node and moving the cursor as per the Previous
6849 function.]}
6850
6851 @begin{Example}
6852 @ChgRef{Version=[3],Kind=[Added]}
6853 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1],ARef=[AI12-0266-1]}
6854 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] List)
6855 @key[return] List_Iterator_Interfaces.@Chg{Version=[5],New=[Parallel_Reversible_Iterator],Old=[Reversible_Iterator]}'Class@Chg{Version=[5],New=[
6856 @key[with] Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
6857 @end{Example}
6858
6859 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]}
6860 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0266-1]}
6861 @ChgAdded{Version=[3],Type=[Trailing],Text=[Iterate returns
6862 @Chg{Version=[5],New=[an],Old=[a reversible]}
6863 iterator object (see @RefSecNum{User-Defined Iterator Types}) that
6864 will generate a value for a loop parameter (see
6865 @RefSecNum{Generalized Loop Iteration}) designating
6866 each node in Container, starting with the first node and moving the cursor as
6867 per the Next function when used as a forward iterator, and starting with the
6868 last node and moving the cursor as per the Previous function when used as a
6869 reverse iterator@Chg{Version=[5],New=[, and processing all nodes concurrently
6870 when used as a parallel iterator],Old=[]}. Tampering with the cursors of
6871 Container is prohibited while the iterator object exists (in particular, in the
6872 @nt{sequence_of_statements} of the @nt{loop_statement} whose
6873 @nt{iterator_specification} denotes this object). The iterator object needs
6874 finalization.]}
6875
6876 @begin{Example}
6877 @ChgRef{Version=[3],Kind=[Added]}
6878 @ChgRef{Version=[5],Kind=[RevisedAdded]}
6879 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] List; Start : @key[in] Cursor)
6880 @key[return] List_Iterator_Interfaces.Reversible_Iterator'Class@Chg{Version=[5],New=[
6881 @key[with] Pre => (Start /= No_Element
6882 @key[or else raise] Constraint_Error) @key[and then]
6883 (Has_Element (Container, Start)
6884 @key[or else raise] Program_Error),
6885 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
6886 @end{Example}
6887
6888 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0262-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]}
6889 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6890 @ChgAdded{Version=[3],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
6891 Start is not No_Element and does
6892 not designate an item in Container, then Program_Error is propagated. If Start
6893 is No_Element, then Constraint_Error is propagated. Otherwise, ]}Iterate
6894 returns a reversible iterator object
6895 (see @RefSecNum{User-Defined Iterator Types}) that
6896 will generate a value for a loop parameter (see
6897 @RefSecNum{Generalized Loop Iteration}) designating
6898 each node in Container, starting with the node designated
6899 by Start and moving the cursor as per the Next function when used as a forward
6900 iterator, or moving the cursor as per the Previous function when used as a
6901 reverse iterator. Tampering with the cursors of
6902 Container is prohibited while the iterator object exists (in particular, in the
6903 @nt{sequence_of_statements} of the @nt{loop_statement} whose
6904 @nt{iterator_specification} denotes this object). The iterator object needs
6905 finalization.]}
6906
6907 @begin{Discussion}
6908 @ChgRef{Version=[3],Kind=[AddedNormal]}
6909 @ChgAdded{Version=[3],Type=[Leading],Text=[Exits are allowed from the loops
6910 created using the iterator objects. In particular, to stop the iteration at a
6911 particular cursor, just add]}
6912 @begin{Example}
6913 @ChgRef{Version=[3],Kind=[AddedNormal]}
6914 @ChgAdded{Version=[3],Text=[@key[exit when] Cur = Stop;]}
6915 @end{Example}
6916 @ChgRef{Version=[3],Kind=[AddedNormal]}
6917 @ChgAdded{Version=[3],Type=[Trailing],Text=[in the body of the loop (assuming
6918 that @exam{Cur} is the loop parameter and @exam{Stop} is the cursor that you
6919 want to stop at).]}
6920 @end{Discussion}
6921
6922 @end{DescribeCode}
6923
6924 @ChgRef{Version=[2],Kind=[AddedNormal]}
6925 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0044-1],ARef=[AI05-0262-1]}
6926 @ChgAdded{Version=[2],Text=[The actual function for the generic formal function
6927 "<" of Generic_Sorting is expected to return the same value each time it is
6928 called with a particular pair of element values. It should define a strict
6929 @Chg{Version=[3],New=[weak ],Old=[]}ordering relationship@Chg{Version=[3],
6930 New=[ (see @RefSecNum{Containers})],Old=[, that is, be irreflexive, asymmetric,
6931 and transitive]}; it
6932 should not modify Container. If the actual for "<" behaves in some other
6933 manner, the behavior of the subprograms of Generic_Sorting are unspecified.
6934 @Chg{Version=[3],New=[The number of],Old=[How many]} times the subprograms of
6935 Generic_Sorting call "<" is unspecified.@PDefn{unspecified}]}
6936
6937 @begin{DescribeCode}
6938
6939 @begin{Example}
6940 @ChgRef{Version=[2],Kind=[AddedNormal]}
6941 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Is_Sorted (Container : List) @key{return} Boolean;]}
6942 @end{Example}
6943
6944 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6945 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns True if the elements are
6946 sorted smallest first as determined by the generic formal "<" operator;
6947 otherwise, Is_Sorted returns False. Any exception raised during evaluation of
6948 "<" is propagated.]}
6949
6950 @begin{Example}
6951 @ChgRef{Version=[2],Kind=[AddedNormal]}
6952 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6953 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Sort (Container : @key{in out} List)@Chg{Version=[5],New=[
6954 @key{with} Pre => (@key{if} Tampering_With_Cursors_Prohibited (Container)
6955 @key{then raise} Program_Error)],Old=[]};]}
6956 @end{Example}
6957
6958
6959 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6960 @ChgAdded{Version=[2],Type=[Trailing],Text=[Reorders the nodes of Container
6961 such that the elements are sorted smallest first as determined by the generic
6962 formal "<" operator provided. The sort is stable. Any exception raised during
6963 evaluation of "<" is propagated.]}
6964
6965 @begin{Ramification}
6966 @ChgRef{Version=[2],Kind=[AddedNormal]}
6967 @ChgAdded{Version=[2],Text=[Unlike array sorts, we do require stable sorts
6968 here. That's because algorithms in the merge sort family (as described by
6969 Knuth) can be both fast and stable. Such sorts use the extra memory as
6970 offered by the links to provide better performance.]}
6971
6972 @ChgRef{Version=[2],Kind=[AddedNormal]}
6973 @ChgAdded{Version=[2],Text=[Note that list sorts never copy elements; it is
6974 the nodes, not the elements, that are reordered.]}
6975 @end{Ramification}
6976
6977 @begin{Example}
6978 @ChgRef{Version=[2],Kind=[AddedNormal]}
6979 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6980 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Merge (Target : @key{in out} List;
6981 Source : @key{in out} List)@Chg{Version=[5],New=[
6982 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
6983 @key{or else raise} Program_Error) @key{and then}
6984 (@key{not} Tampering_With_Elements_Prohibited (Source)
6985 @key{or else raise} Program_Error) @key{and then}
6986 (Length (Target) <= Maximum_Length - Length (Source)
6987 @key{or else raise} Constraint_Error),
6988 Post => (@key{declare}
6989 Result_Length : @key{constant} Count_Type :=
6990 Length (Source)'Old + Length (Target)'Old;
6991 @key{begin}
6992 (@key{if} Same_Object (Target, Source) @key{then} True
6993 @key{else} Length (Source) = 0 @key{and then}
6994 Length (Target) = Result_Length))],Old=[]};]}
6995 @end{Example}
6996
6997
6998
6999
7000 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7001 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1]}
7002 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[If Source is
7003 empty, then Merge does nothing. If Source and Target are the same nonempty
7004 container object, then Program_Error is propagated. Otherwise, ],Old=[]}Merge
7005 removes elements from Source
7006 and inserts them into Target; afterwards,
7007 Target contains the union of the elements that were initially
7008 in Source and Target; Source is left empty.
7009 If Target and Source are initially sorted smallest first, then Target is
7010 ordered smallest first as determined by the generic formal "<" operator;
7011 otherwise, the order of elements in Target is unspecified.
7012 Any exception raised during evaluation of "<" is propagated.]}
7013
7014 @begin{Ramification}
7015 @ChgRef{Version=[2],Kind=[AddedNormal]}
7016 @ChgAdded{Version=[2],Text=[It is a bounded error if either of the lists is
7017 unsorted, see below. The bounded error can be recovered by sorting Target
7018 after the merge call, or the lists can be pretested with Is_Sorted.]}
7019 @end{Ramification}
7020
7021 @end{DescribeCode}
7022
7023 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
7024 @ChgAdded{Version=[5],Text=[The nested package Doubly_Linked_Lists.Stable
7025 provides a type Stable.List that represents
7026 a @i<stable> list,@Defn2{Term=(stable),Sec=(list)} which is one that
7027 cannot grow and shrink. Such a list can be created by calling the
7028 Copy function, or by establishing a
7029 @i<stabilized view> of a regular List.@Defn2{Term=[stabilized view],Sec=[list]}]}
7030
7031 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
7032 @ChgAdded{Version=[5],Type=[Leading],Text=[The subprograms of package
7033 Containers.Doubly_Linked_Lists that have a parameter or result of type List
7034 are included in the nested package Stable with the same specification, except
7035 that the following are omitted:]}
7036
7037 @begin{Indent}
7038 @ChgRef{Version=[5],Kind=[Added]}
7039 @ChgAdded{Version=[5],Text=[Tampering_With_Cursors_Prohibited,
7040 Tampering_With_Elements_Prohibited, Assign, Move,
7041 Insert, Clear, Delete, Delete_First, Delete_Last, Splice, Swap_Links,
7042 and Reverse_Elements]}
7043 @end{Indent}
7044
7045 @begin{Ramification}
7046 @ChgRef{Version=[5],Kind=[Added]}
7047 @ChgAdded{Version=[5],Text=[The names List and Cursor mean the types
7048 declared in the nested package in these subprogram specifications.]}
7049 @end{Ramification}
7050 @begin{Reason}
7051 @ChgRef{Version=[5],Kind=[Added]}
7052 @ChgAdded{Version=[5],Text=[The omitted routines are those that tamper with
7053 cursors or elements (or test that state). The model is that it is
7054 impossible to tamper with cursors or elements of a stable view since no
7055 such operations are included. Thus tampering checks are not needed for
7056 a stable view, and we omit the operations associated with those checks.]}
7057
7058 @ChgRef{Version=[5],Kind=[Added]}
7059 @ChgAdded{Version=[5],Text=[The Generic_Sorting generic is omitted entirely,
7060 as only function Is_Sorting does not tamper with cursors. It isn't useful
7061 enough by itself to include.]}
7062 @end{Reason}
7063
7064 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
7065 @ChgAdded{Version=[5],Text=[The operations of this package are equivalent
7066 to those for regular lists, except that the calls to
7067 Tampering_With_Cursors_Prohibited and
7068 Tampering_With_Elements_Prohibited that occur in preconditions are replaced
7069 by False, and any that occur in postconditions are replaced by True.]}
7070
7071 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
7072 @ChgAdded{Version=[5],Text=[If a stable list is declared with the Base
7073 discriminant designating a pre-existing regular list, the stable list
7074 represents a stabilized view of the underlying regular list, and any operation
7075 on the stable list is reflected on the underlying regular list. While a
7076 stabilized view exists, any operation that tampers with elements performed on
7077 the underlying list is prohibited. The finalization of a stable list that
7078 provides such a view removes this restriction on the underlying regular list
7079 @Redundant[(though some other restriction might exist due to other concurrent
7080 iterations or stabilized views)].]}
7081
7082 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
7083 @ChgAdded{Version=[5],Text=[If a stable list is declared without specifying
7084 Base, the object must be initialized. The initializing expression of the stable
7085 list, @Redundant[typically a call on Copy], determines the Length
7086 of the list. The Length of a stable list never changes after
7087 initialization.]}
7088
7089 @end{StaticSem}
7090
7091 @begin{Bounded}
7092 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7093 @ChgAdded{Version=[2],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}
7094 Calling Merge in an instance of Generic_Sorting
7095 with either Source or Target not ordered smallest first using the provided
7096 generic formal "<" operator is a bounded error. Either Program_Error is raised
7097 after Target is updated as described for Merge, or the operation works as
7098 defined.@Defn2{Term=[Program_Error],Sec=(raised by detection of a bounded error)}]}
7099
7100 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0022-1],ARef=[AI05-0248-1]}
7101 @ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}
7102 It is a bounded error for the actual function
7103 associated with a generic formal subprogram, when called as part of an
7104 operation of this package, to tamper with elements of any List parameter of
7105 the operation. Either Program_Error is raised, or the operation works as
7106 defined on the value of the List either prior to, or subsequent to, some or
7107 all of the modifications to the List.@Defn2{Term=[Program_Error],Sec=(raised by detection of a bounded error)}]}
7108
7109 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0027-1]}
7110 @ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}
7111 It is a bounded error to call any subprogram
7112 declared in the visible part of Containers.Doubly_Linked_Lists
7113 when the associated container has been finalized. If the operation takes
7114 Container as an @key[in out] parameter, then it raises Constraint_Error or
7115 Program_Error. Otherwise, the operation either proceeds as it would
7116 for an empty container, or it raises Constraint_Error@Defn2{Term=[Constraint_Error],Sec=(raised by detection of a bounded error)}
7117 or Program_Error.@Defn2{Term=[Program_Error],Sec=(raised by detection of a bounded error)}]}
7118 @end{Bounded}
7119
7120 @begin{Erron}
7121 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7122 @ChgAdded{Version=[2],Type=[Leading],Text=[A Cursor value is
7123 @i<invalid> if any of the following have occurred since it
7124 was created:@Defn2{Term=[invalid cursor],Sec=[of a list container]}
7125 @PDefn2{Term=[cursor],Sec=[invalid]}]}
7126
7127 @begin{Itemize}
7128
7129 @ChgRef{Version=[2],Kind=[AddedNormal]}
7130 @ChgAdded{Version=[2],Text=[The list that contains the element it designates
7131 has been finalized;]}
7132
7133 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0160-1]}
7134 @ChgAdded{Version=[3],Text=[The list that contains the element it designates
7135 has been used as the Target of a call to Assign, or as the target of an
7136 @nt{assignment_statement};]}
7137
7138 @ChgRef{Version=[2],Kind=[AddedNormal]}
7139 @ChgAdded{Version=[2],Text=[@Redundant[The list that contains the element it
7140 designates has been used as the Source or Target of a call to Move;] or]}
7141 @begin{TheProof}
7142 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
7143 @ChgAdded{Version=[3],Text=[Move has been reworded in terms of Assign and
7144 Clear, which are covered by other bullets, so this text is redundant.]}
7145 @end{TheProof}
7146
7147 @ChgRef{Version=[2],Kind=[AddedNormal]}
7148 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0160-1],ARef=[AI05-0262-1]}
7149 @ChgAdded{Version=[2],Text=[The element it designates has been
7150 @Chg{Version=[3],New=[removed from the list that previously contained the
7151 element],Old=[deleted]}.]}
7152 @begin{Honest}
7153 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]}
7154 @ChgAdded{Version=[3],Text=[The cursor modified by the four parameter Splice
7155 is not invalid, even though the element it designates has been removed from
7156 the source list, because that cursor has been modified to designate that
7157 element in the target list @en the cursor no longer designates an element
7158 in the source list.]}
7159 @end{Honest}
7160 @begin{Ramification}
7161 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]}
7162 @ChgAdded{Version=[3],Text=[This can happen directly via calls to Delete,
7163 Delete_Last, Clear, Splice with a Source parameter, and Merge; and indirectly
7164 via calls to Delete_First, Assign, and Move.]}
7165 @end{Ramification}
7166
7167 @end{Itemize}
7168
7169 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7170 @ChgAdded{Version=[2],Text=[The result of "=" or Has_Element is unspecified
7171 if it is called with an invalid
7172 cursor parameter. Execution is erroneous if any other subprogram declared in
7173 Containers.Doubly_Linked_Lists is called with an invalid cursor parameter.
7174 @PDefn{unspecified}@PDefn2{Term=(erroneous execution),Sec=(cause)}]}
7175
7176 @begin{Discussion}
7177 @ChgRef{Version=[2],Kind=[AddedNormal]}
7178 @ChgAdded{Version=[2],Text=[The list above is intended to be exhaustive. In
7179 other cases, a cursor value continues to designate its original element. For
7180 instance, cursor values survive the insertion and deletion of other nodes.]}
7181
7182 @ChgRef{Version=[2],Kind=[AddedNormal]}
7183 @ChgAdded{Version=[2],Text=[While it is possible to check for these cases, in
7184 many cases the overhead necessary to make the check is substantial in time or
7185 space. Implementations are encouraged to check for as many of these cases as
7186 possible and raise Program_Error if detected.]}
7187 @end{Discussion}
7188
7189 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
7190 @ChgAdded{Version=[3],Text=[Execution is erroneous if the list associated with
7191 the result of a call to Reference or Constant_Reference is finalized before the
7192 result object returned by the call to Reference or Constant_Reference is
7193 finalized.]}
7194 @begin{Reason}
7195 @ChgRef{Version=[3],Kind=[AddedNormal]}
7196 @ChgAdded{Version=[3],Text=[Each object of Reference_Type and
7197 Constant_Reference_Type probably contains some reference to the originating
7198 container. If that container is prematurely finalized (which is only possible
7199 via Unchecked_Deallocation, as accessibility checks prevent passing a
7200 container to Reference that will not live as long as the result), the
7201 finalization of the object of Reference_Type will try to access a nonexistent
7202 object. This is a normal case of a dangling pointer created by
7203 Unchecked_Deallocation; we have to explicitly mention it here as the pointer
7204 in question is not visible in the specification of the type. (This is the same
7205 reason we have to say this for invalid cursors.)]}
7206 @end{Reason}
7207 @end{Erron}
7208
7209 @begin{ImplReq}
7210 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7211 @ChgAdded{Version=[2],Text=[No storage associated with a doubly-linked List
7212 object shall be lost upon assignment or scope exit.]}
7213
7214 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7215 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]}
7216 @ChgAdded{Version=[2],Text=[The execution of an @nt{assignment_statement} for
7217 a list shall have the effect of copying the elements from the source list
7218 object to the target list object@Chg{Version=[3],New=[ and changing the length
7219 of the target object to that of the source object],Old=[]}.]}
7220
7221 @begin{ImplNote}
7222 @ChgRef{Version=[2],Kind=[AddedNormal]}
7223 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0298-1]}
7224 @ChgAdded{Version=[2],Text=[An assignment of a List is a @lquotes@;deep@rquotes
7225 copy; that is the elements are copied as well as the data structures.
7226 We say @lquotes@;effect of@rquotes in order to allow the implementation to
7227 avoid copying elements immediately if it wishes. For instance, an
7228 implementation that avoided copying until one of the containers is modified
7229 would be allowed.@Chg{Version=[3],New=[ (Note that this implementation would
7230 require care, see @RefSecNum{The Generic Package Containers.Vectors} for more.)],Old=[]}]}
7231 @end{ImplNote}
7232 @end{ImplReq}
7233
7234 @begin{ImplAdvice}
7235
7236 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7237 @ChgAdded{Version=[2],Text=[Containers.Doubly_Linked_Lists should be
7238 implemented similarly to a linked list. In particular, if @i<N> is the length
7239 of a list, then the worst-case time complexity of Element, Insert with Count=1,
7240 and Delete with Count=1 should be @i{O}(log @i<N>).]}
7241 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
7242 Text=[The worst-case time complexity of Element, Insert with Count=1, and
7243 Delete with Count=1 for Containers.Doubly_Linked_Lists should be
7244 @i{O}(log @i<N>).]}]}
7245
7246 @begin{Reason}
7247 @ChgRef{Version=[2],Kind=[AddedNormal]}
7248 @ChgAdded{Version=[2],Text=[We do not mean to overly constrain implementation
7249 strategies here. However, it is important for portability that the
7250 performance of large containers has roughly the same factors on different
7251 implementations. If a program is moved to an implementation that takes
7252 @i{O}(@i<N>) time to access elements, that program could be unusable when the
7253 lists are large. We allow @i{O}(log @i<N>) access because the proportionality
7254 constant and caching effects are likely to be larger than the log factor, and
7255 we don't want to discourage innovative implementations.]}
7256 @end{Reason}
7257
7258 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7259 @ChgAdded{Version=[2],Text=[The worst-case time complexity of a call on
7260 procedure Sort of an
7261 instance of Containers.Doubly_Linked_Lists.Generic_Sorting should be
7262 @i{O}(@i<N>**2), and the average time complexity should be better than @i{O}(@i<N>**2).]}
7263 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
7264 Text=[A call on procedure Sort of an
7265 instance of Containers.Doubly_Linked_Lists.Generic_Sorting
7266 should have an average time complexity better than @i{O}(@i{N}**2) and
7267 worst case no worse than @i{O}(@i{N}**2).]}]}
7268
7269 @begin{Ramification}
7270 @ChgRef{Version=[2],Kind=[AddedNormal]}
7271 @ChgAdded{Version=[2],Text=[In other words, we're requiring the use of a
7272 better than @i{O}(@i{N}**2) sorting algorithm, such as Quicksort. No bubble sorts
7273 allowed!]}
7274 @end{Ramification}
7275
7276 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7277 @ChgAdded{Version=[2],Text=[Move should not copy elements, and should minimize
7278 copying of internal data structures.]}
7279 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
7280 Text=[Containers.Doubly_Linked_Lists.Move should not copy elements, and should
7281 minimize copying of internal data structures.]}]}
7282
7283 @begin{ImplNote}
7284 @ChgRef{Version=[2],Kind=[AddedNormal]}
7285 @ChgAdded{Version=[2],Text=[Usually that can be accomplished simply by
7286 moving the pointer(s) to the internal data structures from the Source
7287 container to the Target container.]}
7288 @end{ImplNote}
7289
7290 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7291 @ChgAdded{Version=[2],Text=[If an exception is propagated from a list
7292 operation, no storage should be lost, nor any elements removed from a list
7293 unless specified by the operation.]}
7294 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
7295 Text=[If an exception is propagated from a list
7296 operation, no storage should be lost, nor any elements removed from a list
7297 unless specified by the operation.]}]}
7298
7299 @begin{Reason}
7300 @ChgRef{Version=[2],Kind=[AddedNormal]}
7301 @ChgAdded{Version=[2],Text=[This is important so that programs can recover
7302 from errors. But we don't want to require heroic efforts, so we just require
7303 documentation of cases where this can't be accomplished.]}
7304 @end{Reason}
7305
7306 @end{ImplAdvice}
7307
7308 @begin{Notes}
7309 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7310 @ChgAdded{Version=[2],Text=[Sorting a list never copies elements, and is a
7311 stable sort (equal elements remain in the original order). This is different
7312 than sorting an array or vector, which may need to copy elements, and is
7313 probably not a stable sort.]}
7314 @end{Notes}
7315
7316 @begin{Extend95}
7317 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7318 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
7319 The generic package Containers.Doubly_Linked_Lists is new.]}
7320 @end{Extend95}
7321
7322 @begin{Inconsistent2005}
7323 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0248-1],ARef=[AI05-0257-1]}
7324 @ChgAdded{Version=[3],Text=[@Defn{inconsistencies with Ada 2005}@b<Correction:>
7325 The Insert versions that return a Position parameter are now defined to
7326 return Position = Before if Count = 0. This was unspecified for Ada 2005;
7327 so this will only be inconsistent if an implementation did something else and
7328 a program depended on that something else @em this should be very rare.]}
7329 @end{Inconsistent2005}
7330
7331 @begin{Incompatible2005}
7332 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
7333 @ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Subprograms Assign and Copy
7334 are added to Containers.Doubly_Linked_Lists. If an instance of Containers.Doubly_Linked_Lists
7335 is referenced in a @nt{use_clause}, and an entity @i<E> with the same
7336 @nt{defining_identifier} as a new entity in Containers.Doubly_Linked_Lists is
7337 defined in a package that is also referenced in a @nt{use_clause}, the
7338 entity @i<E> may no longer be use-visible, resulting in errors. This should
7339 be rare and is easily fixed if it does occur.]}
7340 @end{Incompatible2005}
7341
7342 @begin{Extend2005}
7343 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]}
7344 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
7345 Added iterator, reference, and indexing support to make list containers more
7346 convenient to use.]}
7347 @end{Extend2005}
7348
7349 @begin{DiffWord2005}
7350 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
7351 @ChgAdded{Version=[3],Text=[Generalized the definition
7352 of Move. Specified which elements are read/written by stream attributes.]}
7353
7354 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0022-1]}
7355 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName
7356 to cover tampering by generic actual subprograms.]}
7357
7358 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0027-1]}
7359 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName
7360 to cover access to finalized list containers.]}
7361
7362 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]}
7363 @ChgAdded{Version=[3],Text=[@b<Correction:> Redefined "<" actuals
7364 to require a strict weak ordering; the old definition allowed
7365 indeterminant comparisons that would not have worked in a container.]}
7366
7367 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0084-1]}
7368 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a pragma
7369 Remote_Types so that containers can be used in distributed programs.]}
7370
7371 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]}
7372 @ChgAdded{Version=[3],Text=[@b<Correction:> Revised the definition
7373 of invalid cursors to cover missing (and new) cases.]}
7374
7375 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0257-1]}
7376 @ChgAdded{Version=[3],Text=[@b<Correction:> Added missing wording to describe
7377 the Position after Inserting 0 elements.]}
7378
7379 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0265-1]}
7380 @ChgAdded{Version=[3],Text=[@b<Correction:> Defined when a container
7381 prohibits tampering in order to more clearly define where the check is
7382 made and the exception raised.]}
7383 @end{DiffWord2005}
7384
7385 @begin{Inconsistent2012}
7386 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1]}
7387 @ChgAdded{Version=[5],Text=[@Defn{inconsistencies with Ada 2012}@b<Corrigendum:>
7388 Tampering with elements is now defined to be equivalent to tampering with
7389 cursors for regular containers. If a program requires tampering detection
7390 to work, it might fail in Ada 202x. Needless to say, this shouldn't happen
7391 outside of test programs. See @Inconsistent2012Title in
7392 @RefSecNum{The Generic Package Containers.Vectors} for more details.]}
7393 @end{Inconsistent2012}
7394
7395 @begin{Incompatible2012}
7396 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1],ARef=[AI12-0112-1],ARef=[AI12-0339-1]}
7397 @ChgAdded{Version=[5],Text=[@Defn{incompatibilities with Ada 2012}A number of
7398 new subprograms, types, and even a nested package were added to
7399 Containers.Doubly_Linked_Lists to better support contracts and stable views. If an
7400 instance of Containers.Doubly_Linked_Lists
7401 is referenced in a @nt{use_clause}, and an entity @i<E> with the same
7402 @nt{defining_identifier} as a new entity in Containers.Hashed_Maps is
7403 defined in a package that is also referenced in a @nt{use_clause}, the
7404 entity @i<E> may no longer be use-visible, resulting in errors. This should
7405 be rare and is easily fixed if it does occur.]}
7406 @end{Incompatible2012}
7407
7408 @begin{Extend2012}
7409 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0196-1]}
7410 @ChgAdded{Version=[5],Text=[@Defn{extensions to Ada 2012}
7411 Replace_Element is now defined such that it can be used
7412 concurrently so long as it operates on different elements. This allows
7413 some container operations to be used in parallel without separate
7414 synchronization.]}
7415
7416 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0212-1]}
7417 @ChgAdded{Version=[5],Text=[Lists now support positional container
7418 aggregates, so @nt{aggregate} syntax can be used to create Lists.]}
7419
7420 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0266-1]}
7421 @ChgAdded{Version=[5],Text=[The iterator for the
7422 entire container now can return a parallel iterator which can be used to
7423 process the container in parallel.]}
7424 @end{Extend2012}
7425
7426 @begin{DiffWord2012}
7427 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0110-1]}
7428 @ChgAdded{Version=[4],Text=[@b<Corrigendum:> Clarified that tampering checks
7429 precede all other checks made by a subprogram (but come after those associated
7430 with the call).]}
7431
7432 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
7433 @ChgAdded{Version=[5],Text=[Added contracts to this container. This includes
7434 describing some of the semantics with pre- and postconditions, rather than
7435 English text. Note that the preconditions can be Suppressed (see
7436 @RefSecNum{Suppressing Checks}).]}
7437 @end{DiffWord2012}
7438