| 1 |
@comment{ $Source: e:\\cvsroot/ARM/Source/pre_containers.mss,v $ } |
| 2 |
@comment{ $Revision: 1.99 $ $Date: 2015/04/03 04:12:43 $ $Author: randy $ } |
| 3 |
@Part(precontainers, Root="ada.mss") |
| 4 |
|
| 5 |
@Comment{$Date: 2015/04/03 04:12:43 $} |
| 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 |
@ChgAdded{Version=[2],Text=[A variety of sequence and associative containers are |
| 24 |
provided. Each container includes a @i{cursor} type. A cursor is a reference |
| 25 |
to an element within a container. Many operations on cursors are common to |
| 26 |
all of the containers. A cursor referencing |
| 27 |
an element in a container is considered to be overlapping |
| 28 |
with the container object itself.@PDefn2{Term=[cursor],Sec=[for a container]} |
| 29 |
@Defn2{Term=[container],Sec=[cursor]}]} |
| 30 |
|
| 31 |
@begin{Reason} |
| 32 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 33 |
@ChgAdded{Version=[2],Text=[The last sentence is intended to clarify that |
| 34 |
operations that just use a cursor are on the same footing as operations that |
| 35 |
use a container in terms of the reentrancy rules of Annex A.]} |
| 36 |
@end{Reason} |
| 37 |
|
| 38 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 39 |
@ChgAdded{Version=[2],Text=[Within this clause we provide Implementation Advice |
| 40 |
for the desired average or worst case time complexity of certain operations |
| 41 |
on a container. This advice is expressed using the Landau symbol @i{O}(X). |
| 42 |
Presuming f is some function of a length parameter N and t(N) is the time the |
| 43 |
operation takes (on average or worst case, as specified) for the length N, a |
| 44 |
complexity of @i{O}(f(N)) means that there exists a finite A such that for any N, |
| 45 |
t(N)/f(N) < A. @Defn{Landau symbol @i{O}(X)}@Defn{@i{O}(f(N))}]} |
| 46 |
|
| 47 |
@begin{Discussion} |
| 48 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 49 |
@ChgAdded{Version=[2],Text=[Of course, an implementation can do better than a |
| 50 |
specified @i{O}(f(N)): for example, @i{O}(1) meets the requirements for |
| 51 |
@i{O}(log N).]} |
| 52 |
|
| 53 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 54 |
@ChgAdded{Version=[2],Text=[This concept seems to have |
| 55 |
as many names as there are authors. We used @lquotes@;Landau symbol@rquotes |
| 56 |
because that's what our reference does. But we'd also seen this referred as |
| 57 |
big-O notation@Defn{big-O notation} (sometimes written as @i<big-oh>), and |
| 58 |
as Bachmann notation. Whatever the name, it always has the above definition.]} |
| 59 |
@end{Discussion} |
| 60 |
|
| 61 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 62 |
@ChgAdded{Version=[2],Text=[If the advice suggests that the complexity should be |
| 63 |
less than @i{O}(f(N)), then for any arbitrarily small positive real D, there |
| 64 |
should exist a positive integer M such that for all N > M, |
| 65 |
t(N)/f(N) < D.]} |
| 66 |
|
| 67 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1],ARef=[AI05-0044-1]} |
| 68 |
@ChgAdded{Version=[3],Text=[When a formal function is used to provide an |
| 69 |
ordering for a container, it is generally required to define |
| 70 |
a strict weak ordering. A function "<" defines |
| 71 |
a @i<strict weak ordering>@Defn{strict weak ordering} if it is irreflexive, |
| 72 |
asymmetric, transitive, and in addition, if @i<x> < @i<y> for any values |
| 73 |
@i<x> and @i<y>, then for all other |
| 74 |
values @i<z>, (@i<x> < @i<z>) or (@i<z> < @i<y>).]} |
| 75 |
|
| 76 |
@end{Intro} |
| 77 |
|
| 78 |
@begin{Metarules} |
| 79 |
|
| 80 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 81 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]} |
| 82 |
@ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[subclause],Old=[clause]} |
| 83 |
provides a number of useful containers |
| 84 |
for Ada. Only the most useful containers are provided. Ones that are relatively |
| 85 |
easy to code, redundant, or rarely used are omitted from this set, even if they |
| 86 |
are generally included in containers libraries.]} |
| 87 |
|
| 88 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 89 |
@ChgAdded{Version=[2],Text=[The containers packages are modeled on the Standard Template Library (STL), an |
| 90 |
algorithms and data structure library popularized by Alexander Stepanov, and |
| 91 |
included in the C++ standard library. The structure and terminology differ from |
| 92 |
the STL where that better maps to common Ada usage. For instance, what the STL |
| 93 |
calls @lquotes@;iterators@rquotes@; are |
| 94 |
called @lquotes@;cursors@rquotes@; here.]} |
| 95 |
|
| 96 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 97 |
@ChgAdded{Version=[2],Type=[Leading],Text=[The following major nonlimited |
| 98 |
containers are provided:]} |
| 99 |
|
| 100 |
@begin{Itemize} |
| 101 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 102 |
@ChgAdded{Version=[2],Text=[(Expandable) Vectors of any nonlimited type;]} |
| 103 |
|
| 104 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 105 |
@ChgAdded{Version=[2],Text=[Doubly-linked Lists of any nonlimited type;]} |
| 106 |
|
| 107 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 108 |
@ChgAdded{Version=[2],Text=[Hashed Maps keyed by any nonlimited hashable type, |
| 109 |
and containing any nonlimited type;]} |
| 110 |
|
| 111 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 112 |
@ChgAdded{Version=[2],Text=[Ordered Maps keyed by any nonlimited ordered type, |
| 113 |
and containing any nonlimited type;]} |
| 114 |
|
| 115 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 116 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0136-1]} |
| 117 |
@ChgAdded{Version=[2],Text=[Hashed Sets of any nonlimited hashable type;@Chg{Version=[3],New=[],Old=[ and]}]} |
| 118 |
|
| 119 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 120 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0136-1]} |
| 121 |
@ChgAdded{Version=[2],Text=[Ordered Sets of any nonlimited ordered type@Chg{Version=[3],New=[;],Old=[.]}]} |
| 122 |
|
| 123 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0136-1]} |
| 124 |
@ChgAdded{Version=[3],Text=[Multiway Trees of any nonlimited type;]} |
| 125 |
|
| 126 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0069-1]} |
| 127 |
@ChgAdded{Version=[3],Text=[Holders of any (indefinite) nonlimited type;]} |
| 128 |
|
| 129 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0159-1]} |
| 130 |
@ChgAdded{Version=[3],Text=[Synchronized queues of any definite nonlimited type; and]} |
| 131 |
|
| 132 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0159-1]} |
| 133 |
@ChgAdded{Version=[3],Text=[Priority queues of any definite nonlimited type.]} |
| 134 |
@end{Itemize} |
| 135 |
|
| 136 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 137 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1]} |
| 138 |
@ChgAdded{Version=[2],Text=[Separate versions for definite and indefinite |
| 139 |
element types are provided, as those for definite types can be implemented more |
| 140 |
efficiently.@Chg{Version=[3],New=[ Similarly, a separate bounded version is |
| 141 |
provided in order to give more predictable memory usage.],Old=[]}]} |
| 142 |
|
| 143 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 144 |
@ChgAdded{Version=[2],Text=[Each container includes a cursor, which is a |
| 145 |
reference to an element within a container. Cursors generally remain valid as |
| 146 |
long as the container exists and the element referenced is not deleted. Many |
| 147 |
operations on cursors are common to all of the containers. This makes it |
| 148 |
possible to write generic algorithms that work on any kind of container.]} |
| 149 |
|
| 150 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 151 |
@ChgAdded{Version=[2],Text=[The containers packages are structured so that |
| 152 |
additional packages can be added in the future. Indeed, we hope that these |
| 153 |
packages provide the basis for a more extensive secondary standard for |
| 154 |
containers.]} |
| 155 |
|
| 156 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 157 |
@ChgAdded{Version=[2],Text=[If containers with similar functionality (but |
| 158 |
different performance characteristics) are provided (by the implementation or |
| 159 |
by a secondary standard), we suggest that a prefix be used to identify the |
| 160 |
class of the functionality: "Ada.Containers.Bounded_Sets" (for a set with a |
| 161 |
maximum number of elements); "Ada.Containers.Protected_Maps" (for a map which |
| 162 |
can be accessed by multiple tasks at one time); |
| 163 |
"Ada.Containers.Persistent_Vectors" (for a persistent vector which continues to |
| 164 |
exist between executions of a program) and so on.]} |
| 165 |
|
| 166 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 167 |
@ChgAdded{Version=[2],Type=[Leading],Text=[Note that the language already |
| 168 |
includes several requirements that are important to the use of containers. |
| 169 |
These include:]} |
| 170 |
|
| 171 |
@begin{Itemize} |
| 172 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 173 |
@ChgAdded{Version=[2],Text=[Library packages must be |
| 174 |
reentrant @en multiple tasks can use the packages as long as they operate on |
| 175 |
separate containers. Thus, it is only necessary for a user to protect a |
| 176 |
container if a single container needs to be used by multiple tasks.]} |
| 177 |
|
| 178 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 179 |
@ChgAdded{Version=[2],Text=[Language-defined types must stream "properly". |
| 180 |
That means that the stream attributes can be used to implement persistence |
| 181 |
of containers when necessary, and containers can be passed between |
| 182 |
partitions of a program.]} |
| 183 |
|
| 184 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 185 |
@ChgAdded{Version=[2],Text=[Equality of language-defined types must compose |
| 186 |
@lquotes@;properly@rquotes@;. This means that the version of "=" directly |
| 187 |
used by users is the same one that will be used in generics and in predefined |
| 188 |
equality operators of types with components of the containers and/or cursors. |
| 189 |
This prevents the abstraction from breaking unexpectedly.]} |
| 190 |
|
| 191 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0048-1]} |
| 192 |
@ChgAdded{Version=[3],Text=[Redispatching is not allowed (unless it is |
| 193 |
required). That means that overriding a container operation will not change |
| 194 |
the behavior of any other predefined container operation. This provides |
| 195 |
a stable base for extensions.]} |
| 196 |
@end{Itemize} |
| 197 |
|
| 198 |
|
| 199 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 200 |
@ChgAdded{Version=[2],Text=[If a container's element type is controlled, the |
| 201 |
point at which the element is finalized will depend on the implementation of |
| 202 |
the container. We do not specify precisely where this will happen (it will |
| 203 |
happen no later than the finalization of the container, of course) in order to |
| 204 |
give implementation's flexibility to cache, block, or split the nodes of the |
| 205 |
container. In particular, Delete does not necessarily finalize the element; the |
| 206 |
implementation may (or may not) hold the space for reuse.]} |
| 207 |
|
| 208 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 209 |
@ChgAdded{Version=[2],Text=[This is not likely to be a hardship, as the element |
| 210 |
type has to be nonlimited. Types used to manage scarce resources generally |
| 211 |
need to be limited. Otherwise, the amount of resources needed is hard to |
| 212 |
control, as the language allows a lot of variation in the number or order of |
| 213 |
adjusts/finalizations. For common uses of nonlimited controlled types such as |
| 214 |
managing storage, the types already have to manage arbitrary copies.]} |
| 215 |
|
| 216 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 217 |
@ChgAdded{Version=[2],Text=[The use of controlled types also brings up the |
| 218 |
possibility of failure of finalization (and thus deallocation) of an element. |
| 219 |
This is a @ldquote@;serious bug@rdquote@;, as AI95-179 puts it, so we don't try |
| 220 |
to specify what happens in that case. The implementation should propagate |
| 221 |
the exception.]} |
| 222 |
@end{Metarules} |
| 223 |
|
| 224 |
@begin{ImplNote} |
| 225 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 226 |
@ChgAdded{Version=[2],Text=[It is expected that exceptions propagated from |
| 227 |
these operations do not |
| 228 |
damage containers. That is, if Storage_Error is propagated because of an |
| 229 |
allocation failure, or Constraint_Error is propagated by the assignment of |
| 230 |
elements, the container can continue to be used without further exceptions. |
| 231 |
The intent is that it should be possible to recover from errors without |
| 232 |
losing data. We don't try to state this formally in most cases, because it is |
| 233 |
hard to define precisely what is and is not allowed behavior.]} |
| 234 |
@end{ImplNote} |
| 235 |
|
| 236 |
@begin{ImplNote} |
| 237 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 238 |
@ChgAdded{Version=[2],Text=[When this clause says that the behavior of |
| 239 |
something is unspecified@PDefn{unspecified}, we |
| 240 |
really mean that any result of executing Ada code short of erroneous |
| 241 |
execution is allowed. We do not mean that memory not belonging to the |
| 242 |
parameters of the operation can be trashed. When we mean to allow erroneous |
| 243 |
behavior, we specifically say that execution is erroneous. All this means |
| 244 |
if the containers are written in Ada is that checks should not be suppressed |
| 245 |
or removed assuming some behavior of other code, and that the implementation |
| 246 |
should take care to avoid creating internal dangling accesses by assuming |
| 247 |
behavior from generic formals that can't be guaranteed. We don't |
| 248 |
try to say this normatively because it would be fairly complex, and |
| 249 |
implementers are unlikely to increase their support costs by fielding |
| 250 |
implementations that are unstable if given buggy hash functions, et al.]} |
| 251 |
@end{ImplNote} |
| 252 |
|
| 253 |
@begin{StaticSem} |
| 254 |
@ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0035-1]} |
| 255 |
@ChgAdded{Version=[4],Text=[Certain subprograms declared within instances of |
| 256 |
some of the generic packages presented in this clause are said to @i<perform |
| 257 |
indefinite insertion>. These subprograms are those corresponding (in the sense |
| 258 |
of the copying described in subclause @RefSecNum{Generic Instantiation}) to |
| 259 |
subprograms that have formal parameters of a generic formal indefinite type and |
| 260 |
that are identified as performing indefinite insertion in the subclause defining |
| 261 |
the generic package.@Defn{perform indefinite insertion}]} |
| 262 |
|
| 263 |
@ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0035-1]} |
| 264 |
@ChgAdded{Version=[4],Type=[Leading],Text=[If a subprogram performs indefinite |
| 265 |
insertion, then certain run-time checks are performed as part of a call to the |
| 266 |
subprogram; if any of these checks fail, then the resulting exception is |
| 267 |
propagated to the caller and the container is not modified by the call. These |
| 268 |
checks are performed for each parameter corresponding (in the sense of the |
| 269 |
copying described in @RefSecNum{Generic Instantiation}) to a parameter in the |
| 270 |
corresponding generic whose type is a generic formal indefinite type. The checks |
| 271 |
performed for a given parameter are those checks explicitly specified in |
| 272 |
subclause @RefSecNum{Allocators} that would be performed as part of the |
| 273 |
evaluation of an initialized allocator whose access type is declared immediately |
| 274 |
within the instance, where:]} |
| 275 |
|
| 276 |
@begin{Itemize} |
| 277 |
@ChgRef{Version=[4],Kind=[AddedNormal]} |
| 278 |
@ChgAdded{Version=[4],Text=[the value of the @nt{qualified_expression} is |
| 279 |
that of the parameter; and]} |
| 280 |
|
| 281 |
@ChgRef{Version=[4],Kind=[AddedNormal]} |
| 282 |
@ChgAdded{Version=[4],Text=[the designated subtype of the access type is the |
| 283 |
subtype of the parameter; and]} |
| 284 |
|
| 285 |
@ChgRef{Version=[4],Kind=[AddedNormal]} |
| 286 |
@ChgAdded{Version=[4],Text=[finalization of the collection of the access type |
| 287 |
has started if and only if the finalization of the instance has started.]} |
| 288 |
@end{Itemize} |
| 289 |
|
| 290 |
@begin{Discussion} |
| 291 |
@ChgRef{Version=[4],Kind=[AddedNormal]} |
| 292 |
@ChgAdded{Version=[4],Text=[The phrase "explicitly specified" means those |
| 293 |
checks for which subclause @RefSecNum{Allocators} includes the phrase "<some |
| 294 |
exception> is raised if ...". It does not refer, for example, to any checks |
| 295 |
performed as part of any subtype conversion. In particular, this wording |
| 296 |
includes the checks described in subclause @RefSecNum{Allocators} to be |
| 297 |
performed in the case of a class-wide designated type, and of a designated |
| 298 |
subtype that has access discriminant parts. These checks are needed to prevent |
| 299 |
containers from outliving their contained (Element_Type or Key_Type) values.]} |
| 300 |
@end{Discussion} |
| 301 |
@begin{ImplNote} |
| 302 |
@ChgRef{Version=[4],Kind=[AddedNormal]} |
| 303 |
@ChgAdded{Version=[4],Text=[These rules have a dual purpose. Mainly, we are |
| 304 |
@i{requiring} checks needed to prevent dangling references. As a side effect, we |
| 305 |
are also @i{allowing} checks needed to permit an implementation of a container |
| 306 |
generic to make use of access types in a straightforward way. As an example of |
| 307 |
the second purpose, suppose that an implementation does declare such an access |
| 308 |
type and suppose further that the finalization of the collection of the |
| 309 |
access type has started. These rules allow Program_Error to be propagated |
| 310 |
in this case (as specified in @RefSecNum{Allocators}); this is necessary to |
| 311 |
allow an all-Ada implementation of these packages.]} |
| 312 |
@end{ImplNote} |
| 313 |
@end{StaticSem} |
| 314 |
|
| 315 |
@begin{Extend95} |
| 316 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 317 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]} |
| 318 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 319 |
This @Chg{Version=[3],New=[subclause],Old=[clause]} is new. It just |
| 320 |
provides an introduction to the following subclauses.]} |
| 321 |
@end{Extend95} |
| 322 |
|
| 323 |
@begin{DiffWord2005} |
| 324 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]} |
| 325 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a definition of |
| 326 |
strict weak ordering.]} |
| 327 |
@end{DiffWord2005} |
| 328 |
|
| 329 |
@begin{DiffWord2012} |
| 330 |
@ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI05-0035-1]} |
| 331 |
@ChgAdded{Version=[4],Text=[@b<Corrigendum:> Added a definition of |
| 332 |
@ldquote@;performs indefinite insertion@rdquote. This is used in |
| 333 |
other subclauses and any resulting inconsistencies are documented |
| 334 |
there.]} |
| 335 |
@end{DiffWord2012} |
| 336 |
|
| 337 |
|
| 338 |
@LabeledAddedSubclause{Version=[2],Name=[The Package Containers]} |
| 339 |
|
| 340 |
@begin{Intro} |
| 341 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 342 |
@ChgAdded{Version=[2],Text=[The package Containers is the root of |
| 343 |
the containers subsystem.]} |
| 344 |
@end{Intro} |
| 345 |
|
| 346 |
@begin{StaticSem} |
| 347 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 348 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The library package |
| 349 |
Containers has the following declaration:]} |
| 350 |
@begin{Example} |
| 351 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 352 |
@ChgAdded{Version=[2],Text=[@key{package} Ada.Containers @key{is}@ChildUnit{Parent=[Ada],Child=[Containers]} |
| 353 |
@key{pragma} Pure(Containers);]} |
| 354 |
|
| 355 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 356 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Hash_Type} @key{is mod} @i<implementation-defined>;]} |
| 357 |
|
| 358 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 359 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Count_Type} @key{is range} 0 .. @i<implementation-defined>;]} |
| 360 |
|
| 361 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 362 |
@ChgAdded{Version=[3],Text=[ @AdaExcDefn{Capacity_Error} : @key[exception];]} |
| 363 |
|
| 364 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 365 |
@ChgAdded{Version=[2],Text=[@key{end} Ada.Containers;]} |
| 366 |
@end{Example} |
| 367 |
|
| 368 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 369 |
@ChgAdded{Version=[2],Text=[Hash_Type represents the range of the result of a |
| 370 |
hash function. Count_Type represents the (potential or actual) number of |
| 371 |
elements of a container.]} |
| 372 |
@ChgImpldef{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 373 |
Text=[The value of Containers.Hash_Type'Modulus. The value of |
| 374 |
Containers.Count_Type'Last.]}]} |
| 375 |
|
| 376 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0262-1]} |
| 377 |
@ChgAdded{Version=[3],Text=[Capacity_Error is raised when the capacity of a |
| 378 |
container is exceeded.]} |
| 379 |
|
| 380 |
@end{StaticSem} |
| 381 |
|
| 382 |
@begin{ImplAdvice} |
| 383 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 384 |
@ChgAdded{Version=[2],Text=[Hash_Type'Modulus should be at least 2**32. |
| 385 |
Count_Type'Last should be at least 2**31@en@;1.]} |
| 386 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 387 |
Text=[Containers.Hash_Type'Modulus should be at least 2**32. |
| 388 |
Containers.Count_Type'Last should be at least 2**31@en@;1.]}]} |
| 389 |
|
| 390 |
@begin{Discussion} |
| 391 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 392 |
@ChgAdded{Version=[2],Text=[This is not a requirement so that these types |
| 393 |
can be declared |
| 394 |
properly on machines with native sizes that are not 32 bits. For instance, a |
| 395 |
24-bit target could use 2**24 for Hash_Type'Modulus.]} |
| 396 |
@end{Discussion} |
| 397 |
@end{ImplAdvice} |
| 398 |
|
| 399 |
@begin{Extend95} |
| 400 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 401 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 402 |
The package Containers is new.]} |
| 403 |
@end{Extend95} |
| 404 |
|
| 405 |
@begin{Incompatible2005} |
| 406 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 407 |
@ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Exception Capacity_Error |
| 408 |
is added to Containers. If Containers is referenced in a @nt{use_clause}, |
| 409 |
and an entity with the name Capacity_Error is defined in a package that is |
| 410 |
also referenced in a @nt{use_clause}, the entity Capacity_Error may no |
| 411 |
longer be use-visible, resulting in errors. This should be rare and is |
| 412 |
easily fixed if it does occur.]} |
| 413 |
@end{Incompatible2005} |
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
@LabeledAddedSubclause{Version=[2],Name=[The Generic Package Containers.Vectors]} |
| 418 |
|
| 419 |
@begin{Intro} |
| 420 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 421 |
@ChgAdded{Version=[2],Text=[The language-defined generic package |
| 422 |
Containers.Vectors provides private types Vector and Cursor, and a set of |
| 423 |
operations for each type. A vector container allows insertion and deletion at |
| 424 |
any position, but it is specifically optimized for insertion and deletion at |
| 425 |
the high end (the end with the higher index) of the container. A vector |
| 426 |
container also provides random access to its elements.@Defn{vector container} |
| 427 |
@Defn2{Term=[container],Sec=[vector]}]} |
| 428 |
|
| 429 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 430 |
@ChgAdded{Version=[2],Text=[@Pdefn2{Term=[length], Sec=(of a vector container)} |
| 431 |
@Pdefn2{Term=[capacity], Sec=(of a vector)} |
| 432 |
A vector container behaves conceptually as an array that expands as necessary |
| 433 |
as items are inserted. The @i{length} of a vector is the number of elements that |
| 434 |
the vector contains. The @i{capacity} of a vector is the maximum number of |
| 435 |
elements that can be inserted into the vector prior to it being automatically |
| 436 |
expanded.]} |
| 437 |
|
| 438 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 439 |
@ChgAdded{Version=[2],Text=[Elements in a vector container can be referred to by |
| 440 |
an index value of a generic formal type. The first element of a vector always |
| 441 |
has its index value equal to the lower bound of the formal type.]} |
| 442 |
|
| 443 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 444 |
@ChgAdded{Version=[2],Text=[@Pdefn2{Term=[empty element], Sec=(of a vector)} |
| 445 |
A vector container may contain @i{empty elements}. Empty elements do not have a |
| 446 |
specified value.]} |
| 447 |
|
| 448 |
@begin{ImplNote} |
| 449 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 450 |
@ChgAdded{Version=[2],Text=[ |
| 451 |
Vectors are not intended to be sparse (that is, there are elements at all |
| 452 |
defined positions). Users are expected to use other containers (like a Map) |
| 453 |
when they need sparse structures (there is a Note to this effect at the |
| 454 |
end of this subclause).]} |
| 455 |
|
| 456 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 457 |
@ChgAdded{Version=[2],Text=[ |
| 458 |
The internal array is a conceptual model of a vector. There is no requirement |
| 459 |
for an implementation to be a single contiguous array.]} |
| 460 |
@end{Implnote} |
| 461 |
@end{Intro} |
| 462 |
|
| 463 |
@begin{StaticSem} |
| 464 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 465 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library |
| 466 |
package Containers.Vectors has the following declaration:]} |
| 467 |
@begin{Example} |
| 468 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 469 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0084-1],ARef=[AI05-0212-1]} |
| 470 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[@key[with] Ada.Iterator_Interfaces; |
| 471 |
],Old=[]}@key{generic} |
| 472 |
@key{type} Index_Type @key{is range} <>; |
| 473 |
@key{type} Element_Type @key{is private}; |
| 474 |
@key{with function} "=" (Left, Right : Element_Type) |
| 475 |
@key{return} Boolean @key{is} <>; |
| 476 |
@key{package} Ada.Containers.Vectors @key{is}@ChildUnit{Parent=[Ada.Containers],Child=[Vectors]} |
| 477 |
@key{pragma} Preelaborate(Vectors);@Chg{Version=[3],New=[ |
| 478 |
@key{pragma} Remote_Types(Vectors);],Old=[]}]} |
| 479 |
|
| 480 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 481 |
@ChgAdded{Version=[2],Text=[ @key{subtype} @AdaSubtypeDefn{Name=[Extended_Index],Of=[Index_Type'Base]} @key{is} |
| 482 |
Index_Type'Base @key{range} |
| 483 |
Index_Type'First-1 .. |
| 484 |
Index_Type'Min (Index_Type'Base'Last - 1, Index_Type'Last) + 1; |
| 485 |
@AdaObjDefn{No_Index} : @key{constant} Extended_Index := Extended_Index'First;]} |
| 486 |
|
| 487 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 488 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]} |
| 489 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Vector} @key{is tagged private}@Chg{Version=[3],New=[ |
| 490 |
@key[with] Constant_Indexing => Constant_Reference, |
| 491 |
Variable_Indexing => Reference, |
| 492 |
Default_Iterator => Iterate, |
| 493 |
Iterator_Element => Element_Type],Old=[]}; |
| 494 |
@key{pragma} Preelaborable_Initialization(Vector);]} |
| 495 |
|
| 496 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 497 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private}; |
| 498 |
@key{pragma} Preelaborable_Initialization(Cursor);]} |
| 499 |
|
| 500 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 501 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{Empty_Vector} : @key{constant} Vector;]} |
| 502 |
|
| 503 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 504 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]} |
| 505 |
|
| 506 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 507 |
@ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]} |
| 508 |
|
| 509 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 510 |
@ChgAdded{Version=[3],Text=[ @key[package] @AdaPackDefn{Vector_Iterator_Interfaces} @key[is new] |
| 511 |
Ada.Iterator_Interfaces (Cursor, Has_Element);]} |
| 512 |
|
| 513 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 514 |
@ChgAdded{Version=[2],Text=[ @key{function} "=" (Left, Right : Vector) @key{return} Boolean;]} |
| 515 |
|
| 516 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 517 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{To_Vector} (Length : Count_Type) @key{return} Vector;]} |
| 518 |
|
| 519 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 520 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{To_Vector} |
| 521 |
(New_Item : Element_Type; |
| 522 |
Length : Count_Type) @key{return} Vector;]} |
| 523 |
|
| 524 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 525 |
@ChgAdded{Version=[2],Text=[ @key{function} "&" (Left, Right : Vector) @key{return} Vector;]} |
| 526 |
|
| 527 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 528 |
@ChgAdded{Version=[2],Text=[ @key{function} "&" (Left : Vector; |
| 529 |
Right : Element_Type) @key{return} Vector;]} |
| 530 |
|
| 531 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 532 |
@ChgAdded{Version=[2],Text=[ @key{function} "&" (Left : Element_Type; |
| 533 |
Right : Vector) @key{return} Vector;]} |
| 534 |
|
| 535 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 536 |
@ChgAdded{Version=[2],Text=[ @key{function} "&" (Left, Right : Element_Type) @key{return} Vector;]} |
| 537 |
|
| 538 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 539 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Capacity} (Container : Vector) @key{return} Count_Type;]} |
| 540 |
|
| 541 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 542 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reserve_Capacity} (Container : @key{in out} Vector; |
| 543 |
Capacity : @key{in} Count_Type);]} |
| 544 |
|
| 545 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 546 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Length} (Container : Vector) @key{return} Count_Type;]} |
| 547 |
|
| 548 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 549 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Set_Length} (Container : @key{in out} Vector; |
| 550 |
Length : @key{in} Count_Type);]} |
| 551 |
|
| 552 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 553 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Empty} (Container : Vector) @key{return} Boolean;]} |
| 554 |
|
| 555 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 556 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Clear} (Container : @key{in out} Vector);]} |
| 557 |
|
| 558 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 559 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{To_Cursor} (Container : Vector; |
| 560 |
Index : Extended_Index) @key{return} Cursor;]} |
| 561 |
|
| 562 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 563 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{To_Index} (Position : Cursor) @key{return} Extended_Index;]} |
| 564 |
|
| 565 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 566 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Container : Vector; |
| 567 |
Index : Index_Type) |
| 568 |
@key{return} Element_Type;]} |
| 569 |
|
| 570 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 571 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Position : Cursor) @key{return} Element_Type;]} |
| 572 |
|
| 573 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 574 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} Vector; |
| 575 |
Index : @key{in} Index_Type; |
| 576 |
New_Item : @key{in} Element_Type);]} |
| 577 |
|
| 578 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 579 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} Vector; |
| 580 |
Position : @key{in} Cursor; |
| 581 |
New_item : @key{in} Element_Type);]} |
| 582 |
|
| 583 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 584 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element} |
| 585 |
(Container : @key{in} Vector; |
| 586 |
Index : @key{in} Index_Type; |
| 587 |
Process : @key{not null access procedure} (Element : @key{in} Element_Type));]} |
| 588 |
|
| 589 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 590 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element} |
| 591 |
(Position : @key{in} Cursor; |
| 592 |
Process : @key{not null access procedure} (Element : @key{in} Element_Type));]} |
| 593 |
|
| 594 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 595 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element} |
| 596 |
(Container : @key{in out} Vector; |
| 597 |
Index : @key{in} Index_Type; |
| 598 |
Process : @key{not null access procedure} |
| 599 |
(Element : @key{in out} Element_Type));]} |
| 600 |
|
| 601 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 602 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element} |
| 603 |
(Container : @key{in out} Vector; |
| 604 |
Position : @key{in} Cursor; |
| 605 |
Process : @key{not null access procedure} |
| 606 |
(Element : @key{in out} Element_Type));]} |
| 607 |
|
| 608 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 609 |
@ChgAdded{Version=[3],Text=[ @key[type] Constant_Reference_Type |
| 610 |
(Element : @key[not null access constant] Element_Type) @key[is private] |
| 611 |
@key[with] Implicit_Dereference => Element;]} |
| 612 |
|
| 613 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 614 |
@ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Reference_Type} (Element : @key[not null access] Element_Type) @key[is private] |
| 615 |
@key[with] Implicit_Dereference => Element;]} |
| 616 |
|
| 617 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 618 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Vector; |
| 619 |
Index : @key[in] Index_Type) |
| 620 |
@key[return] Constant_Reference_Type;]} |
| 621 |
|
| 622 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 623 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] Vector; |
| 624 |
Index : @key[in] Index_Type) |
| 625 |
@key[return] Reference_Type;]} |
| 626 |
|
| 627 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 628 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Vector; |
| 629 |
Position : @key[in] Cursor) |
| 630 |
@key[return] Constant_Reference_Type;]} |
| 631 |
|
| 632 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 633 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] Vector; |
| 634 |
Position : @key[in] Cursor) |
| 635 |
@key[return] Reference_Type;]} |
| 636 |
|
| 637 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 638 |
@ChgAdded{Version=[3],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} Vector; Source : @key{in} Vector);]} |
| 639 |
|
| 640 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 641 |
@ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Copy} (Source : Vector; Capacity : Count_Type := 0) |
| 642 |
@key[return] Vector;]} |
| 643 |
|
| 644 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 645 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Move} (Target : @key{in out} Vector; |
| 646 |
Source : @key{in out} Vector);]} |
| 647 |
|
| 648 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 649 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector; |
| 650 |
Before : @key{in} Extended_Index; |
| 651 |
New_Item : @key{in} Vector);]} |
| 652 |
|
| 653 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 654 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector; |
| 655 |
Before : @key{in} Cursor; |
| 656 |
New_Item : @key{in} Vector);]} |
| 657 |
|
| 658 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 659 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector; |
| 660 |
Before : @key{in} Cursor; |
| 661 |
New_Item : @key{in} Vector; |
| 662 |
Position : @key{out} Cursor);]} |
| 663 |
|
| 664 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 665 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector; |
| 666 |
Before : @key{in} Extended_Index; |
| 667 |
New_Item : @key{in} Element_Type; |
| 668 |
Count : @key{in} Count_Type := 1);]} |
| 669 |
|
| 670 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 671 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector; |
| 672 |
Before : @key{in} Cursor; |
| 673 |
New_Item : @key{in} Element_Type; |
| 674 |
Count : @key{in} Count_Type := 1);]} |
| 675 |
|
| 676 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 677 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector; |
| 678 |
Before : @key{in} Cursor; |
| 679 |
New_Item : @key{in} Element_Type; |
| 680 |
Position : @key{out} Cursor; |
| 681 |
Count : @key{in} Count_Type := 1);]} |
| 682 |
|
| 683 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 684 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector; |
| 685 |
Before : @key{in} Extended_Index; |
| 686 |
Count : @key{in} Count_Type := 1);]} |
| 687 |
|
| 688 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 689 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Vector; |
| 690 |
Before : @key{in} Cursor; |
| 691 |
Position : @key{out} Cursor; |
| 692 |
Count : @key{in} Count_Type := 1);]} |
| 693 |
|
| 694 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 695 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Prepend} (Container : @key{in out} Vector; |
| 696 |
New_Item : @key{in} Vector);]} |
| 697 |
|
| 698 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 699 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Prepend} (Container : @key{in out} Vector; |
| 700 |
New_Item : @key{in} Element_Type; |
| 701 |
Count : @key{in} Count_Type := 1);]} |
| 702 |
|
| 703 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 704 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Append} (Container : @key{in out} Vector; |
| 705 |
New_Item : @key{in} Vector);]} |
| 706 |
|
| 707 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 708 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Append} (Container : @key{in out} Vector; |
| 709 |
New_Item : @key{in} Element_Type; |
| 710 |
Count : @key{in} Count_Type := 1);]} |
| 711 |
|
| 712 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 713 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert_Space} (Container : @key{in out} Vector; |
| 714 |
Before : @key{in} Extended_Index; |
| 715 |
Count : @key{in} Count_Type := 1);]} |
| 716 |
|
| 717 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 718 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert_Space} (Container : @key{in out} Vector; |
| 719 |
Before : @key{in} Cursor; |
| 720 |
Position : @key{out} Cursor; |
| 721 |
Count : @key{in} Count_Type := 1);]} |
| 722 |
|
| 723 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 724 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Vector; |
| 725 |
Index : @key{in} Extended_Index; |
| 726 |
Count : @key{in} Count_Type := 1);]} |
| 727 |
|
| 728 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 729 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Vector; |
| 730 |
Position : @key{in out} Cursor; |
| 731 |
Count : @key{in} Count_Type := 1);]} |
| 732 |
|
| 733 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 734 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_First} (Container : @key{in out} Vector; |
| 735 |
Count : @key{in} Count_Type := 1);]} |
| 736 |
|
| 737 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 738 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_Last} (Container : @key{in out} Vector; |
| 739 |
Count : @key{in} Count_Type := 1);]} |
| 740 |
|
| 741 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 742 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reverse_Elements} (Container : @key{in out} Vector);]} |
| 743 |
|
| 744 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 745 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Swap} (Container : @key{in out} Vector; |
| 746 |
I, J : @key{in} Index_Type);]} |
| 747 |
|
| 748 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 749 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Swap} (Container : @key{in out} Vector; |
| 750 |
I, J : @key{in} Cursor);]} |
| 751 |
|
| 752 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 753 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First_Index} (Container : Vector) @key{return} Index_Type;]} |
| 754 |
|
| 755 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 756 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First} (Container : Vector) @key{return} Cursor;]} |
| 757 |
|
| 758 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 759 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First_Element} (Container : Vector) |
| 760 |
@key{return} Element_Type;]} |
| 761 |
|
| 762 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 763 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last_Index} (Container : Vector) @key{return} Extended_Index;]} |
| 764 |
|
| 765 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 766 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last} (Container : Vector) @key{return} Cursor;]} |
| 767 |
|
| 768 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 769 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last_Element} (Container : Vector) |
| 770 |
@key{return} Element_Type;]} |
| 771 |
|
| 772 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 773 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Next} (Position : Cursor) @key{return} Cursor;]} |
| 774 |
|
| 775 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 776 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Next} (Position : @key{in out} Cursor);]} |
| 777 |
|
| 778 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 779 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Previous} (Position : Cursor) @key{return} Cursor;]} |
| 780 |
|
| 781 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 782 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Previous} (Position : @key{in out} Cursor);]} |
| 783 |
|
| 784 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 785 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find_Index} (Container : Vector; |
| 786 |
Item : Element_Type; |
| 787 |
Index : Index_Type := Index_Type'First) |
| 788 |
@key{return} Extended_Index;]} |
| 789 |
|
| 790 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 791 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Vector; |
| 792 |
Item : Element_Type; |
| 793 |
Position : Cursor := No_Element) |
| 794 |
@key{return} Cursor;]} |
| 795 |
|
| 796 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 797 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Reverse_Find_Index} (Container : Vector; |
| 798 |
Item : Element_Type; |
| 799 |
Index : Index_Type := Index_Type'Last) |
| 800 |
@key{return} Extended_Index;]} |
| 801 |
|
| 802 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 803 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Reverse_Find} (Container : Vector; |
| 804 |
Item : Element_Type; |
| 805 |
Position : Cursor := No_Element) |
| 806 |
@key{return} Cursor;]} |
| 807 |
|
| 808 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 809 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Vector; |
| 810 |
Item : Element_Type) @key{return} Boolean;]} |
| 811 |
|
| 812 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 813 |
@ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0212-1]} |
| 814 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]}]} |
| 815 |
|
| 816 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 817 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Iterate} |
| 818 |
(Container : @key{in} Vector; |
| 819 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 820 |
|
| 821 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 822 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reverse_Iterate} |
| 823 |
(Container : @key{in} Vector; |
| 824 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 825 |
|
| 826 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 827 |
@ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] Vector) |
| 828 |
@key[return] Vector_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 829 |
|
| 830 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 831 |
@ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] Vector; Start : @key[in] Cursor) |
| 832 |
@key[return] Vector_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 833 |
|
| 834 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 835 |
@ChgAdded{Version=[2],Text=[ @key{generic} |
| 836 |
@key{with function} "<" (Left, Right : Element_Type) |
| 837 |
@key{return} Boolean is <>; |
| 838 |
@key{package} @AdaPackDefn{Generic_Sorting} @key{is}]} |
| 839 |
|
| 840 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 841 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Sorted} (Container : Vector) @key{return} Boolean;]} |
| 842 |
|
| 843 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 844 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Sort} (Container : @key{in out} Vector);]} |
| 845 |
|
| 846 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 847 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Merge} (Target : @key{in out} Vector; |
| 848 |
Source : @key{in out} Vector);]} |
| 849 |
|
| 850 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 851 |
@ChgAdded{Version=[2],Text=[ @key{end} Generic_Sorting;]} |
| 852 |
|
| 853 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 854 |
@ChgAdded{Version=[2],Text=[@key{private}]} |
| 855 |
|
| 856 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 857 |
@ChgAdded{Version=[2],Text=[ ... -- @RI[not specified by the language]]} |
| 858 |
|
| 859 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 860 |
@ChgAdded{Version=[2],Text=[@key{end} Ada.Containers.Vectors;]} |
| 861 |
|
| 862 |
@end{Example} |
| 863 |
|
| 864 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 865 |
@ChgAdded{Version=[2],Text=[The actual function for the generic formal function |
| 866 |
"=" on Element_Type values is expected to define a reflexive and symmetric |
| 867 |
relationship and return the same result value each time it is called with a |
| 868 |
particular pair of values. If it behaves in some other manner, the functions |
| 869 |
defined to use it return an unspecified value. The exact arguments and number |
| 870 |
of calls of this generic formal function by the functions defined to use it are |
| 871 |
unspecified.@PDefn{unspecified}]} |
| 872 |
|
| 873 |
@begin{Ramification} |
| 874 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 875 |
@ChgAdded{Version=[2],Text=[The @lquotes@;functions defined to use it@rquotes |
| 876 |
are Find, Find_Index, Reverse_Find, Reverse_Find_Index, and |
| 877 |
"=" for Vectors. This list is a bit too long to give explicitly.]} |
| 878 |
|
| 879 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 880 |
@ChgAdded{Version=[2],Text=[If the actual function for "=" is not symmetric |
| 881 |
and consistent, the result returned by any of the functions defined to use |
| 882 |
"=" cannot be predicted. The implementation is not required to protect |
| 883 |
against "=" raising an exception, or returning random results, or any |
| 884 |
other @lquotes@;bad@rquotes behavior. And it can call "=" in whatever |
| 885 |
manner makes sense. But note that only the results of the functions defined |
| 886 |
to use "=" are unspecified; other subprograms are not allowed to break if |
| 887 |
"=" is bad.]} |
| 888 |
@end{Ramification} |
| 889 |
|
| 890 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 891 |
@ChgAdded{Version=[2],Text=[The type Vector is used to represent vectors. |
| 892 |
The type Vector needs finalization@PDefn2{Term=<needs finalization>, |
| 893 |
Sec=<language-defined type>} |
| 894 |
(see @RefSecNum{Assignment and Finalization}).]} |
| 895 |
|
| 896 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 897 |
@ChgAdded{Version=[2],Text=[Empty_Vector represents the empty vector object. It |
| 898 |
has a length of 0. If an object of type Vector is not otherwise initialized, it |
| 899 |
is initialized to the same value as Empty_Vector.]} |
| 900 |
|
| 901 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 902 |
@ChgAdded{Version=[2],Text=[No_Element represents a cursor that designates no |
| 903 |
element. If an object of type Cursor is not otherwise initialized, it is |
| 904 |
initialized to the same value as No_Element.]} |
| 905 |
|
| 906 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 907 |
@ChgAdded{Version=[2],Text=[The predefined "=" operator for type Cursor returns |
| 908 |
True if both cursors are No_Element, or designate the same element in the same |
| 909 |
container.]} |
| 910 |
|
| 911 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 912 |
@ChgAdded{Version=[2],Text=[Execution of the default implementation of the |
| 913 |
Input, Output, Read, or Write attribute of type Cursor raises Program_Error.]} |
| 914 |
|
| 915 |
@begin{Reason} |
| 916 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 917 |
@ChgAdded{Version=[2],Text=[A cursor will probably be implemented in terms |
| 918 |
of one or more access values, and the effects of streaming access values is |
| 919 |
unspecified. Rather than letting the user stream junk by accident, we mandate |
| 920 |
that streaming of cursors raise Program_Error by default. The attributes |
| 921 |
can always be specified if there is a need to support streaming.]} |
| 922 |
@end{Reason} |
| 923 |
|
| 924 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]} |
| 925 |
@ChgAdded{Version=[3],Text=[Vector'Write for a Vector object @i<V> writes |
| 926 |
Length(@i<V>) elements of the vector to the stream. It also may write |
| 927 |
additional information about the vector.]} |
| 928 |
|
| 929 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]} |
| 930 |
@ChgAdded{Version=[3],Text=[Vector'Read reads the representation of a vector |
| 931 |
from the stream, and assigns to @i<Item> a vector with the same length and |
| 932 |
elements as was written by Vector'Write.]} |
| 933 |
|
| 934 |
@begin{ImplNote} |
| 935 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 936 |
@ChgAdded{Version=[3],Text=[The Standard requires streaming of all |
| 937 |
language-defined nonlimited types (including containers) to "work" (see |
| 938 |
@RefSecNum{Stream-Oriented Attributes}). In addition, we do not want all |
| 939 |
of the elements that make up the |
| 940 |
capacity of the vector streamed, as those beyond the length of the container |
| 941 |
have undefined contents (and might cause bad things when read back in). |
| 942 |
This will require a custom stream attribute |
| 943 |
implementation; the language-defined default implementation will not work |
| 944 |
(even for a bounded form, as that would most likely stream the entire |
| 945 |
capacity of the vector). There is a separate requirement that the unbounded |
| 946 |
and Bounded form use the same streaming representation for the same element |
| 947 |
type, see @RefSecNum{The Generic Package Containers.Bounded_Vectors}.]} |
| 948 |
@end{ImplNote} |
| 949 |
|
| 950 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 951 |
@ChgAdded{Version=[2],Text=[No_Index represents a position that does not |
| 952 |
correspond to any element. The subtype Extended_Index includes the indices |
| 953 |
covered by Index_Type plus the value No_Index and, if it exists, the successor |
| 954 |
to the Index_Type'Last.]} |
| 955 |
|
| 956 |
@begin{Discussion} |
| 957 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 958 |
@ChgAdded{Version=[2],Text=[We require the existence of Index_Type'First @en 1, |
| 959 |
so that No_Index and Last_Index of an empty vector is well-defined. We don't |
| 960 |
require the existence of Index_Type'Last + 1, as it is only used as the |
| 961 |
position of insertions (and needs to be allowed only when inserting an empty |
| 962 |
vector).]} |
| 963 |
@end{Discussion} |
| 964 |
|
| 965 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 966 |
@ChgAdded{Version=[3],Text=[If an operation attempts to modify the vector such |
| 967 |
that the position of the last element would be greater than Index_Type'Last, |
| 968 |
then the operation propagates Constraint_Error.]} |
| 969 |
|
| 970 |
@begin{Reason} |
| 971 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 972 |
@ChgAdded{Version=[3],Text=[We don't want to require an implementation to |
| 973 |
go to heroic efforts to handle index values larger than the base type of |
| 974 |
the index subtype.]} |
| 975 |
@end{Reason} |
| 976 |
|
| 977 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 978 |
@ChgAdded{Version=[2],Text=[@Redundant[Some operations of this generic package |
| 979 |
have access-to-subprogram parameters. To ensure such operations are |
| 980 |
well-defined, they guard against certain actions by the designated |
| 981 |
subprogram. In particular, some operations check for @lquotes@;tampering with |
| 982 |
cursors@rquotes of a container because they depend on the set of elements of |
| 983 |
the container remaining constant, and others check for @lquotes@;tampering with |
| 984 |
elements@rquotes of a container because they depend on elements of the |
| 985 |
container not being replaced.]]} |
| 986 |
|
| 987 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 988 |
@ChgAdded{Version=[2],Type=[Leading],Text=[@Defn2{Term=[tamper with cursors],Sec=[of a vector]} |
| 989 |
A subprogram is said to |
| 990 |
@i{tamper with cursors} of a vector object @i<V> if:]} |
| 991 |
|
| 992 |
@begin{Itemize} |
| 993 |
|
| 994 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 995 |
@ChgAdded{Version=[2],Text=[it inserts or deletes elements of @i<V>, that is, |
| 996 |
it calls the Insert, Insert_Space, Clear, Delete, or Set_Length procedures with |
| 997 |
@i<V> as a parameter; or]} |
| 998 |
|
| 999 |
@begin{Honest} |
| 1000 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1001 |
@ChgAdded{Version=[2],Text=[Operations which are defined to be equivalent to |
| 1002 |
a call on one of these operations also are included. Similarly, operations |
| 1003 |
which call one of these as part of their definition are included.]} |
| 1004 |
@end{Honest} |
| 1005 |
|
| 1006 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1007 |
@ChgAdded{Version=[2],Text=[it finalizes @i<V>; or]} |
| 1008 |
|
| 1009 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 1010 |
@ChgAdded{Version=[3],Text=[it calls the Assign procedure with @i<V> as the Target parameter; |
| 1011 |
or]} |
| 1012 |
|
| 1013 |
@begin{Ramification} |
| 1014 |
@ChgRef{Version=[3],Kind=[Added]} |
| 1015 |
@ChgAdded{Version=[3],Text=[We don't need to explicitly mention |
| 1016 |
@nt{assignment_statement}, because that finalizes the target object |
| 1017 |
as part of the operation, and finalization of an object is already defined |
| 1018 |
as tampering with cursors.]} |
| 1019 |
@end{Ramification} |
| 1020 |
|
| 1021 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1022 |
@ChgAdded{Version=[2],Text=[it calls the Move procedure with @i<V> as |
| 1023 |
a parameter.]} |
| 1024 |
|
| 1025 |
@begin{Discussion} |
| 1026 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1027 |
@ChgAdded{Version=[2],Text=[Swap, Sort, and Merge copy elements rather |
| 1028 |
than reordering them, so they don't tamper with cursors.]} |
| 1029 |
@end{Discussion} |
| 1030 |
|
| 1031 |
@end{Itemize} |
| 1032 |
|
| 1033 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1034 |
@ChgAdded{Version=[2],Type=[Leading],Text=[@Defn2{Term=[tamper with elements],Sec=[of a vector]} |
| 1035 |
A subprogram is said to @i{tamper with elements} of a vector object @i<V> if:]} |
| 1036 |
|
| 1037 |
@begin{Itemize} |
| 1038 |
|
| 1039 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1040 |
@ChgAdded{Version=[2],Text=[it tampers with cursors of @i<V>; or]} |
| 1041 |
|
| 1042 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1043 |
@ChgAdded{Version=[2],Text=[it replaces one or more elements of @i<V>, that is, |
| 1044 |
it calls the Replace_Element, Reverse_Elements, or Swap procedures or the Sort |
| 1045 |
or Merge procedures of an instance of Generic_Sorting with @i<V> as a |
| 1046 |
parameter.]} |
| 1047 |
|
| 1048 |
@begin{Reason} |
| 1049 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1050 |
@ChgAdded{Version=[2],Text=[Complete replacement of an element can cause its |
| 1051 |
memory to be deallocated while another operation is holding onto a reference |
| 1052 |
to it. That can't be allowed. However, a simple modification of (part of) an |
| 1053 |
element is not a problem, so Update_Element does not cause a problem.]} |
| 1054 |
@end{Reason} |
| 1055 |
|
| 1056 |
@end{Itemize} |
| 1057 |
|
| 1058 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0265-1]} |
| 1059 |
@ChgRef{Version=[4],Kind=[RevisedAdded],ARef=[AI12-0110-1]} |
| 1060 |
@ChgAdded{Version=[3],Text=[@Defn2{Term=[prohibited],Sec=[tampering with a vector]} |
| 1061 |
@Defn2{Term=[tampering],Sec=[prohibited for a vector]} |
| 1062 |
When tampering with cursors is @i<prohibited> for a particular vector object |
| 1063 |
@i<V>, Program_Error is propagated by a call of any language-defined subprogram |
| 1064 |
that is defined to tamper with the cursors of @i<V>, leaving @i<V> unmodified. |
| 1065 |
Similarly, when tampering with elements is @i<prohibited> for a particular vector |
| 1066 |
object @i<V>, Program_Error is propagated by a call of any language-defined |
| 1067 |
subprogram that is defined to tamper with the elements of @i<V> @Redundant[(or |
| 1068 |
tamper with the cursors of @i<V>)], leaving @i<V> |
| 1069 |
unmodified.@Chg{Version=[4],New=[ These checks are made before any other |
| 1070 |
defined behavior of the body of the language-defined subprogram.],Old=[]}]} |
| 1071 |
@begin{TheProof} |
| 1072 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 1073 |
@ChgAdded{Version=[3],Text=[Tampering with elements includes tampering with |
| 1074 |
cursors, so we mention it only from completeness in the second sentence.]} |
| 1075 |
@end{TheProof} |
| 1076 |
|
| 1077 |
@begin{DescribeCode} |
| 1078 |
|
| 1079 |
@begin{Example} |
| 1080 |
@ChgRef{Version=[3],Kind=[Added]} |
| 1081 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean;]} |
| 1082 |
@end{Example} |
| 1083 |
|
| 1084 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 1085 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns True if Position designates |
| 1086 |
an element, and returns False otherwise.]} |
| 1087 |
|
| 1088 |
@begin{Honest} |
| 1089 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1],ARef=[AI05-0212-1]} |
| 1090 |
@ChgAdded{Version=[3],Text=[This function might not detect cursors that |
| 1091 |
designate deleted elements; such cursors are invalid (see below) and the |
| 1092 |
result of calling Has_Element with an invalid cursor is unspecified (but |
| 1093 |
not erroneous).]} |
| 1094 |
@end{Honest} |
| 1095 |
|
| 1096 |
@begin{Example} |
| 1097 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1098 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "=" (Left, Right : Vector) @key{return} Boolean;]} |
| 1099 |
@end{Example} |
| 1100 |
|
| 1101 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1102 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 1103 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Left and Right denote the same |
| 1104 |
vector object, then the function returns True. If Left and Right have different |
| 1105 |
lengths, then the function returns False. |
| 1106 |
Otherwise, it compares each element in Left to |
| 1107 |
the corresponding element in Right using the generic formal equality operator. |
| 1108 |
If any such comparison returns False, the function returns False; |
| 1109 |
otherwise@Chg{Version=[3],New=[,],Old=[]} it |
| 1110 |
returns True. Any exception raised during |
| 1111 |
evaluation of element equality is propagated.]} |
| 1112 |
|
| 1113 |
@begin{ImplNote} |
| 1114 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1115 |
@ChgAdded{Version=[2],Text=[This wording describes the canonical semantics. |
| 1116 |
However, the order and number of calls on the formal equality function is |
| 1117 |
unspecified for all of the operations that use it in this package, so an |
| 1118 |
implementation can call it as many or as few times as it needs to get the |
| 1119 |
correct answer. Specifically, there is no requirement to call the formal |
| 1120 |
equality additional times once the answer has been determined.]} |
| 1121 |
@end{ImplNote} |
| 1122 |
|
| 1123 |
@begin{Example} |
| 1124 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1125 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} To_Vector (Length : Count_Type) @key{return} Vector;]} |
| 1126 |
@end{Example} |
| 1127 |
|
| 1128 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1129 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a vector with a length of |
| 1130 |
Length, filled with empty elements.]} |
| 1131 |
|
| 1132 |
@begin{Example} |
| 1133 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1134 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} To_Vector |
| 1135 |
(New_Item : Element_Type; |
| 1136 |
Length : Count_Type) @key{return} Vector;]} |
| 1137 |
@end{Example} |
| 1138 |
|
| 1139 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1140 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a vector with a length of |
| 1141 |
Length, filled with elements initialized to the value New_Item.]} |
| 1142 |
|
| 1143 |
@begin{Example} |
| 1144 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1145 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "&" (Left, Right : Vector) @key{return} Vector;]} |
| 1146 |
@end{Example} |
| 1147 |
|
| 1148 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1149 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a vector comprising the |
| 1150 |
elements of Left followed by the elements of Right.]} |
| 1151 |
|
| 1152 |
@begin{Example} |
| 1153 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1154 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "&" (Left : Vector; |
| 1155 |
Right : Element_Type) @key{return} Vector;]} |
| 1156 |
@end{Example} |
| 1157 |
|
| 1158 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1159 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a vector comprising the |
| 1160 |
elements of Left followed by the element Right.]} |
| 1161 |
|
| 1162 |
@begin{Example} |
| 1163 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1164 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "&" (Left : Element_Type; |
| 1165 |
Right : Vector) @key{return} Vector;]} |
| 1166 |
@end{Example} |
| 1167 |
|
| 1168 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1169 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a vector comprising the |
| 1170 |
element Left followed by the elements of Right.]} |
| 1171 |
|
| 1172 |
@begin{Example} |
| 1173 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1174 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "&" (Left, Right : Element_Type) @key{return} Vector;]} |
| 1175 |
@end{Example} |
| 1176 |
|
| 1177 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1178 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a vector comprising the |
| 1179 |
element Left followed by the element Right.]} |
| 1180 |
|
| 1181 |
@begin{Example} |
| 1182 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1183 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Capacity (Container : Vector) @key{return} Count_Type;]} |
| 1184 |
@end{Example} |
| 1185 |
|
| 1186 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1187 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the capacity of Container.]} |
| 1188 |
|
| 1189 |
@begin{Example} |
| 1190 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1191 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reserve_Capacity (Container : @key{in out} Vector; |
| 1192 |
Capacity : @key{in} Count_Type);]} |
| 1193 |
@end{Example} |
| 1194 |
|
| 1195 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1196 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1],ARef=[AI05-0264-1]} |
| 1197 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[If the |
| 1198 |
capacity of Container is already greater than or equal to Capacity, then |
| 1199 |
Reserve_Capacity has no effect. Otherwise, ],Old=[]}Reserve_Capacity allocates |
| 1200 |
@Chg{Version=[3],New=[additional storage as necessary to |
| 1201 |
ensure],Old=[new internal data structures such]} that the length of the |
| 1202 |
resulting vector can become at least the value Capacity without requiring an additional call to |
| 1203 |
Reserve_Capacity, and is large enough to hold the current length of Container. |
| 1204 |
Reserve_Capacity then@Chg{Version=[3],New=[, as necessary, moves],Old=[ copies the]} |
| 1205 |
elements into the new @Chg{Version=[3],New=[storage],Old=[data structures]} and |
| 1206 |
deallocates @Chg{Version=[3],New=[any storage no longer needed],Old=[the old |
| 1207 |
data structures]}. Any exception raised during allocation is |
| 1208 |
propagated and Container is not modified.]} |
| 1209 |
|
| 1210 |
@begin{Discussion} |
| 1211 |
|
| 1212 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1213 |
@ChgAdded{Version=[2],Text=[Expanding the internal array can be done by |
| 1214 |
allocating a new, longer array, copying the elements, and deallocating the |
| 1215 |
original array. This may raise Storage_Error, or cause an exception from a |
| 1216 |
controlled subprogram. We require that a failed Reserve_Capacity does not |
| 1217 |
lose any elements if an exception occurs, but we do not require a specific |
| 1218 |
order of evaluations or copying.]} |
| 1219 |
|
| 1220 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1221 |
@ChgAdded{Version=[2],Text=[This routine is used to preallocate the internal |
| 1222 |
array to the specified capacity such that future Inserts do not require |
| 1223 |
memory allocation overhead. Therefore, the implementation should allocate the |
| 1224 |
needed memory to make that true at this point, even though the visible |
| 1225 |
semantics could be preserved by waiting until the memory is needed. This |
| 1226 |
doesn't apply to the indefinite element container, because elements will have |
| 1227 |
to be allocated individually.]} |
| 1228 |
|
| 1229 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1230 |
@ChgAdded{Version=[2],Text=[The implementation does not have to contract the |
| 1231 |
internal array if the capacity is reduced, as any capacity greater than or |
| 1232 |
equal to the specified capacity is allowed.]} |
| 1233 |
|
| 1234 |
@end{Discussion} |
| 1235 |
|
| 1236 |
@begin{Example} |
| 1237 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1238 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Length (Container : Vector) @key{return} Count_Type;]} |
| 1239 |
@end{Example} |
| 1240 |
|
| 1241 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1242 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the number of elements in Container.]} |
| 1243 |
|
| 1244 |
@begin{Example} |
| 1245 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1246 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Set_Length (Container : @key{in out} Vector; |
| 1247 |
Length : @key{in} Count_Type);]} |
| 1248 |
@end{Example} |
| 1249 |
|
| 1250 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1251 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 1252 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Length is larger than the |
| 1253 |
capacity of Container, Set_Length calls Reserve_Capacity (Container, Length), |
| 1254 |
then sets the length of the Container to Length. If Length is greater than the |
| 1255 |
original length of Container, empty elements are added to Container; |
| 1256 |
otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 1257 |
elements are removed from Container.]} |
| 1258 |
|
| 1259 |
@begin{Ramification} |
| 1260 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1261 |
@ChgAdded{Version=[2],Text=[No elements are moved by this operation; any new |
| 1262 |
empty elements are added at the end. This follows from the rules that a |
| 1263 |
cursor continues to designate the same element unless the routine is |
| 1264 |
defined to make the cursor ambiguous or invalid; this operation does not do |
| 1265 |
that.]} |
| 1266 |
@end{Ramification} |
| 1267 |
|
| 1268 |
@begin{Example} |
| 1269 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1270 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Is_Empty (Container : Vector) @key{return} Boolean;]} |
| 1271 |
@end{Example} |
| 1272 |
|
| 1273 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1274 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Length (Container) = 0.]} |
| 1275 |
|
| 1276 |
@begin{Example} |
| 1277 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1278 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Clear (Container : @key{in out} Vector);]} |
| 1279 |
@end{Example} |
| 1280 |
|
| 1281 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1282 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Removes all the elements from |
| 1283 |
Container. The capacity of Container does not change.]} |
| 1284 |
|
| 1285 |
@begin{Example} |
| 1286 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1287 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} To_Cursor (Container : Vector; |
| 1288 |
Index : Extended_Index) @key{return} Cursor;]} |
| 1289 |
@end{Example} |
| 1290 |
|
| 1291 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1292 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Index is not in the range |
| 1293 |
First_Index (Container) .. Last_Index (Container), then No_Element is returned. |
| 1294 |
Otherwise, a cursor designating the element at position Index in Container is |
| 1295 |
returned.]} |
| 1296 |
|
| 1297 |
@begin{Example} |
| 1298 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1299 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} To_Index (Position : Cursor) @key{return} Extended_Index;]} |
| 1300 |
@end{Example} |
| 1301 |
|
| 1302 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1303 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position is No_Element, No_Index |
| 1304 |
is returned. Otherwise, the index (within its containing vector) of the element |
| 1305 |
designated by Position is returned.]} |
| 1306 |
|
| 1307 |
@begin{Ramification} |
| 1308 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1309 |
@ChgAdded{Version=[2],Text=[This implies that the index is determinable from |
| 1310 |
a bare cursor alone. The basic model is that a vector cursor is implemented |
| 1311 |
as a record containing an access to the vector container and an index value. |
| 1312 |
This does constrain implementations, but it also allows all of the cursor |
| 1313 |
operations to be defined in terms of the corresponding index operation (which |
| 1314 |
should be primary for a vector).]} |
| 1315 |
@end{Ramification} |
| 1316 |
|
| 1317 |
@begin{Example} |
| 1318 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1319 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Element (Container : Vector; |
| 1320 |
Index : Index_Type) |
| 1321 |
@key{return} Element_Type;]} |
| 1322 |
@end{Example} |
| 1323 |
|
| 1324 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1325 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Index is not in the range |
| 1326 |
First_Index (Container) .. Last_Index (Container), then Constraint_Error is |
| 1327 |
propagated. Otherwise, Element returns the element at position Index.]} |
| 1328 |
|
| 1329 |
@begin{Example} |
| 1330 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1331 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Element (Position : Cursor) @key{return} Element_Type;]} |
| 1332 |
@end{Example} |
| 1333 |
|
| 1334 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1335 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 1336 |
Constraint_Error is propagated. Otherwise, Element returns the element |
| 1337 |
designated by Position.]} |
| 1338 |
|
| 1339 |
@begin{Example} |
| 1340 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1341 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace_Element (Container : @key{in out} Vector; |
| 1342 |
Index : @key{in} Index_Type; |
| 1343 |
New_Item : @key{in} Element_Type);]} |
| 1344 |
@end{Example} |
| 1345 |
|
| 1346 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1347 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 1348 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Index is not in the range |
| 1349 |
First_Index (Container) .. Last_Index (Container), then Constraint_Error is |
| 1350 |
propagated. Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 1351 |
Replace_Element assigns the value New_Item to the element at |
| 1352 |
position Index. Any exception raised during the assignment is propagated. The |
| 1353 |
element at position Index is not an empty element after successful call to |
| 1354 |
Replace_Element.]} |
| 1355 |
|
| 1356 |
@begin{Example} |
| 1357 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1358 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace_Element (Container : @key{in out} Vector; |
| 1359 |
Position : @key{in} Cursor; |
| 1360 |
New_Item : @key{in} Element_Type);]} |
| 1361 |
@end{Example} |
| 1362 |
|
| 1363 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1364 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 1365 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, |
| 1366 |
then Constraint_Error is propagated; if Position does not designate an element |
| 1367 |
in Container, then Program_Error is propagated. |
| 1368 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} Replace_Element |
| 1369 |
assigns New_Item to the element designated by Position. Any exception raised |
| 1370 |
during the assignment is propagated. The element at Position is not an empty |
| 1371 |
element after successful call to Replace_Element.]} |
| 1372 |
|
| 1373 |
@begin{Ramification} |
| 1374 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1375 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]} |
| 1376 |
@ChgAdded{Version=[2],Text=[Replace_Element@Chg{Version=[3],New=[,],Old=[ and]} |
| 1377 |
Update_Element@Chg{Version=[3],New=[, and Reference],Old=[]} are the only |
| 1378 |
ways that an element can change from empty to nonempty. Also see the note |
| 1379 |
following Update_Element.]} |
| 1380 |
@end{Ramification} |
| 1381 |
|
| 1382 |
@begin{Example} |
| 1383 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1384 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Query_Element |
| 1385 |
(Container : @key{in} Vector; |
| 1386 |
Index : @key{in} Index_Type; |
| 1387 |
Process : @key{not null access} @key{procedure} (Element : @key{in} Element_Type));]} |
| 1388 |
@end{Example} |
| 1389 |
|
| 1390 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1391 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]} |
| 1392 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Index is not in the range |
| 1393 |
First_Index (Container) .. Last_Index (Container), then Constraint_Error is |
| 1394 |
propagated. Otherwise, Query_Element calls Process.@key{all} with the element at |
| 1395 |
position Index as the argument. |
| 1396 |
@Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 1397 |
is propagated if Process.@key{all} tampers]} |
| 1398 |
with the elements of Container@Chg{Version=[3],New=[ is prohibited during the |
| 1399 |
execution of the call on Process.@key{all}],Old=[]}. Any exception raised by |
| 1400 |
Process.@key{all} is propagated.]} |
| 1401 |
|
| 1402 |
@begin{Reason} |
| 1403 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI05-0005-1]} |
| 1404 |
@ChgAdded{Version=[2],Text=[The @lquotes@;tamper with the elements@rquotes@; |
| 1405 |
check is intended to prevent the Element parameter of Process from being |
| 1406 |
@Chg{Version=[3],New=[replaced],Old=[modified]} or deleted |
| 1407 |
outside of Process. The check prevents data loss (if Element_Type is passed by |
| 1408 |
copy) or erroneous execution (if Element_Type is an unconstrained type in an |
| 1409 |
indefinite container).]} |
| 1410 |
@end{Reason} |
| 1411 |
|
| 1412 |
@begin{Example} |
| 1413 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1414 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Query_Element |
| 1415 |
(Position : @key{in} Cursor; |
| 1416 |
Process : @key{not null access} @key{procedure} (Element : @key{in} Element_Type));]} |
| 1417 |
@end{Example} |
| 1418 |
|
| 1419 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1420 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1],ARef=[AI05-0265-1]} |
| 1421 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 1422 |
Constraint_Error is propagated. Otherwise, Query_Element calls |
| 1423 |
Process.@key{all} with the element designated by Position as the argument. |
| 1424 |
@Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 1425 |
is propagated if Process.@key{all} tampers]} |
| 1426 |
with the elements of @Chg{Version=[3],New=[the vector that contains the |
| 1427 |
element designated by Position is prohibited during the |
| 1428 |
execution of the call on Process.@key{all}],Old=[Container]}. Any |
| 1429 |
exception raised by Process.@key{all} is propagated.]} |
| 1430 |
|
| 1431 |
@begin{Example} |
| 1432 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1433 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Update_Element |
| 1434 |
(Container : @key{in out} Vector; |
| 1435 |
Index : @key{in} Index_Type; |
| 1436 |
Process : @key{not null access} @key{procedure} (Element : @key{in out} Element_Type));]} |
| 1437 |
@end{Example} |
| 1438 |
|
| 1439 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1440 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]} |
| 1441 |
@ChgAdded{Version=[2],Text=[If Index is not in the range |
| 1442 |
First_Index (Container) .. Last_Index (Container), then Constraint_Error is |
| 1443 |
propagated. Otherwise, Update_Element calls Process.@key{all} with the element |
| 1444 |
at position Index as the argument. |
| 1445 |
@Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 1446 |
is propagated if Process.@key{all} tampers]} |
| 1447 |
with the elements of Container@Chg{Version=[3],New=[ is prohibited during the |
| 1448 |
execution of the call on Process.@key{all}],Old=[]}. Any exception raised by |
| 1449 |
Process.@key{all} is propagated.]} |
| 1450 |
|
| 1451 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1452 |
@ChgAdded{Version=[2],Text=[If Element_Type is unconstrained and definite, then |
| 1453 |
the actual Element parameter of Process.@key{all} shall be unconstrained.]} |
| 1454 |
|
| 1455 |
@begin{Ramification} |
| 1456 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1457 |
@ChgAdded{Version=[2],Text=[This means that the elements cannot be directly |
| 1458 |
allocated from the heap; it must be possible to change the discriminants of |
| 1459 |
the element in place.]} |
| 1460 |
@end{Ramification} |
| 1461 |
|
| 1462 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1463 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[The element at position Index is |
| 1464 |
not an empty element after successful completion of this operation.]} |
| 1465 |
|
| 1466 |
@begin{Ramification} |
| 1467 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1468 |
@ChgAdded{Version=[2],Text=[Since reading an empty element is a bounded |
| 1469 |
error, attempting to use this procedure to replace empty elements may fail. |
| 1470 |
Use Replace_Element to do that reliably.]} |
| 1471 |
@end{Ramification} |
| 1472 |
|
| 1473 |
@begin{Example} |
| 1474 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1475 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Update_Element |
| 1476 |
(Container : @key{in out} Vector; |
| 1477 |
Position : @key{in} Cursor; |
| 1478 |
Process : @key{not null access} @key{procedure} (Element : @key{in out} Element_Type));]} |
| 1479 |
@end{Example} |
| 1480 |
|
| 1481 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1482 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1],ARef=[AI05-0265-1]} |
| 1483 |
@ChgAdded{Version=[2],Text=[If Position equals No_Element, then |
| 1484 |
Constraint_Error is propagated; if Position does not designate an element in |
| 1485 |
Container, then Program_Error is propagated. |
| 1486 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} Update_Element calls |
| 1487 |
Process.@key{all} with the element designated by Position as the argument. |
| 1488 |
@Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 1489 |
is propagated if Process.@key{all} tampers]} |
| 1490 |
with the elements of Container@Chg{Version=[3],New=[ is prohibited during the |
| 1491 |
execution of the call on Process.@key{all}],Old=[]}. Any exception raised by |
| 1492 |
Process.@key{all} is propagated.]} |
| 1493 |
|
| 1494 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1495 |
@ChgAdded{Version=[2],Text=[If Element_Type is unconstrained and definite, then |
| 1496 |
the actual Element parameter of Process.@key{all} shall be unconstrained.]} |
| 1497 |
|
| 1498 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1499 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[The element designated by Position |
| 1500 |
is not an empty element after successful completion of this operation.]} |
| 1501 |
|
| 1502 |
@begin{Example} |
| 1503 |
@ChgRef{Version=[3],Kind=[Added]} |
| 1504 |
@ChgAdded{Version=[3],Text=[@key[type] Constant_Reference_Type |
| 1505 |
(Element : @key[not null access constant] Element_Type) @key[is private] |
| 1506 |
@key[with] Implicit_Dereference => Element;]} |
| 1507 |
|
| 1508 |
@ChgRef{Version=[3],Kind=[Added]} |
| 1509 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[type] Reference_Type (Element : @key[not null access] Element_Type) @key[is private] |
| 1510 |
@key[with] Implicit_Dereference => Element;]} |
| 1511 |
@end{Example} |
| 1512 |
|
| 1513 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 1514 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[The types Constant_Reference_Type |
| 1515 |
and Reference_Type need finalization.@PDefn2{Term=<needs finalization>, |
| 1516 |
Sec=<language-defined type>}]} |
| 1517 |
|
| 1518 |
@ChgRef{Version=[3],Kind=[Added]} |
| 1519 |
@ChgAdded{Version=[3],Text=[The default initialization of an object of type |
| 1520 |
Constant_Reference_Type or Reference_Type propagates Program_Error.]} |
| 1521 |
|
| 1522 |
@begin{Reason} |
| 1523 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 1524 |
@ChgAdded{Version=[3],Text=[It is expected that Reference_Type (and |
| 1525 |
Constant_Reference_Type) will be a controlled type, for which finalization |
| 1526 |
will have some action to terminate the tampering check for the associated |
| 1527 |
container. If the object is created by default, however, there is no |
| 1528 |
associated container. Since this is useless, and supporting this case would |
| 1529 |
take extra work, we define it to raise an exception.]} |
| 1530 |
@end{Reason} |
| 1531 |
|
| 1532 |
@begin{Example} |
| 1533 |
@ChgRef{Version=[3],Kind=[Added]} |
| 1534 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] Vector; |
| 1535 |
Index : @key[in] Index_Type) |
| 1536 |
@key[return] Constant_Reference_Type;]} |
| 1537 |
@end{Example} |
| 1538 |
|
| 1539 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 1540 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 1541 |
Constant_Indexing and Implicit_Dereference aspects) provides a convenient way to |
| 1542 |
gain read access to an individual element of a vector given an |
| 1543 |
index value.]} |
| 1544 |
|
| 1545 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]} |
| 1546 |
@ChgAdded{Version=[3],Text=[If Index is not in the range First_Index (Container) |
| 1547 |
.. Last_Index (Container), then Constraint_Error is propagated. Otherwise, |
| 1548 |
Constant_Reference returns an object whose discriminant is an access value that |
| 1549 |
designates the element at position Index. Tampering with the elements of |
| 1550 |
Container is prohibited while the object returned by Constant_Reference exists |
| 1551 |
and has not been finalized.]} |
| 1552 |
|
| 1553 |
@begin{Example} |
| 1554 |
@ChgRef{Version=[3],Kind=[Added]} |
| 1555 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference (Container : @key[aliased in out] Vector; |
| 1556 |
Index : @key[in] Index_Type) |
| 1557 |
@key[return] Reference_Type;]} |
| 1558 |
@end{Example} |
| 1559 |
|
| 1560 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 1561 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 1562 |
Variable_Indexing and Implicit_Dereference aspects) provides a convenient way to |
| 1563 |
gain read and write access to an individual element of a vector given |
| 1564 |
an index value.]} |
| 1565 |
|
| 1566 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]} |
| 1567 |
@ChgAdded{Version=[3],Text=[If Index is not in the range First_Index (Container) |
| 1568 |
.. Last_Index (Container), then Constraint_Error is propagated. Otherwise, |
| 1569 |
Reference returns an object whose discriminant is an access value that |
| 1570 |
designates the element at position Index. Tampering with the elements of |
| 1571 |
Container is prohibited while the object returned by Reference exists and has |
| 1572 |
not been finalized.]} |
| 1573 |
|
| 1574 |
@ChgRef{Version=[3],Kind=[Added]} |
| 1575 |
@ChgAdded{Version=[3],Text=[The element at position Index is not an empty |
| 1576 |
element after successful completion of this operation.]} |
| 1577 |
|
| 1578 |
@begin{Example} |
| 1579 |
@ChgRef{Version=[3],Kind=[Added]} |
| 1580 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] Vector; |
| 1581 |
Position : @key[in] Cursor) |
| 1582 |
@key[return] Constant_Reference_Type;]} |
| 1583 |
@end{Example} |
| 1584 |
|
| 1585 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 1586 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 1587 |
Constant_Indexing and Implicit_Dereference aspects) provides a convenient way to |
| 1588 |
gain read access to an individual element of a vector given a cursor.]} |
| 1589 |
|
| 1590 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]} |
| 1591 |
@ChgAdded{Version=[3],Text=[If Position equals No_Element, then Constraint_Error |
| 1592 |
is propagated; if Position does not designate an element in Container, then |
| 1593 |
Program_Error is propagated. Otherwise, Constant_Reference returns an object |
| 1594 |
whose discriminant is an access value that designates the element designated by |
| 1595 |
Position. Tampering with the elements of Container is prohibited while the |
| 1596 |
object returned by Constant_Reference exists and has not been finalized.]} |
| 1597 |
|
| 1598 |
@begin{Example} |
| 1599 |
@ChgRef{Version=[3],Kind=[Added]} |
| 1600 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference (Container : @key[aliased in out] Vector; |
| 1601 |
Position : @key[in] Cursor) |
| 1602 |
@key[return] Reference_Type;]} |
| 1603 |
@end{Example} |
| 1604 |
|
| 1605 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 1606 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 1607 |
Variable_Indexing and Implicit_Dereference aspects) provides a convenient way to |
| 1608 |
gain read and write access to an individual element of a vector given |
| 1609 |
a cursor.]} |
| 1610 |
|
| 1611 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]} |
| 1612 |
@ChgAdded{Version=[3],Text=[If Position equals No_Element, then Constraint_Error |
| 1613 |
is propagated; if Position does not designate an element in Container, then |
| 1614 |
Program_Error is propagated. Otherwise, Reference returns an object whose |
| 1615 |
discriminant is an access value that designates the element designated by |
| 1616 |
Position. Tampering with the elements of Container is prohibited while the |
| 1617 |
object returned by Reference exists and has not been finalized.]} |
| 1618 |
|
| 1619 |
@ChgRef{Version=[3],Kind=[Added]} |
| 1620 |
@ChgAdded{Version=[3],Text=[The element designated by Position is not an empty |
| 1621 |
element after successful completion of this operation.]} |
| 1622 |
|
| 1623 |
@begin{Example} |
| 1624 |
@ChgRef{Version=[3],Kind=[Added]} |
| 1625 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key{procedure} Assign (Target : @key{in out} Vector; Source : @key{in} Vector);]} |
| 1626 |
@end{Example} |
| 1627 |
|
| 1628 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0262-1]} |
| 1629 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[If Target denotes the same object as |
| 1630 |
Source, the operation has no effect. If the length of Source is greater than the |
| 1631 |
capacity of Target, Reserve_Capacity (Target, Length (Source)) is called. |
| 1632 |
The elements of Source are then copied to Target as for an |
| 1633 |
@nt{assignment_statement} assigning Source to Target (this includes |
| 1634 |
setting the length of Target to be that of Source).]} |
| 1635 |
@begin{Discussion} |
| 1636 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1]} |
| 1637 |
@ChgAdded{Version=[3],Text=[This routine exists for compatibility with the |
| 1638 |
bounded vector container. For an unbounded vector, @exam{Assign(A, B)} and |
| 1639 |
@exam{A := B} behave identically. For a bounded vector, := will raise an |
| 1640 |
exception if the container capacities are different, while Assign will |
| 1641 |
not raise an exception if there is enough room in the target.]} |
| 1642 |
@end{Discussion} |
| 1643 |
|
| 1644 |
@begin{Example} |
| 1645 |
@ChgRef{Version=[3],Kind=[Added]} |
| 1646 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key{function} Copy (Source : Vector; Capacity : Count_Type := 0) |
| 1647 |
@key[return] Vector;]} |
| 1648 |
@end{Example} |
| 1649 |
|
| 1650 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 1651 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns a vector whose elements are |
| 1652 |
initialized from the corresponding elements of Source. If Capacity is 0, then |
| 1653 |
the vector capacity is the length of Source; if Capacity is equal to or greater |
| 1654 |
than the length of Source, the vector capacity is at least the specified value. |
| 1655 |
Otherwise, the operation propagates Capacity_Error.]} |
| 1656 |
|
| 1657 |
|
| 1658 |
@begin{Example} |
| 1659 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1660 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Move (Target : @key{in out} Vector; |
| 1661 |
Source : @key{in out} Vector);]} |
| 1662 |
@end{Example} |
| 1663 |
|
| 1664 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1665 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1],ARef=[AI05-0248-1]} |
| 1666 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Target denotes the same object |
| 1667 |
as Source, then @Chg{Version=[3],New=[the operation],Old=[Move]} |
| 1668 |
has no effect. Otherwise, Move first calls |
| 1669 |
@Chg{Version=[3],New=[Reserve_Capacity (Target, Length (Source)) |
| 1670 |
and then ],Old=[]}Clear (Target); |
| 1671 |
then, each element from Source is removed from Source and inserted into Target |
| 1672 |
in the original order. The length of Source is 0 after a successful call to |
| 1673 |
Move.]} |
| 1674 |
|
| 1675 |
@begin{Discussion} |
| 1676 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1677 |
@ChgAdded{Version=[2],Text=[The idea is that the internal array is removed |
| 1678 |
from Source and moved to Target. (See the @ImplAdviceName for Move). If |
| 1679 |
Capacity (Target) /= 0, the previous internal array may need to be |
| 1680 |
deallocated. We don't mention this explicitly, because it is covered by the |
| 1681 |
"no memory loss" @ImplReqName@;.]} |
| 1682 |
@end{Discussion} |
| 1683 |
|
| 1684 |
@begin{Example} |
| 1685 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1686 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector; |
| 1687 |
Before : @key{in} Extended_Index; |
| 1688 |
New_Item : @key{in} Vector);]} |
| 1689 |
@end{Example} |
| 1690 |
|
| 1691 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1692 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 1693 |
@ChgAdded{Version=[2],Text=[If Before is not in the range First_Index |
| 1694 |
(Container) .. Last_Index (Container) + 1, then Constraint_Error is propagated. |
| 1695 |
If Length(New_Item) is 0, then Insert does nothing. Otherwise, it computes the |
| 1696 |
new length @i<NL> as the sum of the current length and Length (New_Item); if |
| 1697 |
the value of Last appropriate for length @i<NL> would be greater than |
| 1698 |
Index_Type'Last@Chg{Version=[3],New=[,],Old=[]} then |
| 1699 |
Constraint_Error is propagated.]} |
| 1700 |
|
| 1701 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1702 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If the current vector capacity is |
| 1703 |
less than @i<NL>, Reserve_Capacity (Container, @i<NL>) is called to |
| 1704 |
increase the vector capacity. Then Insert slides the elements in the range |
| 1705 |
Before .. Last_Index (Container) up by Length(New_Item) positions, and then |
| 1706 |
copies the elements of New_Item to the positions starting at Before. Any |
| 1707 |
exception raised during the copying is propagated.]} |
| 1708 |
|
| 1709 |
@begin{Ramification} |
| 1710 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1711 |
@ChgAdded{Version=[2],Text=[Moving the elements does not necessarily involve |
| 1712 |
copying. Similarly, since Reserve_Capacity does not require the copying of |
| 1713 |
elements, it does not need to be explicitly called (the implementation can |
| 1714 |
combine the operations if it wishes to).]} |
| 1715 |
@end{Ramification} |
| 1716 |
|
| 1717 |
@begin{Example} |
| 1718 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1719 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector; |
| 1720 |
Before : @key{in} Cursor; |
| 1721 |
New_Item : @key{in} Vector);]} |
| 1722 |
@end{Example} |
| 1723 |
|
| 1724 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1725 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 1726 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Before is not No_Element, and |
| 1727 |
does not designate an element in Container, then Program_Error is propagated. |
| 1728 |
Otherwise, if |
| 1729 |
Length(New_Item) is 0, then Insert does nothing. If Before is No_Element, then |
| 1730 |
the call is equivalent to Insert (Container, Last_Index (Container) + 1, |
| 1731 |
New_Item); otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 1732 |
the call is equivalent to Insert (Container, To_Index |
| 1733 |
(Before), New_Item);]} |
| 1734 |
|
| 1735 |
@begin{Ramification} |
| 1736 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1737 |
@ChgAdded{Version=[2],Text=[The check on Before checks that the cursor does |
| 1738 |
not belong to some other Container. This check implies that a reference to |
| 1739 |
the container is included in the cursor value. This wording is not meant to |
| 1740 |
require detection of dangling cursors; such cursors are defined to be |
| 1741 |
invalid, which means that execution is erroneous, and any result is allowed |
| 1742 |
(including not raising an exception).]} |
| 1743 |
@end{Ramification} |
| 1744 |
|
| 1745 |
@begin{Example} |
| 1746 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1747 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector; |
| 1748 |
Before : @key{in} Cursor; |
| 1749 |
New_Item : @key{in} Vector; |
| 1750 |
Position : @key{out} Cursor);]} |
| 1751 |
@end{Example} |
| 1752 |
|
| 1753 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1754 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Before is not No_Element, and |
| 1755 |
does not designate an element in Container, then Program_Error is propagated. |
| 1756 |
If Before |
| 1757 |
equals No_Element, then let @i<T> be Last_Index (Container) + 1; otherwise, let |
| 1758 |
@i<T> be To_Index (Before). Insert (Container, @i<T>, New_Item) is called, and |
| 1759 |
then Position is set to To_Cursor (Container, @i<T>).]} |
| 1760 |
|
| 1761 |
@begin{Discussion} |
| 1762 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1763 |
@ChgAdded{Version=[2],Text=[The messy wording is needed because Before is |
| 1764 |
invalidated by Insert, and we don't want Position to be invalid after this |
| 1765 |
call. An implementation probably only needs to copy Before to Position.]} |
| 1766 |
@end{Discussion} |
| 1767 |
|
| 1768 |
@begin{Example} |
| 1769 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1770 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector; |
| 1771 |
Before : @key{in} Extended_Index; |
| 1772 |
New_Item : @key{in} Element_Type; |
| 1773 |
Count : @key{in} Count_Type := 1);]} |
| 1774 |
@end{Example} |
| 1775 |
|
| 1776 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1777 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, Before, To_Vector (New_Item, Count));]} |
| 1778 |
|
| 1779 |
@begin{Example} |
| 1780 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1781 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector; |
| 1782 |
Before : @key{in} Cursor; |
| 1783 |
New_Item : @key{in} Element_Type; |
| 1784 |
Count : @key{in} Count_Type := 1);]} |
| 1785 |
@end{Example} |
| 1786 |
|
| 1787 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1788 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, Before, To_Vector (New_Item, Count));]} |
| 1789 |
|
| 1790 |
@begin{Example} |
| 1791 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1792 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector; |
| 1793 |
Before : @key{in} Cursor; |
| 1794 |
New_Item : @key{in} Element_Type; |
| 1795 |
Position : @key{out} Cursor; |
| 1796 |
Count : @key{in} Count_Type := 1);]} |
| 1797 |
@end{Example} |
| 1798 |
|
| 1799 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1800 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, Before, To_Vector (New_Item, Count), Position);]} |
| 1801 |
|
| 1802 |
@begin{Ramification} |
| 1803 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0257-1]} |
| 1804 |
@ChgAdded{Version=[3],Text=[If Count equals 0, Position will designate the |
| 1805 |
element designated by Before, rather than a newly inserted element. Otherwise, |
| 1806 |
Position will designate the first newly inserted element.]} |
| 1807 |
@end{Ramification} |
| 1808 |
|
| 1809 |
@begin{Example} |
| 1810 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1811 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector; |
| 1812 |
Before : @key{in} Extended_Index; |
| 1813 |
Count : @key{in} Count_Type := 1);]} |
| 1814 |
@end{Example} |
| 1815 |
|
| 1816 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1817 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 1818 |
@ChgAdded{Version=[2],Text=[If Before is not in the range |
| 1819 |
First_Index (Container) .. Last_Index (Container) + 1, then Constraint_Error is |
| 1820 |
propagated. If Count is 0, then Insert does nothing. Otherwise, it |
| 1821 |
computes the new length @i<NL> as the sum of the current length and Count; if |
| 1822 |
the value of Last appropriate for length @i<NL> would be greater than |
| 1823 |
Index_Type'Last@Chg{Version=[3],New=[,],Old=[]} then |
| 1824 |
Constraint_Error is propagated.]} |
| 1825 |
|
| 1826 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1827 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If the current vector capacity is |
| 1828 |
less than @i<NL>, Reserve_Capacity (Container, @i<NL>) is called to |
| 1829 |
increase the vector capacity. Then Insert slides the elements in the |
| 1830 |
range Before .. Last_Index (Container) up by Count positions, and then inserts |
| 1831 |
elements that are initialized by default (see @RefSecNum{Object Declarations}) |
| 1832 |
in the positions starting at Before.]} |
| 1833 |
|
| 1834 |
@begin{Example} |
| 1835 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1836 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Vector; |
| 1837 |
Before : @key{in} Cursor; |
| 1838 |
Position : @key{out} Cursor; |
| 1839 |
Count : @key{in} Count_Type := 1);]} |
| 1840 |
@end{Example} |
| 1841 |
|
| 1842 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1843 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Before is not No_Element, and |
| 1844 |
does not designate an element in Container, then Program_Error is propagated. |
| 1845 |
If Before |
| 1846 |
equals No_Element, then let @i<T> be Last_Index (Container) + 1; otherwise, let |
| 1847 |
@i<T> be To_Index (Before). Insert (Container, @i<T>, Count) is called, |
| 1848 |
and then Position is set to To_Cursor (Container, @i<T>).]} |
| 1849 |
|
| 1850 |
@begin{Reason} |
| 1851 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1852 |
@ChgAdded{Version=[2],Text=[This routine exists mainly to ease conversion |
| 1853 |
between Vector and List containers. Unlike Insert_Space, this routine |
| 1854 |
default initializes the elements it inserts, which can be more expensive |
| 1855 |
for some element types.]} |
| 1856 |
@end{Reason} |
| 1857 |
|
| 1858 |
@begin{Example} |
| 1859 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1860 |
@ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0080-1]} |
| 1861 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Prepend (Container : @key{in out} Vector; |
| 1862 |
New_Item : @key{in} Vector@Chg{Version=[4],New=[],Old=[; |
| 1863 |
Count : @key{in} Count_Type := 1]});]} |
| 1864 |
@end{Example} |
| 1865 |
|
| 1866 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1867 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, First_Index (Container), New_Item).]} |
| 1868 |
|
| 1869 |
@begin{Example} |
| 1870 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1871 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Prepend (Container : @key{in out} Vector; |
| 1872 |
New_Item : @key{in} Element_Type; |
| 1873 |
Count : @key{in} Count_Type := 1);]} |
| 1874 |
@end{Example} |
| 1875 |
|
| 1876 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1877 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, First_Index (Container), New_Item, Count).]} |
| 1878 |
|
| 1879 |
@begin{Example} |
| 1880 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1881 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Append (Container : @key{in out} Vector; |
| 1882 |
New_Item : @key{in} Vector);]} |
| 1883 |
@end{Example} |
| 1884 |
|
| 1885 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1886 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, Last_Index (Container) + 1, New_Item).]} |
| 1887 |
|
| 1888 |
@begin{Example} |
| 1889 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1890 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Append (Container : @key{in out} Vector; |
| 1891 |
New_Item : @key{in} Element_Type; |
| 1892 |
Count : @key{in} Count_Type := 1);]} |
| 1893 |
@end{Example} |
| 1894 |
|
| 1895 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1896 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, Last_Index (Container) + 1, New_Item, Count).]} |
| 1897 |
|
| 1898 |
@begin{Example} |
| 1899 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1900 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert_Space (Container : @key{in out} Vector; |
| 1901 |
Before : @key{in} Extended_Index; |
| 1902 |
Count : @key{in} Count_Type := 1);]} |
| 1903 |
@end{Example} |
| 1904 |
|
| 1905 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1906 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 1907 |
@ChgAdded{Version=[2],Text=[If Before is not in the range |
| 1908 |
First_Index (Container) .. Last_Index (Container) + 1, then Constraint_Error is |
| 1909 |
propagated. If Count is 0, then Insert_Space does nothing. Otherwise, it |
| 1910 |
computes the new length @i<NL> as the sum of the current length and Count; if |
| 1911 |
the value of Last appropriate for length @i<NL> would be greater than |
| 1912 |
Index_Type'Last@Chg{Version=[3],New=[,],Old=[]} then |
| 1913 |
Constraint_Error is propagated.]} |
| 1914 |
|
| 1915 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1916 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If the current vector capacity is |
| 1917 |
less than @i<NL>, Reserve_Capacity (Container, @i<NL>) is called to |
| 1918 |
increase the vector capacity. Then Insert_Space slides the elements in the |
| 1919 |
range Before .. Last_Index (Container) up by Count positions, and then inserts |
| 1920 |
empty elements in the positions starting at Before.]} |
| 1921 |
|
| 1922 |
@begin{Example} |
| 1923 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1924 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert_Space (Container : @key{in out} Vector; |
| 1925 |
Before : @key{in} Cursor; |
| 1926 |
Position : @key{out} Cursor; |
| 1927 |
Count : @key{in} Count_Type := 1);]} |
| 1928 |
@end{Example} |
| 1929 |
|
| 1930 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1931 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Before is not No_Element, and |
| 1932 |
does not designate an element in Container, then Program_Error is propagated. |
| 1933 |
If Before |
| 1934 |
equals No_Element, then let @i<T> be Last_Index (Container) + 1; otherwise, let |
| 1935 |
@i<T> be To_Index (Before). Insert_Space (Container, @i<T>, Count) is called, |
| 1936 |
and then Position is set to To_Cursor (Container, @i<T>).]} |
| 1937 |
|
| 1938 |
@begin{Example} |
| 1939 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1940 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Vector; |
| 1941 |
Index : @key{in} Extended_Index; |
| 1942 |
Count : @key{in} Count_Type := 1);]} |
| 1943 |
@end{Example} |
| 1944 |
|
| 1945 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1946 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 1947 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Index is not in the range |
| 1948 |
First_Index (Container) .. Last_Index (Container) + 1, then Constraint_Error is |
| 1949 |
propagated. If Count is 0, Delete has no effect. |
| 1950 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} Delete slides the |
| 1951 |
elements (if any) starting at position Index + Count down to Index. Any |
| 1952 |
exception raised during element assignment is propagated.]} |
| 1953 |
|
| 1954 |
@begin{Ramification} |
| 1955 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1956 |
@ChgAdded{Version=[2],Text=[If Index + Count >= Last_Index(Container), this |
| 1957 |
effectively truncates the vector (setting Last_Index to Index @en 1 and |
| 1958 |
consequently sets Length to Index @en Index_Type'First).]} |
| 1959 |
@end{Ramification} |
| 1960 |
|
| 1961 |
@begin{Example} |
| 1962 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1963 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Vector; |
| 1964 |
Position : @key{in out} Cursor; |
| 1965 |
Count : @key{in} Count_Type := 1);]} |
| 1966 |
@end{Example} |
| 1967 |
|
| 1968 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1969 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 1970 |
Constraint_Error is propagated. If Position does not designate an element in |
| 1971 |
Container, then Program_Error is propagated. Otherwise, Delete (Container, |
| 1972 |
To_Index (Position), Count) is called, and then Position is set to No_Element.]} |
| 1973 |
|
| 1974 |
@begin{Example} |
| 1975 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1976 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_First (Container : @key{in out} Vector; |
| 1977 |
Count : @key{in} Count_Type := 1);]} |
| 1978 |
@end{Example} |
| 1979 |
|
| 1980 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1981 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Delete (Container, First_Index (Container), Count).]} |
| 1982 |
|
| 1983 |
@begin{Example} |
| 1984 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1985 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_Last (Container : @key{in out} Vector; |
| 1986 |
Count : @key{in} Count_Type := 1);]} |
| 1987 |
@end{Example} |
| 1988 |
|
| 1989 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 1990 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 1991 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If |
| 1992 |
Length (Container) <= Count@Chg{Version=[3],New=[,],Old=[]} then |
| 1993 |
Delete_Last is equivalent to Clear (Container). |
| 1994 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} it is equivalent to |
| 1995 |
Delete (Container, Index_Type'Val(Index_Type'Pos(Last_Index (Container)) @en |
| 1996 |
Count + 1), Count).]} |
| 1997 |
|
| 1998 |
@begin{Example} |
| 1999 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0092-1]} |
| 2000 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2001 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reverse_Elements (Container : @key{in out} @Chg{Version=[3],New=[Vector],Old=[List]});]} |
| 2002 |
@end{Example} |
| 2003 |
|
| 2004 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2005 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Reorders the elements of Container |
| 2006 |
in reverse order.]} |
| 2007 |
|
| 2008 |
@begin{Discussion} |
| 2009 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2010 |
@ChgAdded{Version=[2],Text=[This can copy the elements of the vector @em |
| 2011 |
all cursors referencing the vector are ambiguous afterwards and may |
| 2012 |
designate different elements afterwards.]} |
| 2013 |
@end{Discussion} |
| 2014 |
|
| 2015 |
@begin{Example} |
| 2016 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2017 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Swap (Container : @key{in out} Vector; |
| 2018 |
I, J : @key{in} Index_Type);]} |
| 2019 |
@end{Example} |
| 2020 |
|
| 2021 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2022 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If either I or J is not in the range |
| 2023 |
First_Index (Container) .. Last_Index (Container), then Constraint_Error is |
| 2024 |
propagated. Otherwise, Swap exchanges the values of the elements at positions I |
| 2025 |
and J.]} |
| 2026 |
|
| 2027 |
@begin{Honest} |
| 2028 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2029 |
@ChgAdded{Version=[2],Text=[The implementation is not required to actually |
| 2030 |
copy the elements if it can do the swap some other way. But it is allowed |
| 2031 |
to copy the elements if needed.]} |
| 2032 |
@end{Honest} |
| 2033 |
|
| 2034 |
@begin{Example} |
| 2035 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2036 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Swap (Container : @key{in out} Vector; |
| 2037 |
I, J : @key{in} Cursor);]} |
| 2038 |
@end{Example} |
| 2039 |
|
| 2040 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2041 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If either I or J is No_Element, |
| 2042 |
then Constraint_Error is propagated. If either I or J do not designate an |
| 2043 |
element in Container, then Program_Error is propagated. Otherwise, Swap |
| 2044 |
exchanges the values of the elements designated by I and J.]} |
| 2045 |
|
| 2046 |
@begin{Ramification} |
| 2047 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2048 |
@ChgAdded{Version=[2],Text=[After a call to Swap, I designates the element |
| 2049 |
value previously designated by J, and J designates the element value |
| 2050 |
previously designated by I. The cursors do not become ambiguous from this |
| 2051 |
operation.]} |
| 2052 |
@end{Ramification} |
| 2053 |
|
| 2054 |
@begin{Honest} |
| 2055 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2056 |
@ChgAdded{Version=[2],Text=[The implementation is not required to actually |
| 2057 |
copy the elements if it can do the swap some other way. But it is allowed |
| 2058 |
to copy the elements if needed.]} |
| 2059 |
@end{Honest} |
| 2060 |
|
| 2061 |
@begin{Example} |
| 2062 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2063 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First_Index (Container : Vector) @key{return} Index_Type;]} |
| 2064 |
@end{Example} |
| 2065 |
|
| 2066 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2067 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the value Index_Type'First.]} |
| 2068 |
|
| 2069 |
@begin{Discussion} |
| 2070 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2071 |
@ChgAdded{Version=[2],Text=[We'd rather call this @lquotes@;First@rquotes@;, |
| 2072 |
but then calling most routines in here with First (Some_Vect) would be |
| 2073 |
ambiguous.]} |
| 2074 |
@end{Discussion} |
| 2075 |
|
| 2076 |
@begin{Example} |
| 2077 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2078 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First (Container : Vector) @key{return} Cursor;]} |
| 2079 |
@end{Example} |
| 2080 |
|
| 2081 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2082 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, First |
| 2083 |
returns No_Element. Otherwise, it returns a cursor that designates the first |
| 2084 |
element in Container.]} |
| 2085 |
|
| 2086 |
@begin{Example} |
| 2087 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2088 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First_Element (Container : Vector) @key{return} Element_Type;]} |
| 2089 |
@end{Example} |
| 2090 |
|
| 2091 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2092 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Container, First_Index (Container)).]} |
| 2093 |
|
| 2094 |
@begin{Example} |
| 2095 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2096 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last_Index (Container : Vector) @key{return} Extended_Index;]} |
| 2097 |
@end{Example} |
| 2098 |
|
| 2099 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2100 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Last_Index |
| 2101 |
returns No_Index. Otherwise, it returns the position of the last element in |
| 2102 |
Container.]} |
| 2103 |
|
| 2104 |
@begin{Example} |
| 2105 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2106 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last (Container : Vector) @key{return} Cursor;]} |
| 2107 |
@end{Example} |
| 2108 |
|
| 2109 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2110 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Last returns |
| 2111 |
No_Element. Otherwise, it returns a cursor that designates the last element in |
| 2112 |
Container.]} |
| 2113 |
|
| 2114 |
@begin{Example} |
| 2115 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2116 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last_Element (Container : Vector) @key{return} Element_Type;]} |
| 2117 |
@end{Example} |
| 2118 |
|
| 2119 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2120 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Container, |
| 2121 |
Last_Index (Container)).]} |
| 2122 |
|
| 2123 |
@begin{Example} |
| 2124 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2125 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Next (Position : Cursor) @key{return} Cursor;]} |
| 2126 |
@end{Example} |
| 2127 |
|
| 2128 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2129 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element or |
| 2130 |
designates the last element of the container, then Next returns the value |
| 2131 |
No_Element. Otherwise, it returns a cursor that designates the element with index |
| 2132 |
To_Index (Position) + 1 in the same vector as Position.]} |
| 2133 |
|
| 2134 |
@begin{Example} |
| 2135 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2136 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Next (Position : @key{in out} Cursor);]} |
| 2137 |
@end{Example} |
| 2138 |
|
| 2139 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2140 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Next (Position).]} |
| 2141 |
|
| 2142 |
@begin{Example} |
| 2143 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2144 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Previous (Position : Cursor) @key{return} Cursor;]} |
| 2145 |
@end{Example} |
| 2146 |
|
| 2147 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2148 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element or |
| 2149 |
designates the first element of the container, then Previous returns the value |
| 2150 |
No_Element. Otherwise, it returns a cursor that designates the element with index |
| 2151 |
To_Index (Position) @en 1 in the same vector as Position.]} |
| 2152 |
|
| 2153 |
@begin{Example} |
| 2154 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2155 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Previous (Position : @key{in out} Cursor);]} |
| 2156 |
@end{Example} |
| 2157 |
|
| 2158 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2159 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Previous (Position).]} |
| 2160 |
|
| 2161 |
@begin{Example} |
| 2162 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2163 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Find_Index (Container : Vector; |
| 2164 |
Item : Element_Type; |
| 2165 |
Index : Index_Type := Index_Type'First) |
| 2166 |
@key{return} Extended_Index;]} |
| 2167 |
@end{Example} |
| 2168 |
|
| 2169 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2170 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Searches the elements of Container |
| 2171 |
for an element equal to Item (using the generic formal equality |
| 2172 |
operator). The search starts at position Index and proceeds towards Last_Index |
| 2173 |
(Container). If no equal element is found, then Find_Index returns No_Index. |
| 2174 |
Otherwise, it returns the index of the first equal element encountered.]} |
| 2175 |
|
| 2176 |
@begin{Example} |
| 2177 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2178 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Find (Container : Vector; |
| 2179 |
Item : Element_Type; |
| 2180 |
Position : Cursor := No_Element) |
| 2181 |
@key{return} Cursor;]} |
| 2182 |
@end{Example} |
| 2183 |
|
| 2184 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2185 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 2186 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position is not No_Element, and |
| 2187 |
does not designate an element in Container, then Program_Error is propagated. |
| 2188 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 2189 |
Find searches the elements of Container for an element equal to Item |
| 2190 |
(using the generic formal equality operator). The search starts at |
| 2191 |
the first element if Position equals No_Element, and at the element designated by |
| 2192 |
Position otherwise. It proceeds towards the last element of Container. If no |
| 2193 |
equal element is found, then Find returns No_Element. Otherwise, it returns a |
| 2194 |
cursor designating the first equal element encountered.]} |
| 2195 |
|
| 2196 |
@begin{Example} |
| 2197 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2198 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Reverse_Find_Index (Container : Vector; |
| 2199 |
Item : Element_Type; |
| 2200 |
Index : Index_Type := Index_Type'Last) |
| 2201 |
@key{return} Extended_Index;]} |
| 2202 |
@end{Example} |
| 2203 |
|
| 2204 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2205 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Searches the elements of Container |
| 2206 |
for an element equal to Item (using the generic formal equality |
| 2207 |
operator). The search starts at position Index or, if Index is greater than |
| 2208 |
Last_Index (Container), at position Last_Index (Container). It proceeds towards |
| 2209 |
First_Index (Container). If no equal element is found, then Reverse_Find_Index |
| 2210 |
returns No_Index. Otherwise, it returns the index of the first equal element |
| 2211 |
encountered.]} |
| 2212 |
|
| 2213 |
@begin{Example} |
| 2214 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2215 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Reverse_Find (Container : Vector; |
| 2216 |
Item : Element_Type; |
| 2217 |
Position : Cursor := No_Element) |
| 2218 |
@key{return} Cursor;]} |
| 2219 |
@end{Example} |
| 2220 |
|
| 2221 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2222 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 2223 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position is not No_Element, and |
| 2224 |
does not designate an element in Container, then Program_Error is propagated. |
| 2225 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 2226 |
Reverse_Find searches the elements of Container for an element equal |
| 2227 |
to Item (using the generic formal equality operator). The search |
| 2228 |
starts at the last element if Position equals No_Element, and at the element |
| 2229 |
designated by Position otherwise. It proceeds towards the first element of |
| 2230 |
Container. If no equal element is found, then Reverse_Find returns No_Element. |
| 2231 |
Otherwise, it returns a cursor designating the first equal element |
| 2232 |
encountered.]} |
| 2233 |
|
| 2234 |
@begin{Example} |
| 2235 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2236 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Contains (Container : Vector; |
| 2237 |
Item : Element_Type) @key{return} Boolean;]} |
| 2238 |
@end{Example} |
| 2239 |
|
| 2240 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2241 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Has_Element (Find (Container, Item)).]} |
| 2242 |
|
| 2243 |
@begin{Example} |
| 2244 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2245 |
@ChgRef{Version=[3],Kind=[DeletedNoDelMsg]} |
| 2246 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@Chg{Version=[3],New=[],Old=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean;]}]} |
| 2247 |
@end{Example} |
| 2248 |
|
| 2249 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2250 |
@ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]} |
| 2251 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[],Old=[Returns True if Position designates |
| 2252 |
an element, and returns False otherwise.]}]} |
| 2253 |
@begin{Honest} |
| 2254 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2255 |
@ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]} |
| 2256 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[This function may not detect cursors that |
| 2257 |
designate deleted elements; such cursors are invalid (see below) and the |
| 2258 |
result of calling Has_Element with an invalid cursor is unspecified (but |
| 2259 |
not erroneous).]}]} |
| 2260 |
@end{Honest} |
| 2261 |
@begin{NotIso} |
| 2262 |
@ChgAdded{Version=[3],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 225 and 226 |
| 2263 |
were moved above.>}]}@Comment{This message should be |
| 2264 |
deleted if the paragraphs are ever renumbered.} |
| 2265 |
@end{NotIso} |
| 2266 |
|
| 2267 |
|
| 2268 |
@begin{Example} |
| 2269 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2270 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Iterate |
| 2271 |
(Container : @key{in} Vector; |
| 2272 |
Process : @key{not null access} @key{procedure} (Position : @key{in} Cursor));]} |
| 2273 |
@end{Example} |
| 2274 |
|
| 2275 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2276 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]} |
| 2277 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Invokes Process.@key{all} with a |
| 2278 |
cursor that designates each element in Container, in index order. |
| 2279 |
@Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 2280 |
is propagated if Process.@key{all} tampers]} |
| 2281 |
with the cursors of Container@Chg{Version=[3],New=[ is prohibited during the |
| 2282 |
execution of a call on Process.@key{all}],Old=[]}. Any exception raised by |
| 2283 |
Process.@key{all} is propagated.]} |
| 2284 |
|
| 2285 |
@begin{Discussion} |
| 2286 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2287 |
@ChgAdded{Version=[2],Text=[The purpose of the @lquotes@;tamper with the |
| 2288 |
cursors@rquotes@; check is |
| 2289 |
to prevent erroneous execution from the Position parameter of Process.@key{all} |
| 2290 |
becoming invalid. This check takes place when the operations that tamper with |
| 2291 |
the cursors of the container are called. The check cannot be made later (say |
| 2292 |
in the body of Iterate), because that could cause the Position cursor to be |
| 2293 |
invalid and potentially cause execution to become erroneous -- defeating the |
| 2294 |
purpose of the check.]} |
| 2295 |
|
| 2296 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2297 |
@ChgAdded{Version=[2],Text=[ There is no check needed if an attempt is made |
| 2298 |
to insert or delete nothing (that is, Count = 0 or Length(Item) = 0).]} |
| 2299 |
|
| 2300 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2301 |
@ChgAdded{Version=[2],Text=[The check is easy to implement: each container |
| 2302 |
needs a counter. The counter is incremented when Iterate is called, and |
| 2303 |
decremented when Iterate completes. If the counter is nonzero when an |
| 2304 |
operation that inserts or deletes is called, Finalize is called, or one of |
| 2305 |
the other operations in the list occurs, Program_Error is raised.]} |
| 2306 |
@end{Discussion} |
| 2307 |
|
| 2308 |
@begin{Example} |
| 2309 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2310 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reverse_Iterate |
| 2311 |
(Container : @key{in} Vector; |
| 2312 |
Process : @key{not null access} @key{procedure} (Position : @key{in} Cursor));]} |
| 2313 |
@end{Example} |
| 2314 |
|
| 2315 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2316 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]} |
| 2317 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Iterates over the elements in |
| 2318 |
Container as per @Chg{Version=[3],New=[procedure ],Old=[]}Iterate, |
| 2319 |
except that elements are traversed in reverse index order.]} |
| 2320 |
|
| 2321 |
@begin{Example} |
| 2322 |
@ChgRef{Version=[3],Kind=[Added]} |
| 2323 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Vector) |
| 2324 |
@key[return] Vector_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 2325 |
@end{Example} |
| 2326 |
|
| 2327 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]} |
| 2328 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Iterate returns a reversible |
| 2329 |
iterator object (see @RefSecNum{User-Defined Iterator Types}) that |
| 2330 |
will generate a value for a loop parameter (see |
| 2331 |
@RefSecNum{Generalized Loop Iteration}) designating |
| 2332 |
each node in Container, starting with the first node and moving the cursor as |
| 2333 |
per the Next function when used as a forward iterator, and starting with the |
| 2334 |
last node and moving the cursor as per the Previous function when used as a |
| 2335 |
reverse iterator. Tampering with the cursors of Container is prohibited while |
| 2336 |
the iterator object exists (in particular, in |
| 2337 |
the @nt{sequence_of_statements} of the @nt{loop_statement} whose |
| 2338 |
@nt{iterator_specification} denotes this object). The iterator object needs |
| 2339 |
finalization.]} |
| 2340 |
|
| 2341 |
@begin{Example} |
| 2342 |
@ChgRef{Version=[3],Kind=[Added]} |
| 2343 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Vector; Start : @key[in] Cursor) |
| 2344 |
@key[return] Vector_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 2345 |
@end{Example} |
| 2346 |
|
| 2347 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0262-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]} |
| 2348 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[If Start is not No_Element and does |
| 2349 |
not designate an item in Container, then Program_Error is propagated. If Start |
| 2350 |
is No_Element, then Constraint_Error is propagated. Otherwise, Iterate |
| 2351 |
returns a reversible iterator object |
| 2352 |
(see @RefSecNum{User-Defined Iterator Types}) that will generate |
| 2353 |
a value for a loop parameter (see @RefSecNum{Generalized Loop Iteration}) |
| 2354 |
designating each node in Container, starting with the node |
| 2355 |
designated by Start and moving the cursor as per the Next function when used as |
| 2356 |
a forward iterator, or moving the cursor as per the Previous function when used |
| 2357 |
as a reverse iterator. Tampering with the cursors of Container is prohibited |
| 2358 |
while the iterator object exists (in particular, in the |
| 2359 |
@nt{sequence_of_statements} of the @nt{loop_statement} whose |
| 2360 |
@nt{iterator_specification} denotes this object). The iterator object needs |
| 2361 |
finalization.]} |
| 2362 |
|
| 2363 |
@begin{Discussion} |
| 2364 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 2365 |
@ChgAdded{Version=[3],Type=[Leading],Text=[Exits are allowed from the loops |
| 2366 |
created using the iterator objects. In particular, to stop the iteration at a |
| 2367 |
particular cursor, just add]} |
| 2368 |
@begin{Example} |
| 2369 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 2370 |
@ChgAdded{Version=[3],Text=[@key[exit when] Cur = Stop;]} |
| 2371 |
@end{Example} |
| 2372 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 2373 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[in the body of the loop (assuming |
| 2374 |
that @exam{Cur} is the loop parameter and @exam{Stop} is the cursor that you |
| 2375 |
want to stop at).]} |
| 2376 |
@end{Discussion} |
| 2377 |
|
| 2378 |
|
| 2379 |
@end{DescribeCode} |
| 2380 |
|
| 2381 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2382 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0044-1],ARef=[AI05-0262-1]} |
| 2383 |
@ChgAdded{Version=[2],Text=[The actual function for the generic formal function |
| 2384 |
"<" of Generic_Sorting is expected to return the same value each time it is |
| 2385 |
called with a particular pair of element values. It should define a strict |
| 2386 |
@Chg{Version=[3],New=[weak ],Old=[]}ordering relationship@Chg{Version=[3], |
| 2387 |
New=[ (see @RefSecNum{Containers})],Old=[, that is, be irreflexive, asymmetric, |
| 2388 |
and transitive]}; |
| 2389 |
it should not modify Container. If the actual for "<" behaves in some other |
| 2390 |
manner, the behavior of the subprograms of Generic_Sorting are unspecified. |
| 2391 |
@Chg{Version=[3],New=[The number of],Old=[How many]} times the subprograms of |
| 2392 |
Generic_Sorting call "<" is unspecified.@PDefn{unspecified}]} |
| 2393 |
|
| 2394 |
@begin{DescribeCode} |
| 2395 |
|
| 2396 |
@begin{Example} |
| 2397 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2398 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Is_Sorted (Container : Vector) @key{return} Boolean;]} |
| 2399 |
@end{Example} |
| 2400 |
|
| 2401 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2402 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns True if the elements are |
| 2403 |
sorted smallest first as determined by the |
| 2404 |
generic formal "<" operator; otherwise, Is_Sorted returns False. |
| 2405 |
Any exception raised during evaluation of "<" is propagated.]} |
| 2406 |
|
| 2407 |
@begin{Example} |
| 2408 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2409 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Sort (Container : @key{in out} Vector);]} |
| 2410 |
@end{Example} |
| 2411 |
|
| 2412 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2413 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Reorders the elements of Container |
| 2414 |
such that the elements are |
| 2415 |
sorted smallest first as determined by the generic formal "<" operator |
| 2416 |
provided. Any exception raised during evaluation of "<" is propagated.]} |
| 2417 |
|
| 2418 |
@begin{Ramification} |
| 2419 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2420 |
@ChgAdded{Version=[2],Text=[This implies swapping the elements, usually |
| 2421 |
including an intermediate copy. This means that the elements will usually be |
| 2422 |
copied. (As with Swap, if the implementation can do this some other way, it |
| 2423 |
is allowed to.) Since the elements are nonlimited, this usually will not be |
| 2424 |
a problem. Note that there is @ImplAdviceName below that the implementation |
| 2425 |
should use a sort that minimizes copying of elements.]} |
| 2426 |
|
| 2427 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2428 |
@ChgAdded{Version=[2],Text=[The sort is not required to be stable (and the |
| 2429 |
fast algorithm required will not be stable). If a stable sort is needed, the |
| 2430 |
user can include the original location of the element as an extra "sort key". |
| 2431 |
We considered requiring the implementation to do that, but it is mostly extra |
| 2432 |
overhead -- usually there is something already in the element that provides |
| 2433 |
the needed stability.]} |
| 2434 |
@end{Ramification} |
| 2435 |
|
| 2436 |
@begin{Example} |
| 2437 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2438 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Merge (Target : @key{in out} Vector; |
| 2439 |
Source : @key{in out} Vector);]} |
| 2440 |
@end{Example} |
| 2441 |
|
| 2442 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2443 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1]} |
| 2444 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[If Source is |
| 2445 |
empty, then Merge does nothing. If Source and Target are the same nonempty |
| 2446 |
container object, then Program_Error is propagated. Otherwise, ],Old=[]}Merge |
| 2447 |
removes elements from Source and inserts them into Target; afterwards, Target |
| 2448 |
contains the union of the elements that were initially in Source and Target; |
| 2449 |
Source is left empty. If Target and Source are initially sorted smallest first, |
| 2450 |
then Target is ordered smallest first as determined by the generic formal "<" |
| 2451 |
operator; otherwise, the order of elements in Target is unspecified. Any |
| 2452 |
exception raised during evaluation of "<" is propagated.]} |
| 2453 |
|
| 2454 |
@begin{Discussion} |
| 2455 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2456 |
@ChgAdded{Version=[2],Text=[It is a bounded error if either of the vectors is |
| 2457 |
unsorted, see below. The bounded error can be recovered by sorting Target |
| 2458 |
after the merge call, or the vectors can be pretested with Is_Sorted.]} |
| 2459 |
@end{Discussion} |
| 2460 |
@begin{ImplNote} |
| 2461 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2462 |
@ChgAdded{Version=[2],Text=[The Merge operation will usually require copying |
| 2463 |
almost all of the elements. One implementation strategy would be to |
| 2464 |
extend Target to the appropriate length, then copying elements from the back |
| 2465 |
of the vectors working towards the front. An alternative approach would be |
| 2466 |
to allocate a new internal data array of the appropriate length, copy the |
| 2467 |
elements into it in an appropriate order, and then replacing the data array |
| 2468 |
in Target with the temporary.]} |
| 2469 |
@end{ImplNote} |
| 2470 |
|
| 2471 |
@end{DescribeCode} |
| 2472 |
|
| 2473 |
@end{StaticSem} |
| 2474 |
|
| 2475 |
@begin{Bounded} |
| 2476 |
|
| 2477 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2478 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]} |
| 2479 |
@ChgAdded{Version=[2],Text=[@PDefn2{Term=(bounded error),Sec=(cause)} |
| 2480 |
Reading the value of an empty element by calling |
| 2481 |
Element, Query_Element, Update_Element,@Chg{Version=[3],New=[ |
| 2482 |
Constant_Reference, Reference,],Old=[]} Swap, Is_Sorted, Sort, Merge, |
| 2483 |
"=", Find, or Reverse_Find is a bounded error. The implementation may treat |
| 2484 |
the element as having any normal value (see @RefSecNum{Data Validity}) of the |
| 2485 |
element type, or raise Constraint_Error or Program_Error before modifying |
| 2486 |
the vector.]} |
| 2487 |
|
| 2488 |
@begin{Ramification} |
| 2489 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2490 |
@ChgAdded{Version=[2],Text=[For instance, a default initialized element could |
| 2491 |
be returned. Or some previous value of an element. But returning random junk |
| 2492 |
is not allowed if the type has default initial value(s).]} |
| 2493 |
|
| 2494 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2495 |
@ChgAdded{Version=[2],Text=[Assignment and streaming of empty elements are |
| 2496 |
@b<not> bounded errors. This is consistent with regular composite types, for |
| 2497 |
which assignment and streaming of uninitialized components do not cause a |
| 2498 |
bounded error, but reading the uninitialized component does cause a bounded |
| 2499 |
error.]} |
| 2500 |
|
| 2501 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2502 |
@ChgAdded{Version=[2],Text=[There are other operations which are defined in |
| 2503 |
terms of the operations listed above.]} |
| 2504 |
@end{Ramification} |
| 2505 |
|
| 2506 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2507 |
@ChgAdded{Version=[2],Text=[@PDefn2{Term=(bounded error),Sec=(cause)} |
| 2508 |
Calling Merge in an instance of Generic_Sorting |
| 2509 |
with either Source or Target not ordered smallest first using the provided |
| 2510 |
generic formal "<" operator is a bounded error. Either Program_Error is raised |
| 2511 |
after Target is updated as described for Merge, or the operation works as |
| 2512 |
defined.]} |
| 2513 |
|
| 2514 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0022-1],ARef=[AI05-0248-1]} |
| 2515 |
@ChgAdded{Version=[3],Text=[It is a bounded error for the actual function |
| 2516 |
associated with a generic formal subprogram, when called as part of an |
| 2517 |
operation of this package, to tamper with elements of any Vector parameter of |
| 2518 |
the operation. Either Program_Error is raised, or the operation works as |
| 2519 |
defined on the value of the Vector either prior to, or subsequent to, some or |
| 2520 |
all of the modifications to the Vector.]} |
| 2521 |
|
| 2522 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0027-1]} |
| 2523 |
@ChgAdded{Version=[3],Text=[It is a bounded error to call any subprogram |
| 2524 |
declared in the visible part of Containers.Vectors |
| 2525 |
when the associated container has been finalized. If the operation takes |
| 2526 |
Container as an @key[in out] parameter, then it raises Constraint_Error or |
| 2527 |
Program_Error. Otherwise, the operation either proceeds as it would |
| 2528 |
for an empty container, or it raises Constraint_Error or Program_Error.]} |
| 2529 |
|
| 2530 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2531 |
@ChgAdded{Version=[2],Type=[Leading],Text=[ |
| 2532 |
@Defn2{Term=[ambiguous cursor],Sec=[of a vector]} |
| 2533 |
@Defn2{Term=[cursor],Sec=[ambiguous]} |
| 2534 |
A Cursor value is @i{ambiguous} if any of the following have occurred since it |
| 2535 |
was created:]} |
| 2536 |
|
| 2537 |
@begin{Itemize} |
| 2538 |
|
| 2539 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2540 |
@ChgAdded{Version=[2],Text=[Insert, Insert_Space, or Delete has been called on |
| 2541 |
the vector that contains the element the cursor designates with an index value |
| 2542 |
(or a cursor designating an element at such an index value) less than or equal |
| 2543 |
to the index value of the element designated by the cursor; or]} |
| 2544 |
|
| 2545 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2546 |
@ChgAdded{Version=[2],Text=[The vector that contains the element it designates |
| 2547 |
has been passed to the Sort or Merge procedures of an instance of |
| 2548 |
Generic_Sorting, or to the Reverse_Elements procedure.]} |
| 2549 |
|
| 2550 |
@end{Itemize} |
| 2551 |
|
| 2552 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2553 |
@ChgAdded{Version=[2],Type=[Leading],Text=[@PDefn2{Term=(bounded error),Sec=(cause)} |
| 2554 |
It is a bounded error to call any subprogram other than "=" |
| 2555 |
or Has_Element declared in Containers.Vectors with an ambiguous (but not |
| 2556 |
invalid, see below) cursor parameter. Possible results are:]} |
| 2557 |
|
| 2558 |
@begin{Itemize} |
| 2559 |
|
| 2560 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2561 |
@ChgAdded{Version=[2],Text=[The cursor may be treated as if it were No_Element;]} |
| 2562 |
|
| 2563 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2564 |
@ChgAdded{Version=[2],Text=[The cursor may designate some element in the vector |
| 2565 |
(but not necessarily the element that it originally designated);]} |
| 2566 |
|
| 2567 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2568 |
@ChgAdded{Version=[2],Text=[Constraint_Error may be raised; or]} |
| 2569 |
|
| 2570 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2571 |
@ChgAdded{Version=[2],Text=[Program_Error may be raised.]} |
| 2572 |
|
| 2573 |
@end{Itemize} |
| 2574 |
|
| 2575 |
@begin{Reason} |
| 2576 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2577 |
@ChgAdded{Version=[2],Text=[Cursors are made ambiguous if an Insert or Delete |
| 2578 |
occurs that moves the elements in the internal array including the designated |
| 2579 |
ones. After such an operation, the cursor probably still designates an |
| 2580 |
element (although it might not after a deletion), but it is a @i<different> |
| 2581 |
element. That violates the definition of cursor @em it designates a particular |
| 2582 |
element.]} |
| 2583 |
|
| 2584 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2585 |
@ChgAdded{Version=[2],Text=[For "=" or Has_Element, the cursor works normally |
| 2586 |
(it would not be No_Element). We don't want to trigger an exception simply |
| 2587 |
for comparing a bad cursor.]} |
| 2588 |
|
| 2589 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2590 |
@ChgAdded{Version=[2],Text=[While it is possible to check for these cases |
| 2591 |
or ensure that cursors survive such operations, in many cases the overhead |
| 2592 |
necessary to make the check (or ensure cursors continue to designate the |
| 2593 |
same element) is substantial in time or space.]} |
| 2594 |
@end{Reason} |
| 2595 |
|
| 2596 |
@end{Bounded} |
| 2597 |
|
| 2598 |
@begin{Erron} |
| 2599 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2600 |
@ChgAdded{Version=[2],Type=[Leading],Text=[ |
| 2601 |
A Cursor value is @i{invalid} if any of the following have occurred since it |
| 2602 |
was created:@Defn2{Term=[invalid cursor],Sec=[of a vector]} |
| 2603 |
@PDefn2{Term=[cursor],Sec=[invalid]}]} |
| 2604 |
|
| 2605 |
@begin{Itemize} |
| 2606 |
|
| 2607 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2608 |
@ChgAdded{Version=[2],Text=[The vector that contains the element it designates |
| 2609 |
has been finalized;]} |
| 2610 |
|
| 2611 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0160-1]} |
| 2612 |
@ChgAdded{Version=[3],Text=[The vector that contains the element it designates |
| 2613 |
has been used as the Target of a call to Assign, or as the target of an |
| 2614 |
@nt{assignment_statement};]} |
| 2615 |
|
| 2616 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2617 |
@ChgAdded{Version=[2],Text=[@Redundant[The vector that contains the element it |
| 2618 |
designates has been used as the Source or Target of a call to Move;] or]} |
| 2619 |
@begin{TheProof} |
| 2620 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 2621 |
@ChgAdded{Version=[3],Text=[Move has been reworded in terms of Assign and |
| 2622 |
Clear, which are covered by other bullets, so this text is redundant.]} |
| 2623 |
@end{TheProof} |
| 2624 |
|
| 2625 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2626 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0160-1],ARef=[AI05-0262-1]} |
| 2627 |
@ChgAdded{Version=[2],Text=[The element it designates has been |
| 2628 |
deleted@Chg{Version=[3],New=[ or removed from the vector that previously |
| 2629 |
contained the element],Old=[]}.]} |
| 2630 |
@begin{Ramification} |
| 2631 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]} |
| 2632 |
@ChgAdded{Version=[3],Text=[An element can be removed via calls to Set_Length, |
| 2633 |
Clear, and Merge; and indirectly via calls to Assign and Move.]} |
| 2634 |
@end{Ramification} |
| 2635 |
|
| 2636 |
@end{Itemize} |
| 2637 |
|
| 2638 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2639 |
@ChgAdded{Version=[2],Text=[The result of "=" or Has_Element is unspecified if |
| 2640 |
it is called with an invalid cursor parameter.@PDefn{unspecified} Execution |
| 2641 |
is erroneous if any other subprogram declared in Containers.Vectors is called |
| 2642 |
with an invalid cursor parameter.@PDefn2{Term=(erroneous execution), |
| 2643 |
Sec=(cause)}]} |
| 2644 |
|
| 2645 |
@begin{Discussion} |
| 2646 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2647 |
@ChgAdded{Version=[2],Text=[The list above (combined with the bounded error |
| 2648 |
cases) is intended to be exhaustive. In other cases, a cursor value continues |
| 2649 |
to designate its original element. For instance, cursor values survive the |
| 2650 |
appending of new elements.]} |
| 2651 |
@end{Discussion} |
| 2652 |
|
| 2653 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 2654 |
@ChgAdded{Version=[3],Text=[Execution is erroneous if the vector associated with the result of a call to |
| 2655 |
Reference or Constant_Reference is finalized before the result object returned |
| 2656 |
by the call to Reference or Constant_Reference is finalized.]} |
| 2657 |
|
| 2658 |
@begin{Reason} |
| 2659 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 2660 |
@ChgAdded{Version=[3],Text=[Each object of Reference_Type and |
| 2661 |
Constant_Reference_Type probably contains some reference to the originating |
| 2662 |
container. If that container is prematurely finalized (which is only possible |
| 2663 |
via Unchecked_Deallocation, as accessibility checks prevent passing a |
| 2664 |
container to Reference that will not live as long as the result), the |
| 2665 |
finalization of the object of Reference_Type will try to access a nonexistent |
| 2666 |
object. This is a normal case of a dangling pointer created by |
| 2667 |
Unchecked_Deallocation; we have to explicitly mention it here as the pointer |
| 2668 |
in question is not visible in the specification of the type. (This is the same |
| 2669 |
reason we have to say this for invalid cursors.)]} |
| 2670 |
@end{Reason} |
| 2671 |
@end{Erron} |
| 2672 |
|
| 2673 |
@begin{ImplReq} |
| 2674 |
|
| 2675 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2676 |
@ChgAdded{Version=[2],Text=[No storage associated with a vector object shall be |
| 2677 |
lost upon assignment or scope exit.]} |
| 2678 |
|
| 2679 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2680 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]} |
| 2681 |
@ChgAdded{Version=[2],Text=[The execution of an @nt{assignment_statement} for |
| 2682 |
a vector shall have the effect of copying the elements from the source vector |
| 2683 |
object to the target vector object@Chg{Version=[3],New=[ and changing the length |
| 2684 |
of the target object to that of the source object],Old=[]}.]} |
| 2685 |
|
| 2686 |
@begin{ImplNote} |
| 2687 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2688 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0298-1]} |
| 2689 |
@ChgAdded{Version=[2],Text=[An assignment of a Vector is a @lquotes@;deep@rquotes |
| 2690 |
copy; that is the elements are copied as well as the data structures. |
| 2691 |
We say @lquotes@;effect of@rquotes in order to allow the implementation to |
| 2692 |
avoid copying elements immediately if it wishes. For instance, an |
| 2693 |
implementation that avoided copying until one of the containers is modified |
| 2694 |
would be allowed.@Chg{Version=[3],New=[ (Note that such an implementation |
| 2695 |
would be require care, as Query_Element and Constant_Reference both could be |
| 2696 |
used to access an element which later needs to be reallocated while |
| 2697 |
the parameter or reference still exists, potentially leaving the |
| 2698 |
parameter or reference pointing at the wrong element.)],Old=[]}]} |
| 2699 |
@end{ImplNote} |
| 2700 |
@end{ImplReq} |
| 2701 |
|
| 2702 |
@begin{ImplAdvice} |
| 2703 |
|
| 2704 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2705 |
@ChgAdded{Version=[2],Text=[Containers.Vectors should be implemented similarly |
| 2706 |
to an array. In particular, if the length of a vector is @i{N}, then]} |
| 2707 |
|
| 2708 |
@begin{Itemize} |
| 2709 |
|
| 2710 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2711 |
@ChgAdded{Version=[2],Text=[the worst-case time complexity of Element should |
| 2712 |
be @i{O}(log @i{N});]} |
| 2713 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2714 |
Text=[The worst-case time complexity of Element |
| 2715 |
for Containers.Vector should be @i{O}(log @i{N}).]}]} |
| 2716 |
|
| 2717 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2718 |
@ChgAdded{Version=[2],Text=[the worst-case time complexity of Append with |
| 2719 |
Count=1 when @i{N} is less than the capacity of the vector should be |
| 2720 |
@i{O}(log @i{N}); and]} |
| 2721 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2722 |
Text=[The worst-case time complexity of Append with Count = 1 when |
| 2723 |
@i{N} is less than the capacity for Containers.Vector should be @i{O}(log @i{N}).]}]} |
| 2724 |
|
| 2725 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2726 |
@ChgAdded{Version=[2],Text=[the worst-case time complexity of Prepend with |
| 2727 |
Count=1 and Delete_First with Count=1 should be @i{O}(@i{N} log @i{N}).]} |
| 2728 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2729 |
Text=[The worst-case time complexity of Prepend with Count = 1 and |
| 2730 |
Delete_First with Count=1 for Containers.Vectors should be @i{O}(@i{N} log @i{N}).]}]} |
| 2731 |
|
| 2732 |
@end{Itemize} |
| 2733 |
|
| 2734 |
@begin{Reason} |
| 2735 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2736 |
@ChgAdded{Version=[2],Text=[We do not mean to overly constrain implementation |
| 2737 |
strategies here. However, it is important for portability that the |
| 2738 |
performance of large containers has roughly the same factors on different |
| 2739 |
implementations. If a program is moved to an implementation that takes |
| 2740 |
@i{O}(@i{N}) time to access elements, that program could be unusable when the |
| 2741 |
vectors are large. We allow @i{O}(log @i{N}) access because the proportionality |
| 2742 |
constant and caching effects are likely to be larger than the log factor, and |
| 2743 |
we don't want to discourage innovative implementations.]} |
| 2744 |
@end{Reason} |
| 2745 |
|
| 2746 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2747 |
@ChgAdded{Version=[2],Text=[The worst-case time complexity of a call on procedure |
| 2748 |
Sort of an instance of Containers.Vectors.Generic_Sorting should be @i{O}(@i{N}**2), and the |
| 2749 |
average time complexity should be better than @i{O}(@i{N}**2).]} |
| 2750 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2751 |
Text=[The worst-case time complexity of a call on procedure Sort of an |
| 2752 |
instance of Containers.Vectors.Generic_Sorting should be @i{O}(@i{N}**2), and the |
| 2753 |
average time complexity should be better than @i{O}(@i{N}**2).]}]} |
| 2754 |
|
| 2755 |
@begin{Ramification} |
| 2756 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2757 |
@ChgAdded{Version=[2],Text=[In other words, we're requiring the use of a |
| 2758 |
better than @i{O}(@i{N}**2) sorting algorithm, such as Quicksort. No bubble sorts |
| 2759 |
allowed!]} |
| 2760 |
@end{Ramification} |
| 2761 |
|
| 2762 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2763 |
@ChgAdded{Version=[2],Text=[Containers.Vectors.Generic_Sorting.Sort and |
| 2764 |
Containers.Vectors.Generic_Sorting.Merge should minimize |
| 2765 |
copying of elements.]} |
| 2766 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2767 |
Text=[Containers.Vectors.Generic_Sorting.Sort and |
| 2768 |
Containers.Vectors.Generic_Sorting.Merge should minimize copying of elements.]}]} |
| 2769 |
|
| 2770 |
@begin{Honest} |
| 2771 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2772 |
@ChgAdded{Version=[2],Text=[We do not mean @lquotes@;absolutely minimize@rquotes |
| 2773 |
here; we're not intending to require a single copy for each element. |
| 2774 |
Rather, we want to suggest that the sorting algorithm chosen is one that |
| 2775 |
does not copy items unnecessarily. Bubble sort would not meet this advice, |
| 2776 |
for instance.]} |
| 2777 |
@end{Honest} |
| 2778 |
|
| 2779 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2780 |
@ChgAdded{Version=[2],Text=[Move should not copy elements, and should minimize |
| 2781 |
copying of internal data structures.]} |
| 2782 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2783 |
Text=[Containers.Vectors.Move should not copy elements, and should minimize |
| 2784 |
copying of internal data structures.]}]} |
| 2785 |
|
| 2786 |
@begin{ImplNote} |
| 2787 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2788 |
@ChgAdded{Version=[2],Text=[Usually that can be accomplished simply by |
| 2789 |
moving the pointer(s) to the internal data structures from the Source vector |
| 2790 |
to the Target vector.]} |
| 2791 |
@end{ImplNote} |
| 2792 |
|
| 2793 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2794 |
@ChgAdded{Version=[2],Text=[If an exception is propagated from a vector |
| 2795 |
operation, no storage should be lost, nor any elements removed from a vector |
| 2796 |
unless specified by the operation.]} |
| 2797 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2798 |
Text=[If an exception is propagated from a vector |
| 2799 |
operation, no storage should be lost, nor any elements removed from a vector |
| 2800 |
unless specified by the operation.]}]} |
| 2801 |
|
| 2802 |
@begin{Reason} |
| 2803 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2804 |
@ChgAdded{Version=[2],Text=[This is important so that programs can recover |
| 2805 |
from errors. But we don't want to require heroic efforts, so we just require |
| 2806 |
documentation of cases where this can't be accomplished.]} |
| 2807 |
@end{Reason} |
| 2808 |
|
| 2809 |
@end{ImplAdvice} |
| 2810 |
|
| 2811 |
@begin{Notes} |
| 2812 |
|
| 2813 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2814 |
@ChgAdded{Version=[2],Text=[All elements of a vector occupy locations in the |
| 2815 |
internal array. If a sparse container is required, a Hashed_Map should be used |
| 2816 |
rather than a vector.]} |
| 2817 |
|
| 2818 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2819 |
@ChgAdded{Version=[2],Text=[If Index_Type'Base'First = Index_Type'First an |
| 2820 |
instance of Ada.Containers.Vectors will raise Constraint_Error. A value |
| 2821 |
below Index_Type'First is required so that an empty vector has a meaningful |
| 2822 |
value of Last_Index.]} |
| 2823 |
|
| 2824 |
@begin{Discussion} |
| 2825 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2826 |
@ChgAdded{Version=[2],Text=[This property is the main reason why only integer |
| 2827 |
types (as opposed to any discrete type) are allowed as the index type of a |
| 2828 |
vector. An enumeration or modular type would require a subtype in order to |
| 2829 |
meet this requirement.]} |
| 2830 |
@end{Discussion} |
| 2831 |
|
| 2832 |
@end{Notes} |
| 2833 |
|
| 2834 |
@begin{Extend95} |
| 2835 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2836 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 2837 |
The package Containers.Vectors is new.]} |
| 2838 |
@end{Extend95} |
| 2839 |
|
| 2840 |
@begin{Incompatible2005} |
| 2841 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 2842 |
@ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Subprograms Assign and Copy |
| 2843 |
are added to Containers.Vectors. If an instance of Containers.Vectors |
| 2844 |
is referenced in a @nt{use_clause}, and an entity @i<E> with the same |
| 2845 |
@nt{defining_identifier} as a new entity in Containers.Vectors is |
| 2846 |
defined in a package that is also referenced in a @nt{use_clause}, the |
| 2847 |
entity @i<E> may no longer be use-visible, resulting in errors. This should |
| 2848 |
be rare and is easily fixed if it does occur.]} |
| 2849 |
@end{Incompatible2005} |
| 2850 |
|
| 2851 |
@begin{Extend2005} |
| 2852 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]} |
| 2853 |
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005} |
| 2854 |
Added iterator, reference, and indexing support to make vector containers more |
| 2855 |
convenient to use.]} |
| 2856 |
@end{Extend2005} |
| 2857 |
|
| 2858 |
@begin{DiffWord2005} |
| 2859 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 2860 |
@ChgAdded{Version=[3],Text=[Generalized the definition |
| 2861 |
of Reserve_Capacity and Move. Specified which elements are read/written |
| 2862 |
by stream attributes.]} |
| 2863 |
|
| 2864 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0022-1]} |
| 2865 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName |
| 2866 |
to cover tampering by generic actual subprograms.]} |
| 2867 |
|
| 2868 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0027-1]} |
| 2869 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName |
| 2870 |
to cover access to finalized vector containers.]} |
| 2871 |
|
| 2872 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]} |
| 2873 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Redefined "<" actuals |
| 2874 |
to require a strict weak ordering; the old definition allowed |
| 2875 |
indeterminant comparisons that would not have worked in a container.]} |
| 2876 |
|
| 2877 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0084-1]} |
| 2878 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a pragma |
| 2879 |
Remote_Types so that containers can be used in distributed programs.]} |
| 2880 |
|
| 2881 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]} |
| 2882 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Revised the definition |
| 2883 |
of invalid cursors to cover missing (and new) cases.]} |
| 2884 |
|
| 2885 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0265-1]} |
| 2886 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Defined when a container |
| 2887 |
prohibits tampering in order to more clearly define where the check is |
| 2888 |
made and the exception raised.]} |
| 2889 |
@end{DiffWord2005} |
| 2890 |
|
| 2891 |
@begin{DiffWord2012} |
| 2892 |
@ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0110-1]} |
| 2893 |
@ChgAdded{Version=[4],Text=[@b<Corrigendum:> Clarified that tampering checks |
| 2894 |
precede all other checks made by a subprogram (but come after those associated |
| 2895 |
with the call).]} |
| 2896 |
@end{DiffWord2012} |
| 2897 |
|
| 2898 |
|
| 2899 |
@LabeledAddedSubclause{Version=[2], |
| 2900 |
Name=[The Generic Package Containers.Doubly_Linked_Lists]} |
| 2901 |
|
| 2902 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2903 |
@ChgAdded{Version=[2],Text=[The language-defined generic package |
| 2904 |
Containers.Doubly_Linked_Lists provides private types List and Cursor, and a |
| 2905 |
set of operations for each type. A list container is optimized for insertion |
| 2906 |
and deletion at any position. @Defn{list container}@Defn2{Term=[container],Sec=[list]}]} |
| 2907 |
|
| 2908 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2909 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[node],Sec=[of a list]}A |
| 2910 |
doubly-linked list container object manages a linked list of internal |
| 2911 |
@i{nodes}, each of which contains an element and pointers to the |
| 2912 |
next (successor) and previous (predecessor) internal nodes. A cursor |
| 2913 |
designates a particular node within a list (and by extension the element |
| 2914 |
contained in that node). A cursor keeps designating the same node (and element) |
| 2915 |
as long as the node is part of the container, even if the node is moved in the |
| 2916 |
container.]} |
| 2917 |
|
| 2918 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2919 |
@ChgAdded{Version=[2],Text=[The @i{length} of a list is the number of elements |
| 2920 |
it contains.@Defn2{Term=[length],Sec=(of a list container)}]} |
| 2921 |
|
| 2922 |
@begin{StaticSem} |
| 2923 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2924 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library |
| 2925 |
package Containers.Doubly_Linked_Lists has the following declaration:]} |
| 2926 |
@begin{Example} |
| 2927 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2928 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0084-1],ARef=[AI05-0212-1]} |
| 2929 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[@key[with] Ada.Iterator_Interfaces; |
| 2930 |
],Old=[]}@key{generic} |
| 2931 |
@key{type} Element_Type @key{is private}; |
| 2932 |
@key{with function} "=" (Left, Right : Element_Type) |
| 2933 |
@key{return} Boolean @key{is} <>; |
| 2934 |
@key{package} Ada.Containers.Doubly_Linked_Lists @key{is}@ChildUnit{Parent=[Ada.Containers],Child=[Doubly_@!Linked_@!Lists]} |
| 2935 |
@key{pragma} Preelaborate(Doubly_Linked_Lists);@Chg{Version=[3],New=[ |
| 2936 |
@key{pragma} Remote_Types(Doubly_Linked_Lists);],Old=[]}]} |
| 2937 |
|
| 2938 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2939 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]} |
| 2940 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{List} @key{is tagged private}@Chg{Version=[3],New=[ |
| 2941 |
@key[with] Constant_Indexing => Constant_Reference, |
| 2942 |
Variable_Indexing => Reference, |
| 2943 |
Default_Iterator => Iterate, |
| 2944 |
Iterator_Element => Element_Type],Old=[]}; |
| 2945 |
@key{pragma} Preelaborable_Initialization(List);]} |
| 2946 |
|
| 2947 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2948 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private}; |
| 2949 |
@key{pragma} Preelaborable_Initialization(Cursor);]} |
| 2950 |
|
| 2951 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2952 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{Empty_List} : @key{constant} List;]} |
| 2953 |
|
| 2954 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2955 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]} |
| 2956 |
|
| 2957 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 2958 |
@ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]} |
| 2959 |
|
| 2960 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 2961 |
@ChgAdded{Version=[3],Text=[ @key[package] @AdaPackDefn{List_Iterator_Interfaces} @key[is new] |
| 2962 |
Ada.Iterator_Interfaces (Cursor, Has_Element);]} |
| 2963 |
|
| 2964 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2965 |
@ChgAdded{Version=[2],Text=[ @key{function} "=" (Left, Right : List) @key{return} Boolean;]} |
| 2966 |
|
| 2967 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2968 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Length} (Container : List) @key{return} Count_Type;]} |
| 2969 |
|
| 2970 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2971 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Empty} (Container : List) @key{return} Boolean;]} |
| 2972 |
|
| 2973 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2974 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Clear} (Container : @key{in out} List);]} |
| 2975 |
|
| 2976 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2977 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Position : Cursor) |
| 2978 |
@key{return} Element_Type;]} |
| 2979 |
|
| 2980 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2981 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} List; |
| 2982 |
Position : @key{in} Cursor; |
| 2983 |
New_Item : @key{in} Element_Type);]} |
| 2984 |
|
| 2985 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2986 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element} |
| 2987 |
(Position : @key{in} Cursor; |
| 2988 |
Process : @key{not null access procedure} (Element : @key{in} Element_Type));]} |
| 2989 |
|
| 2990 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2991 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element} |
| 2992 |
(Container : @key{in out} List; |
| 2993 |
Position : @key{in} Cursor; |
| 2994 |
Process : @key{not null access procedure} |
| 2995 |
(Element : @key{in out} Element_Type));]} |
| 2996 |
|
| 2997 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 2998 |
@ChgAdded{Version=[3],Text=[ @key[type] Constant_Reference_Type |
| 2999 |
(Element : @key[not null access constant] Element_Type) @key[is private] |
| 3000 |
@key[with] Implicit_Dereference => Element;]} |
| 3001 |
|
| 3002 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 3003 |
@ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Reference_Type} (Element : @key[not null access] Element_Type) @key[is private] |
| 3004 |
@key[with] Implicit_Dereference => Element;]} |
| 3005 |
|
| 3006 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 3007 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] List; |
| 3008 |
Position : @key[in] Cursor) |
| 3009 |
@key[return] Constant_Reference_Type;]} |
| 3010 |
|
| 3011 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 3012 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] List; |
| 3013 |
Position : @key[in] Cursor) |
| 3014 |
@key[return] Reference_Type;]} |
| 3015 |
|
| 3016 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 3017 |
@ChgAdded{Version=[3],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} List; Source : @key{in} List);]} |
| 3018 |
|
| 3019 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 3020 |
@ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Copy} (Source : List) @key[return] List;]} |
| 3021 |
|
| 3022 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3023 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Move} (Target : @key{in out} List; |
| 3024 |
Source : @key{in out} List);]} |
| 3025 |
|
| 3026 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3027 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} List; |
| 3028 |
Before : @key{in} Cursor; |
| 3029 |
New_Item : @key{in} Element_Type; |
| 3030 |
Count : @key{in} Count_Type := 1);]} |
| 3031 |
|
| 3032 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3033 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} List; |
| 3034 |
Before : @key{in} Cursor; |
| 3035 |
New_Item : @key{in} Element_Type; |
| 3036 |
Position : @key{out} Cursor; |
| 3037 |
Count : @key{in} Count_Type := 1);]} |
| 3038 |
|
| 3039 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3040 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} List; |
| 3041 |
Before : @key{in} Cursor; |
| 3042 |
Position : @key{out} Cursor; |
| 3043 |
Count : @key{in} Count_Type := 1);]} |
| 3044 |
|
| 3045 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3046 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Prepend} (Container : @key{in out} List; |
| 3047 |
New_Item : @key{in} Element_Type; |
| 3048 |
Count : @key{in} Count_Type := 1);]} |
| 3049 |
|
| 3050 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3051 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Append} (Container : @key{in out} List; |
| 3052 |
New_Item : @key{in} Element_Type; |
| 3053 |
Count : @key{in} Count_Type := 1);]} |
| 3054 |
|
| 3055 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3056 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} List; |
| 3057 |
Position : @key{in out} Cursor; |
| 3058 |
Count : @key{in} Count_Type := 1);]} |
| 3059 |
|
| 3060 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3061 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_First} (Container : @key{in out} List; |
| 3062 |
Count : @key{in} Count_Type := 1);]} |
| 3063 |
|
| 3064 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3065 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_Last} (Container : @key{in out} List; |
| 3066 |
Count : @key{in} Count_Type := 1);]} |
| 3067 |
|
| 3068 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3069 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reverse_Elements} (Container : @key{in out} List);]} |
| 3070 |
|
| 3071 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3072 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Swap} (Container : @key{in out} List; |
| 3073 |
I, J : @key{in} Cursor);]} |
| 3074 |
|
| 3075 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3076 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Swap_Links} (Container : @key{in out} List; |
| 3077 |
I, J : @key{in} Cursor);]} |
| 3078 |
|
| 3079 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3080 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Splice} (Target : @key{in out} List; |
| 3081 |
Before : @key{in} Cursor; |
| 3082 |
Source : @key{in out} List);]} |
| 3083 |
|
| 3084 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3085 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Splice} (Target : @key{in out} List; |
| 3086 |
Before : @key{in} Cursor; |
| 3087 |
Source : @key{in out} List; |
| 3088 |
Position : @key{in out} Cursor);]} |
| 3089 |
|
| 3090 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3091 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Splice} (Container: @key{in out} List; |
| 3092 |
Before : @key{in} Cursor; |
| 3093 |
Position : @key{in} Cursor);]} |
| 3094 |
|
| 3095 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3096 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First} (Container : List) @key{return} Cursor;]} |
| 3097 |
|
| 3098 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3099 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First_Element} (Container : List) |
| 3100 |
@key{return} Element_Type;]} |
| 3101 |
|
| 3102 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3103 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last} (Container : List) @key{return} Cursor;]} |
| 3104 |
|
| 3105 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3106 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last_Element} (Container : List) |
| 3107 |
@key{return} Element_Type;]} |
| 3108 |
|
| 3109 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3110 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Next} (Position : Cursor) @key{return} Cursor;]} |
| 3111 |
|
| 3112 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3113 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Previous} (Position : Cursor) @key{return} Cursor;]} |
| 3114 |
|
| 3115 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3116 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Next} (Position : @key{in out} Cursor);]} |
| 3117 |
|
| 3118 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3119 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Previous} (Position : @key{in out} Cursor);]} |
| 3120 |
|
| 3121 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3122 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : List; |
| 3123 |
Item : Element_Type; |
| 3124 |
Position : Cursor := No_Element) |
| 3125 |
@key{return} Cursor;]} |
| 3126 |
|
| 3127 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3128 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Reverse_Find} (Container : List; |
| 3129 |
Item : Element_Type; |
| 3130 |
Position : Cursor := No_Element) |
| 3131 |
@key{return} Cursor;]} |
| 3132 |
|
| 3133 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3134 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : List; |
| 3135 |
Item : Element_Type) @key{return} Boolean;]} |
| 3136 |
|
| 3137 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3138 |
@ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0212-1]} |
| 3139 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]}]} |
| 3140 |
|
| 3141 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3142 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Iterate} |
| 3143 |
(Container : @key{in} List; |
| 3144 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 3145 |
|
| 3146 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3147 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reverse_Iterate} |
| 3148 |
(Container : @key{in} List; |
| 3149 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 3150 |
|
| 3151 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 3152 |
@ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] List) |
| 3153 |
@key[return] List_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 3154 |
|
| 3155 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 3156 |
@ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] List; Start : @key[in] Cursor) |
| 3157 |
@key[return] List_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 3158 |
|
| 3159 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3160 |
@ChgAdded{Version=[2],Text=[ @key{generic} |
| 3161 |
@key{with function} "<" (Left, Right : Element_Type) |
| 3162 |
@key{return} Boolean is <>; |
| 3163 |
@key{package} @AdaPackDefn{Generic_Sorting} @key{is}]} |
| 3164 |
|
| 3165 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3166 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Sorted} (Container : List) @key{return} Boolean;]} |
| 3167 |
|
| 3168 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3169 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Sort} (Container : @key{in out} List);]} |
| 3170 |
|
| 3171 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3172 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Merge} (Target : @key{in out} List; |
| 3173 |
Source : @key{in out} List);]} |
| 3174 |
|
| 3175 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3176 |
@ChgAdded{Version=[2],Text=[ @key{end} Generic_Sorting;]} |
| 3177 |
|
| 3178 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3179 |
@ChgAdded{Version=[2],Text=[@key{private}]} |
| 3180 |
|
| 3181 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3182 |
@ChgAdded{Version=[2],Text=[ ... -- @RI[not specified by the language]]} |
| 3183 |
|
| 3184 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3185 |
@ChgAdded{Version=[2],Text=[@key{end} Ada.Containers.Doubly_Linked_Lists;]} |
| 3186 |
|
| 3187 |
@end{Example} |
| 3188 |
|
| 3189 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3190 |
@ChgAdded{Version=[2],Text=[The actual function for the generic formal function |
| 3191 |
"=" on Element_Type values is expected to define a reflexive and symmetric |
| 3192 |
relationship and return the same result value each time it is called with a |
| 3193 |
particular pair of values. If it behaves in some other manner, the functions |
| 3194 |
Find, Reverse_Find, and "=" on list values return an unspecified value. The |
| 3195 |
exact arguments and number of calls of this generic formal function by the |
| 3196 |
functions Find, Reverse_Find, and "=" on list values are |
| 3197 |
unspecified.@PDefn{unspecified}]} |
| 3198 |
|
| 3199 |
@begin{Ramification} |
| 3200 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3201 |
@ChgAdded{Version=[2],Text=[If the actual function for "=" is not symmetric |
| 3202 |
and consistent, the result returned by the listed functions cannot be predicted. |
| 3203 |
The implementation is not required to protect |
| 3204 |
against "=" raising an exception, or returning random results, or any |
| 3205 |
other @lquotes@;bad@rquotes behavior. And it can call "=" in whatever |
| 3206 |
manner makes sense. But note that only the results of Find, Reverse_Find, and |
| 3207 |
List "=" are unspecified; other subprograms are not allowed to break if "=" |
| 3208 |
is bad (they aren't expected to use "=").]} |
| 3209 |
@end{Ramification} |
| 3210 |
|
| 3211 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3212 |
@ChgAdded{Version=[2],Text=[The type List is used to represent lists. The type |
| 3213 |
List needs finalization@PDefn2{Term=<needs finalization>,Sec=<language-defined type>} |
| 3214 |
(see @RefSecNum{Assignment and Finalization}).]} |
| 3215 |
|
| 3216 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3217 |
@ChgAdded{Version=[2],Text=[Empty_List represents the empty List object. It has |
| 3218 |
a length of 0. If an object of type List is not otherwise initialized, it is |
| 3219 |
initialized to the same value as Empty_List.]} |
| 3220 |
|
| 3221 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3222 |
@ChgAdded{Version=[2],Text=[No_Element represents a cursor that designates no |
| 3223 |
element. If an object of type Cursor is not otherwise initialized, it is |
| 3224 |
initialized to the same value as No_Element.]} |
| 3225 |
|
| 3226 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3227 |
@ChgAdded{Version=[2],Text=[The predefined "=" operator for type Cursor returns |
| 3228 |
True if both cursors are No_Element, or designate the same element in the same |
| 3229 |
container.]} |
| 3230 |
|
| 3231 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3232 |
@ChgAdded{Version=[2],Text=[Execution of the default implementation of the |
| 3233 |
Input, Output, Read, or Write attribute of type Cursor raises Program_Error.]} |
| 3234 |
|
| 3235 |
@begin{Reason} |
| 3236 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3237 |
@ChgAdded{Version=[2],Text=[A cursor will probably be implemented in terms |
| 3238 |
of one or more access values, and the effects of streaming access values is |
| 3239 |
unspecified. Rather than letting the user stream junk by accident, we mandate |
| 3240 |
that streaming of cursors raise Program_Error by default. The attributes |
| 3241 |
can always be specified if there is a need to support streaming.]} |
| 3242 |
@end{Reason} |
| 3243 |
|
| 3244 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]} |
| 3245 |
@ChgAdded{Version=[3],Text=[List'Write for a List object @i<L> writes |
| 3246 |
Length(@i<L>) elements of the list to the stream. It also may write |
| 3247 |
additional information about the list.]} |
| 3248 |
|
| 3249 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]} |
| 3250 |
@ChgAdded{Version=[3],Text=[List'Read reads the representation of a list |
| 3251 |
from the stream, and assigns to @i<Item> a list with the same length and |
| 3252 |
elements as was written by List'Write.]} |
| 3253 |
|
| 3254 |
@begin{Ramification} |
| 3255 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 3256 |
@ChgAdded{Version=[3],Text=[Streaming more elements than the container |
| 3257 |
length is wrong. For implementation implications of this rule, see the Implementation Note in |
| 3258 |
@RefSecNum{The Generic Package Containers.Vectors}.]} |
| 3259 |
@end{Ramification} |
| 3260 |
|
| 3261 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3262 |
@ChgAdded{Version=[2],Text=[@Redundant[Some operations of this generic package |
| 3263 |
have access-to-subprogram parameters. To ensure such operations are |
| 3264 |
well-defined, they guard against certain actions by the designated |
| 3265 |
subprogram. In particular, some operations check for @lquotes@;tampering with |
| 3266 |
cursors@rquotes of a container because they depend on the set of elements of |
| 3267 |
the container remaining constant, and others check for @lquotes@;tampering with |
| 3268 |
elements@rquotes of a container because they depend on elements of the |
| 3269 |
container not being replaced.]]} |
| 3270 |
|
| 3271 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3272 |
@ChgAdded{Version=[2],Type=[Leading],Text=[@Defn2{Term=[tamper with cursors],Sec=[of a list]} |
| 3273 |
A subprogram is said to @i{tamper with cursors} of a list object |
| 3274 |
@i<L> if:]} |
| 3275 |
|
| 3276 |
@begin{Itemize} |
| 3277 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3278 |
@ChgAdded{Version=[2],Text=[it inserts or deletes elements of @i<L>, that is, |
| 3279 |
it calls the Insert, Clear, Delete, or Delete_Last procedures with @i<L> as a |
| 3280 |
parameter; or]} |
| 3281 |
|
| 3282 |
@begin{Honest} |
| 3283 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3284 |
@ChgAdded{Version=[2],Text=[Operations which are defined to be equivalent to |
| 3285 |
a call on one of these operations also are included. Similarly, operations |
| 3286 |
which call one of these as part of their definition are included.]} |
| 3287 |
@end{Honest} |
| 3288 |
|
| 3289 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3290 |
@ChgAdded{Version=[2],Text=[it reorders the elements of @i<L>, that is, it |
| 3291 |
calls the Splice, Swap_Links, or Reverse_Elements procedures or the Sort or |
| 3292 |
Merge procedures of an instance of Generic_Sorting with @i<L> as a parameter; or]} |
| 3293 |
|
| 3294 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3295 |
@ChgAdded{Version=[2],Text=[it finalizes @i<L>; or]} |
| 3296 |
|
| 3297 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 3298 |
@ChgAdded{Version=[3],Text=[it calls the Assign procedure with @i<L> as the |
| 3299 |
Target parameter; or]} |
| 3300 |
|
| 3301 |
@begin{Ramification} |
| 3302 |
@ChgRef{Version=[3],Kind=[Added]} |
| 3303 |
@ChgAdded{Version=[3],Text=[We don't need to explicitly mention |
| 3304 |
@nt{assignment_statement}, because that finalizes the target object |
| 3305 |
as part of the operation, and finalization of an object is already defined |
| 3306 |
as tampering with cursors.]} |
| 3307 |
@end{Ramification} |
| 3308 |
|
| 3309 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3310 |
@ChgAdded{Version=[2],Text=[it calls the Move procedure with @i<L> as a |
| 3311 |
parameter.]} |
| 3312 |
@end{Itemize} |
| 3313 |
|
| 3314 |
@begin{Reason} |
| 3315 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3316 |
@ChgAdded{Version=[2],Text=[Swap copies elements rather than reordering them, |
| 3317 |
so it doesn't tamper with cursors.]} |
| 3318 |
@end{Reason} |
| 3319 |
|
| 3320 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3321 |
@ChgAdded{Version=[2],Type=[Leading],Text=[@Defn2{Term=[tamper with elements],Sec=[of a list]} |
| 3322 |
A subprogram is said to @i{tamper with elements} of a list |
| 3323 |
object @i<L> if:]} |
| 3324 |
|
| 3325 |
@begin{Itemize} |
| 3326 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3327 |
@ChgAdded{Version=[2],Text=[it tampers with cursors of @i<L>; or]} |
| 3328 |
|
| 3329 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3330 |
@ChgAdded{Version=[2],Text=[it replaces one or more elements of @i<L>, that is, |
| 3331 |
it calls the Replace_Element or Swap procedures with @i<L> as |
| 3332 |
a parameter.]} |
| 3333 |
|
| 3334 |
@begin{Reason} |
| 3335 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3336 |
@ChgAdded{Version=[2],Text=[Complete replacement of an element can cause |
| 3337 |
its memory to be deallocated while another operation is holding onto a |
| 3338 |
reference to it. That can't be allowed. However, a simple modification of |
| 3339 |
(part of) an element is not a problem, so Update_Element does not cause a |
| 3340 |
problem.]} |
| 3341 |
@end{Reason} |
| 3342 |
|
| 3343 |
|
| 3344 |
@end{Itemize} |
| 3345 |
|
| 3346 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0265-1]} |
| 3347 |
@ChgRef{Version=[4],Kind=[RevisedAdded],ARef=[AI12-0110-1]} |
| 3348 |
@ChgAdded{Version=[3],Text=[@Defn2{Term=[prohibited],Sec=[tampering with a list]} |
| 3349 |
@Defn2{Term=[tampering],Sec=[prohibited for a list]} |
| 3350 |
When tampering with cursors is @i<prohibited> for a particular list object |
| 3351 |
@i<L>, Program_Error is propagated by a call of any language-defined subprogram |
| 3352 |
that is defined to tamper with the cursors of @i<L>, leaving @i<L> unmodified. |
| 3353 |
Similarly, when tampering with elements is @i<prohibited> for a particular list |
| 3354 |
object @i<L>, Program_Error is propagated by a call of any language-defined |
| 3355 |
subprogram that is defined to tamper with the elements of @i<L> @Redundant[(or |
| 3356 |
tamper with the cursors of @i<L>)], leaving @i<L> |
| 3357 |
unmodified.@Chg{Version=[4],New=[ These checks are made before any other |
| 3358 |
defined behavior of the body of the language-defined subprogram.],Old=[]}]} |
| 3359 |
@begin{TheProof} |
| 3360 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 3361 |
@ChgAdded{Version=[3],Text=[Tampering with elements includes tampering with |
| 3362 |
cursors, so we mention it only from completeness in the second sentence.]} |
| 3363 |
@end{TheProof} |
| 3364 |
|
| 3365 |
@begin{DescribeCode} |
| 3366 |
|
| 3367 |
@begin{Example} |
| 3368 |
@ChgRef{Version=[3],Kind=[Added]} |
| 3369 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean;]} |
| 3370 |
@end{Example} |
| 3371 |
|
| 3372 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 3373 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns True if Position designates |
| 3374 |
an element, and returns False otherwise.]} |
| 3375 |
|
| 3376 |
@begin{Honest} |
| 3377 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1],ARef=[AI05-0212-1]} |
| 3378 |
@ChgAdded{Version=[3],Text=[This function might not detect cursors that |
| 3379 |
designate deleted elements; such cursors are invalid (see below) and the |
| 3380 |
result of calling Has_Element with an invalid cursor is unspecified (but |
| 3381 |
not erroneous).]} |
| 3382 |
@end{Honest} |
| 3383 |
|
| 3384 |
@begin{Example} |
| 3385 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3386 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "=" (Left, Right : List) @key{return} Boolean;]} |
| 3387 |
@end{Example} |
| 3388 |
|
| 3389 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3390 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 3391 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Left and Right denote the same |
| 3392 |
list object, then the function returns True. If Left and Right have different |
| 3393 |
lengths, then the function returns False. |
| 3394 |
Otherwise, it compares each element in Left to |
| 3395 |
the corresponding element in Right using the generic formal equality operator. |
| 3396 |
If any such comparison returns False, the function returns False; |
| 3397 |
otherwise@Chg{Version=[3],New=[,],Old=[]} it |
| 3398 |
returns True. Any exception raised during |
| 3399 |
evaluation of element equality is propagated.]} |
| 3400 |
@begin{ImplNote} |
| 3401 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3402 |
@ChgAdded{Version=[2],Text=[This wording describes the canonical semantics. |
| 3403 |
However, the order and number of calls on the formal equality function is |
| 3404 |
unspecified for all of the operations that use it in this package, so an |
| 3405 |
implementation can call it as many or as few times as it needs to get the |
| 3406 |
correct answer. Specifically, there is no requirement to call the formal |
| 3407 |
equality additional times once the answer has been determined.]} |
| 3408 |
@end{ImplNote} |
| 3409 |
|
| 3410 |
@begin{Example} |
| 3411 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3412 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Length (Container : List) @key{return} Count_Type;]} |
| 3413 |
@end{Example} |
| 3414 |
|
| 3415 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3416 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the number of elements in |
| 3417 |
Container.]} |
| 3418 |
|
| 3419 |
@begin{Example} |
| 3420 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3421 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Is_Empty (Container : List) @key{return} Boolean;]} |
| 3422 |
@end{Example} |
| 3423 |
|
| 3424 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3425 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Length (Container) = 0.]} |
| 3426 |
|
| 3427 |
@begin{Example} |
| 3428 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3429 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Clear (Container : @key{in out} List);]} |
| 3430 |
@end{Example} |
| 3431 |
|
| 3432 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3433 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Removes all the elements from Container.]} |
| 3434 |
|
| 3435 |
@begin{Example} |
| 3436 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3437 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Element (Position : Cursor) @key{return} Element_Type;]} |
| 3438 |
@end{Example} |
| 3439 |
|
| 3440 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3441 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 3442 |
Constraint_Error is propagated. Otherwise, Element returns the element |
| 3443 |
designated by Position.]} |
| 3444 |
|
| 3445 |
@begin{Example} |
| 3446 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3447 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace_Element (Container : @key{in out} List; |
| 3448 |
Position : @b{in} Cursor; |
| 3449 |
New_Item : @b{in} Element_Type);]} |
| 3450 |
@end{Example} |
| 3451 |
|
| 3452 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3453 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 3454 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, |
| 3455 |
then Constraint_Error is propagated; if Position does not designate an element |
| 3456 |
in Container, then Program_Error is propagated. |
| 3457 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} Replace_Element |
| 3458 |
assigns the value New_Item to the element designated by Position.]} |
| 3459 |
|
| 3460 |
@begin{Example} |
| 3461 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3462 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Query_Element |
| 3463 |
(Position : @key{in} Cursor; |
| 3464 |
Process : @key{not null access procedure} (Element : @key{in} Element_Type));]} |
| 3465 |
@end{Example} |
| 3466 |
|
| 3467 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3468 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1],ARef=[AI05-0265-1]} |
| 3469 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 3470 |
Constraint_Error is propagated. Otherwise, Query_Element calls |
| 3471 |
Process.@key{all} with the element designated by Position as the argument. |
| 3472 |
@Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 3473 |
is propagated if Process.@key{all} tampers]} |
| 3474 |
with the elements of @Chg{Version=[3],New=[the list that contains the |
| 3475 |
element designated by Position is prohibited during the |
| 3476 |
execution of the call on Process.@key{all}],Old=[Container]}. Any exception raised by |
| 3477 |
Process.@key{all} is propagated.]} |
| 3478 |
|
| 3479 |
@begin{Example} |
| 3480 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3481 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Update_Element |
| 3482 |
(Container : @key{in out} List; |
| 3483 |
Position : @key{in} Cursor; |
| 3484 |
Process : @key{not null access procedure} (Element : @key{in out} Element_Type));]} |
| 3485 |
@end{Example} |
| 3486 |
|
| 3487 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3488 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1],ARef=[AI05-0265-1]} |
| 3489 |
@ChgAdded{Version=[2],Text=[If Position equals No_Element, then |
| 3490 |
Constraint_Error is propagated; if Position does not designate an element in |
| 3491 |
Container, then Program_Error is propagated. |
| 3492 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} Update_Element calls |
| 3493 |
Process.@key{all} with the element designated by Position as the |
| 3494 |
argument. @Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 3495 |
is propagated if Process.@key{all} tampers]} |
| 3496 |
with the elements of Container@Chg{Version=[3],New=[ is prohibited during the |
| 3497 |
execution of the call on Process.@key{all}],Old=[]}. Any exception raised by |
| 3498 |
Process.@key{all} is propagated.]} |
| 3499 |
|
| 3500 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3501 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Element_Type is unconstrained |
| 3502 |
and definite, then the actual Element parameter of Process.@key{all} shall be |
| 3503 |
unconstrained.]} |
| 3504 |
|
| 3505 |
@begin{Ramification} |
| 3506 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3507 |
@ChgAdded{Version=[2],Text=[This means that the elements cannot be directly |
| 3508 |
allocated from the heap; it must be possible to change the discriminants of |
| 3509 |
the element in place.]} |
| 3510 |
@end{Ramification} |
| 3511 |
|
| 3512 |
@begin{Example} |
| 3513 |
@ChgRef{Version=[3],Kind=[Added]} |
| 3514 |
@ChgAdded{Version=[3],Text=[@key[type] Constant_Reference_Type |
| 3515 |
(Element : @key[not null access constant] Element_Type) @key[is private] |
| 3516 |
@key[with] Implicit_Dereference => Element;]} |
| 3517 |
|
| 3518 |
@ChgRef{Version=[3],Kind=[Added]} |
| 3519 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[type] Reference_Type (Element : @key[not null access] Element_Type) @key[is private] |
| 3520 |
@key[with] Implicit_Dereference => Element;]} |
| 3521 |
@end{Example} |
| 3522 |
|
| 3523 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 3524 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[The types Constant_Reference_Type |
| 3525 |
and Reference_Type need finalization.@PDefn2{Term=<needs finalization>, |
| 3526 |
Sec=<language-defined type>}]} |
| 3527 |
|
| 3528 |
@ChgRef{Version=[3],Kind=[Added]} |
| 3529 |
@ChgAdded{Version=[3],Text=[The default initialization of an object of type |
| 3530 |
Constant_Reference_Type or Reference_Type propagates Program_Error.]} |
| 3531 |
|
| 3532 |
@begin{Reason} |
| 3533 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 3534 |
@ChgAdded{Version=[3],Text=[It is expected that Reference_Type (and |
| 3535 |
Constant_Reference_Type) will be a controlled type, for which finalization |
| 3536 |
will have some action to terminate the tampering check for the associated |
| 3537 |
container. If the object is created by default, however, there is no |
| 3538 |
associated container. Since this is useless, and supporting this case would |
| 3539 |
take extra work, we define it to raise an exception.]} |
| 3540 |
@end{Reason} |
| 3541 |
|
| 3542 |
@begin{Example} |
| 3543 |
@ChgRef{Version=[3],Kind=[Added]} |
| 3544 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] List; |
| 3545 |
Position : @key[in] Cursor) |
| 3546 |
@key[return] Constant_Reference_Type;]} |
| 3547 |
@end{Example} |
| 3548 |
|
| 3549 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 3550 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 3551 |
Constant_Indexing and Implicit_Dereference aspects) provides a convenient way to |
| 3552 |
gain read access to an individual element of a list given a |
| 3553 |
cursor.]} |
| 3554 |
|
| 3555 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]} |
| 3556 |
@ChgAdded{Version=[3],Text=[If Position equals No_Element, then Constraint_Error |
| 3557 |
is propagated; if Position does not designate an element in Container, then |
| 3558 |
Program_Error is propagated. Otherwise, Constant_Reference returns an object |
| 3559 |
whose discriminant is an access value that designates the element designated by |
| 3560 |
Position. Tampering with the elements of Container is prohibited while the |
| 3561 |
object returned by Constant_Reference exists and has not been finalized.]} |
| 3562 |
|
| 3563 |
@begin{Example} |
| 3564 |
@ChgRef{Version=[3],Kind=[Added]} |
| 3565 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference (Container : @key[aliased in out] List; |
| 3566 |
Position : @key[in] Cursor) |
| 3567 |
@key[return] Reference_Type;]} |
| 3568 |
@end{Example} |
| 3569 |
|
| 3570 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 3571 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 3572 |
Variable_Indexing and Implicit_Dereference aspects) provides a convenient way to |
| 3573 |
gain read and write access to an individual element of a list given |
| 3574 |
a cursor.]} |
| 3575 |
|
| 3576 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]} |
| 3577 |
@ChgAdded{Version=[3],Text=[If Position equals No_Element, then Constraint_Error |
| 3578 |
is propagated; if Position does not designate an element in Container, then |
| 3579 |
Program_Error is propagated. Otherwise, Reference returns an object whose |
| 3580 |
discriminant is an access value that designates the element designated by |
| 3581 |
Position. Tampering with the elements of Container is prohibited while the |
| 3582 |
object returned by Reference exists and has not been finalized.]} |
| 3583 |
|
| 3584 |
@begin{Example} |
| 3585 |
@ChgRef{Version=[3],Kind=[Added]} |
| 3586 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key{procedure} Assign (Target : @key{in out} List; Source : @key{in} List);]} |
| 3587 |
@end{Example} |
| 3588 |
|
| 3589 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0248-1]} |
| 3590 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[If Target denotes the same object as |
| 3591 |
Source, the operation has no effect. Otherwise, the elements of Source are |
| 3592 |
copied to Target as for an @nt{assignment_statement} assigning Source to |
| 3593 |
Target.]} |
| 3594 |
@begin{Discussion} |
| 3595 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1]} |
| 3596 |
@ChgAdded{Version=[3],Text=[This routine exists for compatibility with the |
| 3597 |
bounded list container. For an unbounded list, @exam{Assign(A, B)} and |
| 3598 |
@exam{A := B} behave identically. For a bounded list, := will raise an |
| 3599 |
exception if the container capacities are different, while Assign will |
| 3600 |
not raise an exception if there is enough room in the target.]} |
| 3601 |
@end{Discussion} |
| 3602 |
|
| 3603 |
@begin{Example} |
| 3604 |
@ChgRef{Version=[3],Kind=[Added]} |
| 3605 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key{function} Copy (Source : List) @key[return] List;]} |
| 3606 |
@end{Example} |
| 3607 |
|
| 3608 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 3609 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns a list whose elements match |
| 3610 |
the elements of Source.]} |
| 3611 |
|
| 3612 |
@begin{Example} |
| 3613 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3614 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Move (Target : @key{in out} List; |
| 3615 |
Source : @key{in out} List);]} |
| 3616 |
@end{Example} |
| 3617 |
|
| 3618 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3619 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0262-1]} |
| 3620 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Target denotes the same object |
| 3621 |
as Source, then @Chg{Version=[3],New=[the operation],Old=[Move]} |
| 3622 |
has no effect. Otherwise, @Chg{Version=[3],New=[the operation is equivalent |
| 3623 |
to Assign (Target, Source) followed by Clear (Source)],Old=[Move first calls Clear |
| 3624 |
(Target). Then, the nodes in Source are moved to Target (in the original order). |
| 3625 |
The length of Target is set to the length of Source, and the length of Source is |
| 3626 |
set to 0]}.]} |
| 3627 |
|
| 3628 |
@begin{Example} |
| 3629 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3630 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} List; |
| 3631 |
Before : @key{in} Cursor; |
| 3632 |
New_Item : @key{in} Element_Type; |
| 3633 |
Count : @key{in} Count_Type := 1);]} |
| 3634 |
@end{Example} |
| 3635 |
|
| 3636 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3637 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Before is not No_Element, and |
| 3638 |
does not designate an element in Container, then Program_Error is propagated. |
| 3639 |
Otherwise, |
| 3640 |
Insert inserts Count copies of New_Item prior to the element designated by |
| 3641 |
Before. If Before equals No_Element, the new elements are inserted after the |
| 3642 |
last node (if any). Any exception raised during allocation of internal storage |
| 3643 |
is propagated, and Container is not modified.]} |
| 3644 |
|
| 3645 |
@begin{Ramification} |
| 3646 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3647 |
@ChgAdded{Version=[2],Text=[The check on Before checks that the cursor does |
| 3648 |
not belong to some other Container. This check implies that a reference to |
| 3649 |
the container is included in the cursor value. This wording is not meant to |
| 3650 |
require detection of dangling cursors; such cursors are defined to be |
| 3651 |
invalid, which means that execution is erroneous, and any result is allowed |
| 3652 |
(including not raising an exception).]} |
| 3653 |
@end{Ramification} |
| 3654 |
|
| 3655 |
@begin{Example} |
| 3656 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3657 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} List; |
| 3658 |
Before : @key{in} Cursor; |
| 3659 |
New_Item : @key{in} Element_Type; |
| 3660 |
Position : @key{out} Cursor; |
| 3661 |
Count : @key{in} Count_Type := 1);]} |
| 3662 |
@end{Example} |
| 3663 |
|
| 3664 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3665 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0257-1]} |
| 3666 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Before is not No_Element, and |
| 3667 |
does not designate an element in Container, then Program_Error is |
| 3668 |
propagated. Otherwise, |
| 3669 |
Insert allocates Count copies of New_Item, and inserts them prior to the |
| 3670 |
element designated by Before. If Before equals No_Element, the new elements are |
| 3671 |
inserted after the last element (if any). Position designates the first |
| 3672 |
newly-inserted element@Chg{Version=[3],New=[, or if Count equals 0, |
| 3673 |
then Position is assigned the value of Before],Old=[]}. Any exception raised |
| 3674 |
during allocation of internal |
| 3675 |
storage is propagated, and Container is not modified.]} |
| 3676 |
|
| 3677 |
@begin{Example} |
| 3678 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3679 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} List; |
| 3680 |
Before : @key{in} Cursor; |
| 3681 |
Position : @key{out} Cursor; |
| 3682 |
Count : @key{in} Count_Type := 1);]} |
| 3683 |
@end{Example} |
| 3684 |
|
| 3685 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3686 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0257-1]} |
| 3687 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Before is not No_Element, and |
| 3688 |
does not designate an element in Container, then Program_Error is |
| 3689 |
propagated. Otherwise, |
| 3690 |
Insert inserts Count new elements prior to the element designated by Before. If |
| 3691 |
Before equals No_Element, the new elements are inserted after the last node (if |
| 3692 |
any). The new elements are initialized by default (see |
| 3693 |
@RefSecNum{Object Declarations}). @Chg{Version=[3],New=[Position designates the |
| 3694 |
first newly-inserted element, or if Count equals 0, |
| 3695 |
then Position is assigned the value of Before],Old=[]}. Any exception raised |
| 3696 |
during allocation of internal storage is propagated, and Container is not |
| 3697 |
modified.]} |
| 3698 |
|
| 3699 |
@begin{Example} |
| 3700 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3701 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Prepend (Container : @key{in out} List; |
| 3702 |
New_Item : @key{in} Element_Type; |
| 3703 |
Count : @key{in} Count_Type := 1);]} |
| 3704 |
@end{Example} |
| 3705 |
|
| 3706 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3707 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, |
| 3708 |
First (Container), New_Item, Count).]} |
| 3709 |
|
| 3710 |
@begin{Example} |
| 3711 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3712 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Append (Container : @key{in out} List; |
| 3713 |
New_Item : @key{in} Element_Type; |
| 3714 |
Count : @key{in} Count_Type := 1);]} |
| 3715 |
@end{Example} |
| 3716 |
|
| 3717 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3718 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Insert (Container, |
| 3719 |
No_Element, New_Item, Count).]} |
| 3720 |
|
| 3721 |
@begin{Example} |
| 3722 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3723 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} List; |
| 3724 |
Position : @key{in out} Cursor; |
| 3725 |
Count : @key{in} Count_Type := 1);]} |
| 3726 |
@end{Example} |
| 3727 |
|
| 3728 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3729 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 3730 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 3731 |
Constraint_Error is propagated. If Position does not designate an element in |
| 3732 |
Container, then Program_Error is propagated. |
| 3733 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} Delete removes (from |
| 3734 |
Container) Count elements starting at the element designated by Position (or |
| 3735 |
all of the elements starting at Position if there are fewer than Count elements |
| 3736 |
starting at Position). Finally, Position is set to No_Element.]} |
| 3737 |
|
| 3738 |
@begin{Example} |
| 3739 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3740 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_First (Container : @key{in out} List; |
| 3741 |
Count : @key{in} Count_Type := 1);]} |
| 3742 |
@end{Example} |
| 3743 |
|
| 3744 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3745 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1]} |
| 3746 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[If Length |
| 3747 |
(Container) <= Count, then Delete_First is equivalent to Clear (Container). |
| 3748 |
Otherwise, it removes the first Count nodes from Container],Old=[Equivelent to |
| 3749 |
Delete (Container, First (Container), Count)]}.]} |
| 3750 |
|
| 3751 |
@begin{Example} |
| 3752 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3753 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_Last (Container : @key{in out} List; |
| 3754 |
Count : @key{in} Count_Type := 1);]} |
| 3755 |
@end{Example} |
| 3756 |
|
| 3757 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3758 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 3759 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If |
| 3760 |
Length (Container) <= Count@Chg{Version=[3],New=[,],Old=[]} then |
| 3761 |
Delete_Last is equivalent to Clear (Container). |
| 3762 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} it removes the last |
| 3763 |
Count nodes from Container.]} |
| 3764 |
|
| 3765 |
|
| 3766 |
@begin{Example} |
| 3767 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3768 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reverse_Elements (Container : @key{in out} List);]} |
| 3769 |
@end{Example} |
| 3770 |
|
| 3771 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3772 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Reorders the elements of Container |
| 3773 |
in reverse order.]} |
| 3774 |
|
| 3775 |
@begin{Discussion} |
| 3776 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3777 |
@ChgAdded{Version=[2],Text=[Unlike the similar routine for a vector, |
| 3778 |
elements should not be copied; rather, the nodes should be exchanged. Cursors |
| 3779 |
are expected to reference the same elements afterwards.]} |
| 3780 |
@end{Discussion} |
| 3781 |
|
| 3782 |
|
| 3783 |
@begin{Example} |
| 3784 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3785 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Swap (Container : @key{in out} List; |
| 3786 |
I, J : @key{in} Cursor);]} |
| 3787 |
@end{Example} |
| 3788 |
|
| 3789 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3790 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If either I or J is No_Element, |
| 3791 |
then Constraint_Error is propagated. If either I or J do not designate an |
| 3792 |
element in Container, then Program_Error is propagated. Otherwise, Swap |
| 3793 |
exchanges the values of the elements designated by I and J.]} |
| 3794 |
|
| 3795 |
@begin{Ramification} |
| 3796 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3797 |
@ChgAdded{Version=[2],Text=[After a call to Swap, I designates the element |
| 3798 |
value previously designated by J, and J designates the element value |
| 3799 |
previously designated by I. The cursors do not become ambiguous from |
| 3800 |
this operation.]} |
| 3801 |
@end{Ramification} |
| 3802 |
|
| 3803 |
@begin{Honest} |
| 3804 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3805 |
@ChgAdded{Version=[2],Text=[The implementation is not required to actually |
| 3806 |
copy the elements if it can do the swap some other way. But it is allowed |
| 3807 |
to copy the elements if needed.]} |
| 3808 |
@end{Honest} |
| 3809 |
|
| 3810 |
@begin{Example} |
| 3811 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3812 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Swap_Links (Container : @key{in out} List; |
| 3813 |
I, J : @key{in} Cursor);]} |
| 3814 |
@end{Example} |
| 3815 |
|
| 3816 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3817 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If either I or J is No_Element, |
| 3818 |
then Constraint_Error is propagated. If either I or J do not designate an |
| 3819 |
element in Container, then Program_Error is propagated. Otherwise, Swap_Links |
| 3820 |
exchanges the nodes designated by I and J.]} |
| 3821 |
|
| 3822 |
@begin{Ramification} |
| 3823 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3824 |
@ChgAdded{Version=[2],Text=[Unlike Swap, this exchanges the nodes, not the |
| 3825 |
elements. No copying is performed. I and J designate the same elements after |
| 3826 |
this call as they did before it. This operation can provide better performance |
| 3827 |
than Swap if the element size is large.]} |
| 3828 |
@end{Ramification} |
| 3829 |
|
| 3830 |
@begin{Example} |
| 3831 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3832 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Splice (Target : @key{in out} List; |
| 3833 |
Before : @key{in} Cursor; |
| 3834 |
Source : @key{in out} List);]} |
| 3835 |
@end{Example} |
| 3836 |
|
| 3837 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3838 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Before is not No_Element, and |
| 3839 |
does not designate an element in Target, then Program_Error is propagated. |
| 3840 |
Otherwise, if |
| 3841 |
Source denotes the same object as Target, the operation has no effect. |
| 3842 |
Otherwise, Splice reorders elements such that they are removed from Source and |
| 3843 |
moved to Target, immediately prior to Before. If Before equals No_Element, the |
| 3844 |
nodes of Source are spliced after the last node of Target. The length of Target |
| 3845 |
is incremented by the number of nodes in Source, and the length of Source is |
| 3846 |
set to 0.]} |
| 3847 |
|
| 3848 |
@begin{Example} |
| 3849 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3850 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Splice (Target : @key{in out} List; |
| 3851 |
Before : @key{in} Cursor; |
| 3852 |
Source : @key{in out} List; |
| 3853 |
Position : @key{in out} Cursor);]} |
| 3854 |
@end{Example} |
| 3855 |
|
| 3856 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3857 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 3858 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position is |
| 3859 |
No_Element@Chg{Version=[3],New=[,],Old=[]} then |
| 3860 |
Constraint_Error is propagated. If Before does not equal No_Element, and does |
| 3861 |
not designate an element in Target, then Program_Error is propagated. If |
| 3862 |
Position does not equal No_Element, and does not designate a node in Source, |
| 3863 |
then Program_Error is propagated. If Source denotes the same object as Target, |
| 3864 |
then there is no effect if Position equals Before, else the element |
| 3865 |
designated by Position is moved immediately prior to Before, or, if Before |
| 3866 |
equals No_Element, after the last element. |
| 3867 |
In both cases, Position and the length of Target are unchanged. |
| 3868 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} the element |
| 3869 |
designated by Position is removed from Source and moved to Target, immediately |
| 3870 |
prior to Before, or, if Before equals No_Element, after the last element of |
| 3871 |
Target. The length of Target is incremented, the length of Source is |
| 3872 |
decremented, and Position is updated to represent an element in Target.]} |
| 3873 |
@begin{Ramification} |
| 3874 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3875 |
@ChgAdded{Version=[2],Text=[If Source is the same as Target, and |
| 3876 |
Position = Before, or Next(Position) = Before, Splice has no effect, as |
| 3877 |
the element does not have to move to meet the postcondition.]} |
| 3878 |
@end{Ramification} |
| 3879 |
|
| 3880 |
@begin{Example} |
| 3881 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3882 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Splice (Container: @key{in out} List; |
| 3883 |
Before : @key{in} Cursor; |
| 3884 |
Position : @key{in} Cursor);]} |
| 3885 |
@end{Example} |
| 3886 |
|
| 3887 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3888 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 3889 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position is |
| 3890 |
No_Element@Chg{Version=[3],New=[,],Old=[]} then |
| 3891 |
Constraint_Error is propagated. If Before does not equal No_Element, and does |
| 3892 |
not designate an element in Container, then Program_Error is propagated. If |
| 3893 |
Position does not equal No_Element, and does not designate a node in Container, |
| 3894 |
then Program_Error is propagated. If Position equals Before there is no effect. |
| 3895 |
Otherwise, the element designated by Position is moved immediately prior to |
| 3896 |
Before, or, if Before equals No_Element, after the last element. The length of |
| 3897 |
Container is unchanged.]} |
| 3898 |
|
| 3899 |
@begin{Example} |
| 3900 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3901 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First (Container : List) @key{return} Cursor;]} |
| 3902 |
@end{Example} |
| 3903 |
|
| 3904 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3905 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 3906 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, First |
| 3907 |
returns the value No_Element. |
| 3908 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 3909 |
it returns a cursor that designates the first node in Container.]} |
| 3910 |
|
| 3911 |
@begin{Example} |
| 3912 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3913 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First_Element (Container : List) @key{return} Element_Type;]} |
| 3914 |
@end{Example} |
| 3915 |
|
| 3916 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3917 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (First (Container)).]} |
| 3918 |
|
| 3919 |
@begin{Example} |
| 3920 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3921 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last (Container : List) @key{return} Cursor;]} |
| 3922 |
@end{Example} |
| 3923 |
|
| 3924 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3925 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 3926 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Last returns |
| 3927 |
the value No_Element. Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 3928 |
it returns a cursor that designates the last node in Container.]} |
| 3929 |
|
| 3930 |
@begin{Example} |
| 3931 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3932 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last_Element (Container : List) @key{return} Element_Type;]} |
| 3933 |
@end{Example} |
| 3934 |
|
| 3935 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3936 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Last (Container)).]} |
| 3937 |
|
| 3938 |
@begin{Example} |
| 3939 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3940 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Next (Position : Cursor) @key{return} Cursor;]} |
| 3941 |
@end{Example} |
| 3942 |
|
| 3943 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3944 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element or |
| 3945 |
designates the last element of the container, then Next returns the value |
| 3946 |
No_Element. Otherwise, it returns a cursor that designates the successor of the |
| 3947 |
element designated by Position.]} |
| 3948 |
|
| 3949 |
@begin{Example} |
| 3950 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3951 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Previous (Position : Cursor) @key{return} Cursor;]} |
| 3952 |
@end{Example} |
| 3953 |
|
| 3954 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3955 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element or |
| 3956 |
designates the first element of the container, then Previous returns the value |
| 3957 |
No_Element. Otherwise, it returns a cursor that designates the predecessor of |
| 3958 |
the element designated by Position.]} |
| 3959 |
|
| 3960 |
@begin{Example} |
| 3961 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3962 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Next (Position : @key{in out} Cursor);]} |
| 3963 |
@end{Example} |
| 3964 |
|
| 3965 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3966 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Next (Position).]} |
| 3967 |
|
| 3968 |
@begin{Example} |
| 3969 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3970 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Previous (Position : @key{in out} Cursor);]} |
| 3971 |
@end{Example} |
| 3972 |
|
| 3973 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3974 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Previous (Position).]} |
| 3975 |
|
| 3976 |
@begin{Example} |
| 3977 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3978 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Find (Container : List; |
| 3979 |
Item : Element_Type; |
| 3980 |
Position : Cursor := No_Element) |
| 3981 |
@key{return} Cursor;]} |
| 3982 |
@end{Example} |
| 3983 |
|
| 3984 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 3985 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position is not No_Element, and |
| 3986 |
does not designate an element in Container, then Program_Error is propagated. |
| 3987 |
Find searches the elements of Container for an element equal to Item (using |
| 3988 |
the generic formal equality operator). The search starts at the |
| 3989 |
element designated by Position, or at the first element if Position equals |
| 3990 |
No_Element. It proceeds towards Last (Container). If no equal element is found, |
| 3991 |
then Find returns No_Element. Otherwise, it returns a cursor designating the |
| 3992 |
first equal element encountered.]} |
| 3993 |
|
| 3994 |
@begin{Example} |
| 3995 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 3996 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Reverse_Find (Container : List; |
| 3997 |
Item : Element_Type; |
| 3998 |
Position : Cursor := No_Element) |
| 3999 |
@key{return} Cursor;]} |
| 4000 |
@end{Example} |
| 4001 |
|
| 4002 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4003 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position is not No_Element, and |
| 4004 |
does not designate an element in Container, then Program_Error is propagated. |
| 4005 |
Find searches the elements of Container for an element equal to Item (using |
| 4006 |
the generic formal equality operator). The search starts at the |
| 4007 |
element designated by Position, or at the last element if Position equals |
| 4008 |
No_Element. It proceeds towards First (Container). If no equal element is |
| 4009 |
found, then Reverse_Find returns No_Element. Otherwise, it returns a cursor |
| 4010 |
designating the first equal element encountered.]} |
| 4011 |
|
| 4012 |
@begin{Example} |
| 4013 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4014 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Contains (Container : List; |
| 4015 |
Item : Element_Type) @key{return} Boolean;]} |
| 4016 |
@end{Example} |
| 4017 |
|
| 4018 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4019 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Find (Container, Item) /= No_Element.]} |
| 4020 |
|
| 4021 |
@begin{Example} |
| 4022 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4023 |
@ChgRef{Version=[3],Kind=[DeletedNoDelMsg]} |
| 4024 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@Chg{Version=[3],New=[],Old=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean;]}]} |
| 4025 |
@end{Example} |
| 4026 |
|
| 4027 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4028 |
@ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]} |
| 4029 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[],Old=[Returns True if Position designates |
| 4030 |
an element, and returns False otherwise.]}]} |
| 4031 |
|
| 4032 |
@begin{Honest} |
| 4033 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4034 |
@ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]} |
| 4035 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[This function may not detect cursors that |
| 4036 |
designate deleted elements; such cursors are invalid (see below) and the |
| 4037 |
result of calling Has_Element with an invalid cursor is unspecified (but |
| 4038 |
not erroneous).]}]} |
| 4039 |
@end{Honest} |
| 4040 |
@begin{NotIso} |
| 4041 |
@ChgAdded{Version=[3],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 139 and 140 |
| 4042 |
were moved above.>}]}@Comment{This message should be |
| 4043 |
deleted if the paragraphs are ever renumbered.} |
| 4044 |
@end{NotIso} |
| 4045 |
|
| 4046 |
@begin{Example} |
| 4047 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4048 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Iterate |
| 4049 |
(Container : @key{in} List; |
| 4050 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 4051 |
@end{Example} |
| 4052 |
|
| 4053 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4054 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]} |
| 4055 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Iterate calls Process.@key{all} |
| 4056 |
with a cursor that designates each node in Container, starting with the first |
| 4057 |
node and moving the cursor as per the Next function. |
| 4058 |
@Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 4059 |
is propagated if Process.@key{all} tampers]} |
| 4060 |
with the cursors of Container@Chg{Version=[3],New=[ is prohibited during the |
| 4061 |
execution of a call on Process.@key{all}],Old=[]}. Any exception raised by |
| 4062 |
Process.@key{all} is propagated.]} |
| 4063 |
|
| 4064 |
@begin{ImplNote} |
| 4065 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4066 |
@ChgAdded{Version=[2],Text=[The purpose of the tamper with cursors check is |
| 4067 |
to prevent erroneous execution from the Position parameter of Process.@key{all} |
| 4068 |
becoming invalid. This check takes place when the operations that tamper with |
| 4069 |
the cursors of the container are called. The check cannot be made later (say |
| 4070 |
in the body of Iterate), because that could cause the Position cursor to be |
| 4071 |
invalid and potentially cause execution to become erroneous -- defeating the |
| 4072 |
purpose of the check.]} |
| 4073 |
|
| 4074 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4075 |
@ChgAdded{Version=[2],Text=[See Iterate for vectors |
| 4076 |
(@RefSecNum{The Generic Package Containers.Vectors}) for a suggested |
| 4077 |
implementation of the check.]} |
| 4078 |
@end{ImplNote} |
| 4079 |
|
| 4080 |
@begin{Example} |
| 4081 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4082 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reverse_Iterate |
| 4083 |
(Container : @key{in} List; |
| 4084 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 4085 |
@end{Example} |
| 4086 |
|
| 4087 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4088 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]} |
| 4089 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Iterates over the nodes in |
| 4090 |
Container as per @Chg{Version=[3],New=[procedure ],Old=[]}Iterate, |
| 4091 |
except that elements are traversed in reverse order, |
| 4092 |
starting with the last node and moving the cursor as per the Previous |
| 4093 |
function.]} |
| 4094 |
|
| 4095 |
@begin{Example} |
| 4096 |
@ChgRef{Version=[3],Kind=[Added]} |
| 4097 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] List) |
| 4098 |
@key[return] List_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 4099 |
@end{Example} |
| 4100 |
|
| 4101 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]} |
| 4102 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Iterate returns a reversible |
| 4103 |
iterator object (see @RefSecNum{User-Defined Iterator Types}) that |
| 4104 |
will generate a value for a loop parameter (see |
| 4105 |
@RefSecNum{Generalized Loop Iteration}) designating |
| 4106 |
each node in Container, starting with the first node and moving the cursor as |
| 4107 |
per the Next function when used as a forward iterator, and starting with the |
| 4108 |
last node and moving the cursor as per the Previous function when used as a |
| 4109 |
reverse iterator. Tampering with the cursors of Container is prohibited while |
| 4110 |
the iterator object exists (in particular, in |
| 4111 |
the @nt{sequence_of_statements} of the @nt{loop_statement} whose |
| 4112 |
@nt{iterator_specification} denotes this object). The iterator object needs |
| 4113 |
finalization.]} |
| 4114 |
|
| 4115 |
@begin{Example} |
| 4116 |
@ChgRef{Version=[3],Kind=[Added]} |
| 4117 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] List; Start : @key[in] Cursor) |
| 4118 |
@key[return] List_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 4119 |
@end{Example} |
| 4120 |
|
| 4121 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0262-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]} |
| 4122 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[If Start is not No_Element and does |
| 4123 |
not designate an item in Container, then Program_Error is propagated. If Start |
| 4124 |
is No_Element, then Constraint_Error is propagated. Otherwise, Iterate |
| 4125 |
returns a reversible iterator object |
| 4126 |
(see @RefSecNum{User-Defined Iterator Types}) that |
| 4127 |
will generate a value for a loop parameter (see |
| 4128 |
@RefSecNum{Generalized Loop Iteration}) designating |
| 4129 |
each node in Container, starting with the node designated |
| 4130 |
by Start and moving the cursor as per the Next function when used as a forward |
| 4131 |
iterator, or moving the cursor as per the Previous function when used as a |
| 4132 |
reverse iterator. Tampering with the cursors of Container is prohibited while |
| 4133 |
the iterator object exists (in particular, in |
| 4134 |
the @nt{sequence_of_statements} of the @nt{loop_statement} whose |
| 4135 |
@nt{iterator_specification} denotes this object). The iterator object needs |
| 4136 |
finalization.]} |
| 4137 |
|
| 4138 |
@begin{Discussion} |
| 4139 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 4140 |
@ChgAdded{Version=[3],Type=[Leading],Text=[Exits are allowed from the loops |
| 4141 |
created using the iterator objects. In particular, to stop the iteration at a |
| 4142 |
particular cursor, just add]} |
| 4143 |
@begin{Example} |
| 4144 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 4145 |
@ChgAdded{Version=[3],Text=[@key[exit when] Cur = Stop;]} |
| 4146 |
@end{Example} |
| 4147 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 4148 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[in the body of the loop (assuming |
| 4149 |
that @exam{Cur} is the loop parameter and @exam{Stop} is the cursor that you |
| 4150 |
want to stop at).]} |
| 4151 |
@end{Discussion} |
| 4152 |
|
| 4153 |
@end{DescribeCode} |
| 4154 |
|
| 4155 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4156 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0044-1],ARef=[AI05-0262-1]} |
| 4157 |
@ChgAdded{Version=[2],Text=[The actual function for the generic formal function |
| 4158 |
"<" of Generic_Sorting is expected to return the same value each time it is |
| 4159 |
called with a particular pair of element values. It should define a strict |
| 4160 |
@Chg{Version=[3],New=[weak ],Old=[]}ordering relationship@Chg{Version=[3], |
| 4161 |
New=[ (see @RefSecNum{Containers})],Old=[, that is, be irreflexive, asymmetric, |
| 4162 |
and transitive]}; it |
| 4163 |
should not modify Container. If the actual for "<" behaves in some other |
| 4164 |
manner, the behavior of the subprograms of Generic_Sorting are unspecified. |
| 4165 |
@Chg{Version=[3],New=[The number of],Old=[How many]} times the subprograms of |
| 4166 |
Generic_Sorting call "<" is unspecified.@PDefn{unspecified}]} |
| 4167 |
|
| 4168 |
@begin{DescribeCode} |
| 4169 |
|
| 4170 |
@begin{Example} |
| 4171 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4172 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Is_Sorted (Container : List) @key{return} Boolean;]} |
| 4173 |
@end{Example} |
| 4174 |
|
| 4175 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4176 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns True if the elements are |
| 4177 |
sorted smallest first as determined by the generic formal "<" operator; |
| 4178 |
otherwise, Is_Sorted returns False. Any exception raised during evaluation of |
| 4179 |
"<" is propagated.]} |
| 4180 |
|
| 4181 |
@begin{Example} |
| 4182 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4183 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Sort (Container : @key{in out} List);]} |
| 4184 |
@end{Example} |
| 4185 |
|
| 4186 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4187 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Reorders the nodes of Container |
| 4188 |
such that the elements are sorted smallest first as determined by the generic |
| 4189 |
formal "<" operator provided. The sort is stable. Any exception raised during |
| 4190 |
evaluation of "<" is propagated.]} |
| 4191 |
|
| 4192 |
@begin{Ramification} |
| 4193 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4194 |
@ChgAdded{Version=[2],Text=[Unlike array sorts, we do require stable sorts |
| 4195 |
here. That's because algorithms in the merge sort family (as described by |
| 4196 |
Knuth) can be both fast and stable. Such sorts use the extra memory as |
| 4197 |
offered by the links to provide better performance.]} |
| 4198 |
|
| 4199 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4200 |
@ChgAdded{Version=[2],Text=[Note that list sorts never copy elements; it is |
| 4201 |
the nodes, not the elements, that are reordered.]} |
| 4202 |
@end{Ramification} |
| 4203 |
|
| 4204 |
@begin{Example} |
| 4205 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4206 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Merge (Target : @key{in out} List; |
| 4207 |
Source : @key{in out} List);]} |
| 4208 |
@end{Example} |
| 4209 |
|
| 4210 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4211 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1]} |
| 4212 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[If Source is |
| 4213 |
empty, then Merge does nothing. If Source and Target are the same nonempty |
| 4214 |
container object, then Program_Error is propagated. Otherwise, ],Old=[]}Merge |
| 4215 |
removes elements from Source |
| 4216 |
and inserts them into Target; afterwards, |
| 4217 |
Target contains the union of the elements that were initially |
| 4218 |
in Source and Target; Source is left empty. |
| 4219 |
If Target and Source are initially sorted smallest first, then Target is |
| 4220 |
ordered smallest first as determined by the generic formal "<" operator; |
| 4221 |
otherwise, the order of elements in Target is unspecified. |
| 4222 |
Any exception raised during evaluation of "<" is propagated.]} |
| 4223 |
|
| 4224 |
@begin{Ramification} |
| 4225 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4226 |
@ChgAdded{Version=[2],Text=[It is a bounded error if either of the lists is |
| 4227 |
unsorted, see below. The bounded error can be recovered by sorting Target |
| 4228 |
after the merge call, or the lists can be pretested with Is_Sorted.]} |
| 4229 |
@end{Ramification} |
| 4230 |
|
| 4231 |
@end{DescribeCode} |
| 4232 |
|
| 4233 |
@end{StaticSem} |
| 4234 |
|
| 4235 |
@begin{Bounded} |
| 4236 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4237 |
@ChgAdded{Version=[2],Text=[@PDefn2{Term=(bounded error),Sec=(cause)} |
| 4238 |
Calling Merge in an instance of Generic_Sorting |
| 4239 |
with either Source or Target not ordered smallest first using the provided |
| 4240 |
generic formal "<" operator is a bounded error. Either Program_Error is raised |
| 4241 |
after Target is updated as described for Merge, or the operation works as |
| 4242 |
defined.]} |
| 4243 |
|
| 4244 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0022-1],ARef=[AI05-0248-1]} |
| 4245 |
@ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)} |
| 4246 |
It is a bounded error for the actual function |
| 4247 |
associated with a generic formal subprogram, when called as part of an |
| 4248 |
operation of this package, to tamper with elements of any List parameter of |
| 4249 |
the operation. Either Program_Error is raised, or the operation works as |
| 4250 |
defined on the value of the List either prior to, or subsequent to, some or |
| 4251 |
all of the modifications to the List.]} |
| 4252 |
|
| 4253 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0027-1]} |
| 4254 |
@ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)} |
| 4255 |
It is a bounded error to call any subprogram |
| 4256 |
declared in the visible part of Containers.Doubly_Linked_Lists |
| 4257 |
when the associated container has been finalized. If the operation takes |
| 4258 |
Container as an @key[in out] parameter, then it raises Constraint_Error or |
| 4259 |
Program_Error. Otherwise, the operation either proceeds as it would |
| 4260 |
for an empty container, or it raises Constraint_Error or Program_Error.]} |
| 4261 |
@end{Bounded} |
| 4262 |
|
| 4263 |
@begin{Erron} |
| 4264 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4265 |
@ChgAdded{Version=[2],Type=[Leading],Text=[A Cursor value is |
| 4266 |
@i<invalid> if any of the following have occurred since it |
| 4267 |
was created:@Defn2{Term=[invalid cursor],Sec=[of a list container]} |
| 4268 |
@PDefn2{Term=[cursor],Sec=[invalid]}]} |
| 4269 |
|
| 4270 |
@begin{Itemize} |
| 4271 |
|
| 4272 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4273 |
@ChgAdded{Version=[2],Text=[The list that contains the element it designates |
| 4274 |
has been finalized;]} |
| 4275 |
|
| 4276 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0160-1]} |
| 4277 |
@ChgAdded{Version=[3],Text=[The list that contains the element it designates |
| 4278 |
has been used as the Target of a call to Assign, or as the target of an |
| 4279 |
@nt{assignment_statement};]} |
| 4280 |
|
| 4281 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4282 |
@ChgAdded{Version=[2],Text=[@Redundant[The list that contains the element it |
| 4283 |
designates has been used as the Source or Target of a call to Move;] or]} |
| 4284 |
@begin{TheProof} |
| 4285 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 4286 |
@ChgAdded{Version=[3],Text=[Move has been reworded in terms of Assign and |
| 4287 |
Clear, which are covered by other bullets, so this text is redundant.]} |
| 4288 |
@end{TheProof} |
| 4289 |
|
| 4290 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4291 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0160-1],ARef=[AI05-0262-1]} |
| 4292 |
@ChgAdded{Version=[2],Text=[The element it designates has been |
| 4293 |
@Chg{Version=[3],New=[removed from the list that previously contained the |
| 4294 |
element],Old=[deleted]}.]} |
| 4295 |
@begin{Honest} |
| 4296 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]} |
| 4297 |
@ChgAdded{Version=[3],Text=[The cursor modified by the four parameter Splice |
| 4298 |
is not invalid, even though the element it designates has been removed from |
| 4299 |
the source list, because that cursor has been modified to designate that |
| 4300 |
element in the target list @en the cursor no longer designates an element |
| 4301 |
in the source list.]} |
| 4302 |
@end{Honest} |
| 4303 |
@begin{Ramification} |
| 4304 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]} |
| 4305 |
@ChgAdded{Version=[3],Text=[This can happen directly via calls to Delete, |
| 4306 |
Delete_Last, Clear, Splice with a Source parameter, and Merge; and indirectly |
| 4307 |
via calls to Delete_First, Assign, and Move.]} |
| 4308 |
@end{Ramification} |
| 4309 |
|
| 4310 |
@end{Itemize} |
| 4311 |
|
| 4312 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4313 |
@ChgAdded{Version=[2],Text=[The result of "=" or Has_Element is unspecified |
| 4314 |
if it is called with an invalid |
| 4315 |
cursor parameter. Execution is erroneous if any other subprogram declared in |
| 4316 |
Containers.Doubly_Linked_Lists is called with an invalid cursor parameter. |
| 4317 |
@PDefn{unspecified}@PDefn2{Term=(erroneous execution),Sec=(cause)}]} |
| 4318 |
|
| 4319 |
@begin{Discussion} |
| 4320 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4321 |
@ChgAdded{Version=[2],Text=[The list above is intended to be exhaustive. In |
| 4322 |
other cases, a cursor value continues to designate its original element. For |
| 4323 |
instance, cursor values survive the insertion and deletion of other nodes.]} |
| 4324 |
|
| 4325 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4326 |
@ChgAdded{Version=[2],Text=[While it is possible to check for these cases, in |
| 4327 |
many cases the overhead necessary to make the check is substantial in time or |
| 4328 |
space. Implementations are encouraged to check for as many of these cases as |
| 4329 |
possible and raise Program_Error if detected.]} |
| 4330 |
@end{Discussion} |
| 4331 |
|
| 4332 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 4333 |
@ChgAdded{Version=[3],Text=[Execution is erroneous if the list associated with |
| 4334 |
the result of a call to Reference or Constant_Reference is finalized before the |
| 4335 |
result object returned by the call to Reference or Constant_Reference is |
| 4336 |
finalized.]} |
| 4337 |
@begin{Reason} |
| 4338 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 4339 |
@ChgAdded{Version=[3],Text=[Each object of Reference_Type and |
| 4340 |
Constant_Reference_Type probably contains some reference to the originating |
| 4341 |
container. If that container is prematurely finalized (which is only possible |
| 4342 |
via Unchecked_Deallocation, as accessibility checks prevent passing a |
| 4343 |
container to Reference that will not live as long as the result), the |
| 4344 |
finalization of the object of Reference_Type will try to access a nonexistent |
| 4345 |
object. This is a normal case of a dangling pointer created by |
| 4346 |
Unchecked_Deallocation; we have to explicitly mention it here as the pointer |
| 4347 |
in question is not visible in the specification of the type. (This is the same |
| 4348 |
reason we have to say this for invalid cursors.)]} |
| 4349 |
@end{Reason} |
| 4350 |
@end{Erron} |
| 4351 |
|
| 4352 |
@begin{ImplReq} |
| 4353 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4354 |
@ChgAdded{Version=[2],Text=[No storage associated with a doubly-linked List |
| 4355 |
object shall be lost upon assignment or scope exit.]} |
| 4356 |
|
| 4357 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4358 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]} |
| 4359 |
@ChgAdded{Version=[2],Text=[The execution of an @nt{assignment_statement} for |
| 4360 |
a list shall have the effect of copying the elements from the source list |
| 4361 |
object to the target list object@Chg{Version=[3],New=[ and changing the length |
| 4362 |
of the target object to that of the source object],Old=[]}.]} |
| 4363 |
|
| 4364 |
@begin{ImplNote} |
| 4365 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4366 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0298-1]} |
| 4367 |
@ChgAdded{Version=[2],Text=[An assignment of a List is a @lquotes@;deep@rquotes |
| 4368 |
copy; that is the elements are copied as well as the data structures. |
| 4369 |
We say @lquotes@;effect of@rquotes in order to allow the implementation to |
| 4370 |
avoid copying elements immediately if it wishes. For instance, an |
| 4371 |
implementation that avoided copying until one of the containers is modified |
| 4372 |
would be allowed.@Chg{Version=[3],New=[ (Note that this implementation would |
| 4373 |
require care, see @RefSecNum{The Generic Package Containers.Vectors} for more.)],Old=[]}]} |
| 4374 |
@end{ImplNote} |
| 4375 |
@end{ImplReq} |
| 4376 |
|
| 4377 |
@begin{ImplAdvice} |
| 4378 |
|
| 4379 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4380 |
@ChgAdded{Version=[2],Text=[Containers.Doubly_Linked_Lists should be |
| 4381 |
implemented similarly to a linked list. In particular, if @i<N> is the length |
| 4382 |
of a list, then the worst-case time complexity of Element, Insert with Count=1, |
| 4383 |
and Delete with Count=1 should be @i{O}(log @i<N>).]} |
| 4384 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 4385 |
Text=[The worst-case time complexity of Element, Insert with Count=1, and |
| 4386 |
Delete with Count=1 for Containers.Doubly_Linked_Lists should be |
| 4387 |
@i{O}(log @i<N>).]}]} |
| 4388 |
|
| 4389 |
@begin{Reason} |
| 4390 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4391 |
@ChgAdded{Version=[2],Text=[We do not mean to overly constrain implementation |
| 4392 |
strategies here. However, it is important for portability that the |
| 4393 |
performance of large containers has roughly the same factors on different |
| 4394 |
implementations. If a program is moved to an implementation that takes |
| 4395 |
@i{O}(@i<N>) time to access elements, that program could be unusable when the |
| 4396 |
lists are large. We allow @i{O}(log @i<N>) access because the proportionality |
| 4397 |
constant and caching effects are likely to be larger than the log factor, and |
| 4398 |
we don't want to discourage innovative implementations.]} |
| 4399 |
@end{Reason} |
| 4400 |
|
| 4401 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4402 |
@ChgAdded{Version=[2],Text=[The worst-case time complexity of a call on |
| 4403 |
procedure Sort of an |
| 4404 |
instance of Containers.Doubly_Linked_Lists.Generic_Sorting should be |
| 4405 |
@i{O}(@i<N>**2), and the average time complexity should be better than @i{O}(@i<N>**2).]} |
| 4406 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 4407 |
Text=[A call on procedure Sort of an |
| 4408 |
instance of Containers.Doubly_Linked_Lists.Generic_Sorting |
| 4409 |
should have an average time complexity better than @i{O}(@i{N}**2) and |
| 4410 |
worst case no worse than @i{O}(@i{N}**2).]}]} |
| 4411 |
|
| 4412 |
@begin{Ramification} |
| 4413 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4414 |
@ChgAdded{Version=[2],Text=[In other words, we're requiring the use of a |
| 4415 |
better than @i{O}(@i{N}**2) sorting algorithm, such as Quicksort. No bubble sorts |
| 4416 |
allowed!]} |
| 4417 |
@end{Ramification} |
| 4418 |
|
| 4419 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4420 |
@ChgAdded{Version=[2],Text=[Move should not copy elements, and should minimize |
| 4421 |
copying of internal data structures.]} |
| 4422 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 4423 |
Text=[Containers.Doubly_Linked_Lists.Move should not copy elements, and should |
| 4424 |
minimize copying of internal data structures.]}]} |
| 4425 |
|
| 4426 |
@begin{ImplNote} |
| 4427 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4428 |
@ChgAdded{Version=[2],Text=[Usually that can be accomplished simply by |
| 4429 |
moving the pointer(s) to the internal data structures from the Source |
| 4430 |
container to the Target container.]} |
| 4431 |
@end{ImplNote} |
| 4432 |
|
| 4433 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4434 |
@ChgAdded{Version=[2],Text=[If an exception is propagated from a list |
| 4435 |
operation, no storage should be lost, nor any elements removed from a list |
| 4436 |
unless specified by the operation.]} |
| 4437 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 4438 |
Text=[If an exception is propagated from a list |
| 4439 |
operation, no storage should be lost, nor any elements removed from a list |
| 4440 |
unless specified by the operation.]}]} |
| 4441 |
|
| 4442 |
@begin{Reason} |
| 4443 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4444 |
@ChgAdded{Version=[2],Text=[This is important so that programs can recover |
| 4445 |
from errors. But we don't want to require heroic efforts, so we just require |
| 4446 |
documentation of cases where this can't be accomplished.]} |
| 4447 |
@end{Reason} |
| 4448 |
|
| 4449 |
@end{ImplAdvice} |
| 4450 |
|
| 4451 |
@begin{Notes} |
| 4452 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4453 |
@ChgAdded{Version=[2],Text=[Sorting a list never copies elements, and is a |
| 4454 |
stable sort (equal elements remain in the original order). This is different |
| 4455 |
than sorting an array or vector, which may need to copy elements, and is |
| 4456 |
probably not a stable sort.]} |
| 4457 |
@end{Notes} |
| 4458 |
|
| 4459 |
@begin{Extend95} |
| 4460 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4461 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 4462 |
The generic package Containers.Doubly_Linked_Lists is new.]} |
| 4463 |
@end{Extend95} |
| 4464 |
|
| 4465 |
@begin{Inconsistent2005} |
| 4466 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0248-1],ARef=[AI05-0257-1]} |
| 4467 |
@ChgAdded{Version=[3],Text=[@Defn{inconsistencies with Ada 2005}@b<Correction:> |
| 4468 |
The Insert versions that return a Position parameter are now defined to |
| 4469 |
return Position = Before if Count = 0. This was unspecified for Ada 2005; |
| 4470 |
so this will only be inconsistent if an implementation did something else and |
| 4471 |
a program depended on that something else @em this should be very rare.]} |
| 4472 |
@end{Inconsistent2005} |
| 4473 |
|
| 4474 |
@begin{Incompatible2005} |
| 4475 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 4476 |
@ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Subprograms Assign and Copy |
| 4477 |
are added to Containers.Doubly_Linked_Lists. If an instance of Containers.Doubly_Linked_Lists |
| 4478 |
is referenced in a @nt{use_clause}, and an entity @i<E> with the same |
| 4479 |
@nt{defining_identifier} as a new entity in Containers.Doubly_Linked_Lists is |
| 4480 |
defined in a package that is also referenced in a @nt{use_clause}, the |
| 4481 |
entity @i<E> may no longer be use-visible, resulting in errors. This should |
| 4482 |
be rare and is easily fixed if it does occur.]} |
| 4483 |
@end{Incompatible2005} |
| 4484 |
|
| 4485 |
@begin{Extend2005} |
| 4486 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]} |
| 4487 |
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005} |
| 4488 |
Added iterator, reference, and indexing support to make list containers more |
| 4489 |
convenient to use.]} |
| 4490 |
@end{Extend2005} |
| 4491 |
|
| 4492 |
@begin{DiffWord2005} |
| 4493 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 4494 |
@ChgAdded{Version=[3],Text=[Generalized the definition |
| 4495 |
of Move. Specified which elements are read/written by stream attributes.]} |
| 4496 |
|
| 4497 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0022-1]} |
| 4498 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName |
| 4499 |
to cover tampering by generic actual subprograms.]} |
| 4500 |
|
| 4501 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0027-1]} |
| 4502 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName |
| 4503 |
to cover access to finalized list containers.]} |
| 4504 |
|
| 4505 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]} |
| 4506 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Redefined "<" actuals |
| 4507 |
to require a strict weak ordering; the old definition allowed |
| 4508 |
indeterminant comparisons that would not have worked in a container.]} |
| 4509 |
|
| 4510 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0084-1]} |
| 4511 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a pragma |
| 4512 |
Remote_Types so that containers can be used in distributed programs.]} |
| 4513 |
|
| 4514 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]} |
| 4515 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Revised the definition |
| 4516 |
of invalid cursors to cover missing (and new) cases.]} |
| 4517 |
|
| 4518 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0257-1]} |
| 4519 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added missing wording to describe |
| 4520 |
the Position after Inserting 0 elements.]} |
| 4521 |
|
| 4522 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0265-1]} |
| 4523 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Defined when a container |
| 4524 |
prohibits tampering in order to more clearly define where the check is |
| 4525 |
made and the exception raised.]} |
| 4526 |
@end{DiffWord2005} |
| 4527 |
|
| 4528 |
@begin{DiffWord2012} |
| 4529 |
@ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0110-1]} |
| 4530 |
@ChgAdded{Version=[4],Text=[@b<Corrigendum:> Clarified that tampering checks |
| 4531 |
precede all other checks made by a subprogram (but come after those associated |
| 4532 |
with the call).]} |
| 4533 |
@end{DiffWord2012} |
| 4534 |
|
| 4535 |
@LabeledAddedSubclause{Version=[2],Name=[Maps]} |
| 4536 |
|
| 4537 |
@begin{Intro} |
| 4538 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4539 |
@ChgAdded{Version=[2],Text=[The language-defined generic packages |
| 4540 |
Containers.Hashed_Maps and Containers.Ordered_Maps provide private types Map |
| 4541 |
and Cursor, and a set of operations for each type. A map container allows an |
| 4542 |
arbitrary type to be used as a key to find the element associated with that |
| 4543 |
key. A hashed map uses a hash function to organize the keys, while an ordered |
| 4544 |
map orders the keys per a specified relation. |
| 4545 |
@Defn{map container}@Defn2{Term=[container],Sec=[map]}]} |
| 4546 |
|
| 4547 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4548 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]} |
| 4549 |
@ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[subclause],Old=[section]} |
| 4550 |
describes the declarations that are |
| 4551 |
common to both kinds of maps. See @RefSecNum{The Generic Package Containers.Hashed_Maps} |
| 4552 |
for a description of the semantics specific to |
| 4553 |
Containers.Hashed_Maps and @RefSecNum{The Generic Package Containers.Ordered_Maps} for |
| 4554 |
a description of the semantics specific to Containers.Ordered_Maps.]} |
| 4555 |
@end{Intro} |
| 4556 |
|
| 4557 |
@begin{StaticSem} |
| 4558 |
|
| 4559 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4560 |
@ChgAdded{Version=[2],Text=[The actual function for the generic formal function |
| 4561 |
"=" on Element_Type values is expected to define a reflexive and symmetric |
| 4562 |
relationship and return the same result value each time it is called with a |
| 4563 |
particular pair of values. If it behaves in some other manner, the function |
| 4564 |
"=" on map values returns an unspecified value. The |
| 4565 |
exact arguments and number of calls of this generic formal function by the |
| 4566 |
function "=" on map values are unspecified.@PDefn{unspecified}]} |
| 4567 |
|
| 4568 |
@begin{Ramification} |
| 4569 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4570 |
@ChgAdded{Version=[2],Text=[If the actual function for "=" is not symmetric |
| 4571 |
and consistent, the result returned by "=" for Map objects cannot be predicted. |
| 4572 |
The implementation is not required to protect |
| 4573 |
against "=" raising an exception, or returning random results, or any |
| 4574 |
other @lquotes@;bad@rquotes behavior. And it can call "=" in whatever |
| 4575 |
manner makes sense. But note that only the result of "=" for Map objects |
| 4576 |
is unspecified; other subprograms are not allowed to break if "=" |
| 4577 |
is bad (they aren't expected to use "=").]} |
| 4578 |
@end{Ramification} |
| 4579 |
|
| 4580 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4581 |
@ChgAdded{Version=[2],Text=[The type Map is used to represent maps. The type |
| 4582 |
Map needs finalization@PDefn2{Term=<needs finalization>,Sec=<language-defined type>} |
| 4583 |
(see @RefSecNum{Assignment and Finalization}).]} |
| 4584 |
|
| 4585 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4586 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[node],Sec=[of a map]}A map contains |
| 4587 |
pairs of keys and elements, called @i{nodes}. Map cursors designate nodes, but |
| 4588 |
also can be thought of as designating an element (the element contained in the |
| 4589 |
node) for consistency with the other containers. There exists an equivalence |
| 4590 |
relation on keys, whose definition is different for hashed maps and ordered |
| 4591 |
maps. A map never contains two or more nodes with equivalent keys. The |
| 4592 |
@i{length} of a map is the number of nodes it |
| 4593 |
contains.@Defn2{Term=[length],Sec=[of a map]}]} |
| 4594 |
|
| 4595 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4596 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[first node],Sec=[of a map]} |
| 4597 |
@Defn2{Term=[last node],Sec=[of a map]} |
| 4598 |
@Defn2{Term=[successor node],Sec=[of a map]}Each nonempty map has two |
| 4599 |
particular nodes called the @i{first node} and the @i{last node} (which may be |
| 4600 |
the same). Each node except for the last node has a @i{successor node}. If |
| 4601 |
there are no other intervening operations, starting with the first node and |
| 4602 |
repeatedly going to the successor node will visit each node in the map exactly |
| 4603 |
once until the last node is reached. The exact definition of these terms is |
| 4604 |
different for hashed maps and ordered maps.]} |
| 4605 |
|
| 4606 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4607 |
@ChgAdded{Version=[2],Text=[@Redundant[Some operations of these generic packages |
| 4608 |
have access-to-subprogram parameters. To ensure such operations are |
| 4609 |
well-defined, they guard against certain actions by the designated |
| 4610 |
subprogram. In particular, some operations check for @lquotes@;tampering with |
| 4611 |
cursors@rquotes of a container because they depend on the set of elements of |
| 4612 |
the container remaining constant, and others check for @lquotes@;tampering with |
| 4613 |
elements@rquotes of a container because they depend on elements of the |
| 4614 |
container not being replaced.]]} |
| 4615 |
|
| 4616 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4617 |
@ChgAdded{Version=[2],Type=[Leading],Text=[ |
| 4618 |
@Defn2{Term=[tamper with cursors],Sec=[of a map]} |
| 4619 |
A subprogram is said to @i{tamper with cursors} of a map object @i<M> |
| 4620 |
if:]} |
| 4621 |
|
| 4622 |
@begin{Itemize} |
| 4623 |
|
| 4624 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4625 |
@ChgAdded{Version=[2],Text=[it inserts or deletes elements of @i<M>, that is, |
| 4626 |
it calls the Insert, Include, Clear, Delete, or Exclude procedures with @i<M> |
| 4627 |
as a parameter; or]} |
| 4628 |
|
| 4629 |
@begin{Honest} |
| 4630 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4631 |
@ChgAdded{Version=[2],Text=[Operations which are defined to be equivalent to |
| 4632 |
a call on one of these operations also are included. Similarly, operations |
| 4633 |
which call one of these as part of their definition are included.]} |
| 4634 |
@end{Honest} |
| 4635 |
|
| 4636 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4637 |
@ChgAdded{Version=[2],Text=[it finalizes @i<M>; or]} |
| 4638 |
|
| 4639 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 4640 |
@ChgAdded{Version=[3],Text=[it calls the Assign procedure with @i<M> as the Target parameter; or]} |
| 4641 |
|
| 4642 |
@begin{Ramification} |
| 4643 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 4644 |
@ChgAdded{Version=[3],Text=[We don't need to explicitly mention |
| 4645 |
@nt{assignment_statement}, because that finalizes the target object |
| 4646 |
as part of the operation, and finalization of an object is already defined |
| 4647 |
as tampering with cursors.]} |
| 4648 |
@end{Ramification} |
| 4649 |
|
| 4650 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4651 |
@ChgAdded{Version=[2],Text=[it calls the Move procedure with @i<M> as a |
| 4652 |
parameter; or]} |
| 4653 |
|
| 4654 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4655 |
@ChgAdded{Version=[2],Text=[it calls one of the operations defined to tamper |
| 4656 |
with the cursors of @i<M>.]} |
| 4657 |
|
| 4658 |
@end{Itemize} |
| 4659 |
|
| 4660 |
@begin{Ramification} |
| 4661 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4662 |
@ChgAdded{Version=[2],Text=[Replace only modifies a key and element rather |
| 4663 |
than rehashing, so it does not tamper with cursors.]} |
| 4664 |
@end{Ramification} |
| 4665 |
|
| 4666 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4667 |
@ChgAdded{Version=[2],Type=[Leading],Text=[ |
| 4668 |
@Defn2{Term=[tamper with elements],Sec=[of a map]} |
| 4669 |
A subprogram is said to @i{tamper with elements} of a map object @i<M> if:]} |
| 4670 |
|
| 4671 |
@begin{Itemize} |
| 4672 |
|
| 4673 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4674 |
@ChgAdded{Version=[2],Text=[it tampers with cursors of @i<M>; or]} |
| 4675 |
|
| 4676 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4677 |
@ChgAdded{Version=[2],Text=[it replaces one or more elements of @i<M>, that is, |
| 4678 |
it calls the Replace or Replace_Element procedures with @i<M> |
| 4679 |
as a parameter.]} |
| 4680 |
|
| 4681 |
@begin{Reason} |
| 4682 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4683 |
@ChgAdded{Version=[2],Text=[Complete replacement of an element can cause its |
| 4684 |
memory to be deallocated while another operation is holding onto a reference |
| 4685 |
to it. That can't be allowed. However, a simple modification of (part of) an |
| 4686 |
element is not a problem, so Update_Element does not cause a problem.]} |
| 4687 |
@end{Reason} |
| 4688 |
|
| 4689 |
@end{Itemize} |
| 4690 |
|
| 4691 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0265-1]} |
| 4692 |
@ChgRef{Version=[4],Kind=[RevisedAdded],ARef=[AI12-0110-1]} |
| 4693 |
@ChgAdded{Version=[3],Text=[@Defn2{Term=[prohibited],Sec=[tampering with a map]} |
| 4694 |
@Defn2{Term=[tampering],Sec=[prohibited for a map]} |
| 4695 |
When tampering with cursors is @i<prohibited> for a particular map object |
| 4696 |
@i<M>, Program_Error is propagated by a call of any language-defined subprogram |
| 4697 |
that is defined to tamper with the cursors of @i<M>, leaving @i<M> unmodified. |
| 4698 |
Similarly, when tampering with elements is @i<prohibited> for a particular map |
| 4699 |
object @i<M>, Program_Error is propagated by a call of any language-defined |
| 4700 |
subprogram that is defined to tamper with the elements of @i<M> @Redundant[(or |
| 4701 |
tamper with the cursors of @i<M>)], leaving @i<M> |
| 4702 |
unmodified.@Chg{Version=[4],New=[ These checks are made before any other |
| 4703 |
defined behavior of the body of the language-defined subprogram.],Old=[]}]} |
| 4704 |
@begin{TheProof} |
| 4705 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 4706 |
@ChgAdded{Version=[3],Text=[Tampering with elements includes tampering with |
| 4707 |
cursors, so we mention it only from completeness in the second sentence.]} |
| 4708 |
@end{TheProof} |
| 4709 |
|
| 4710 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4711 |
@ChgAdded{Version=[2],Text=[Empty_Map represents the empty Map object. It has a |
| 4712 |
length of 0. If an object of type Map is not otherwise initialized, it is |
| 4713 |
initialized to the same value as Empty_Map.]} |
| 4714 |
|
| 4715 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4716 |
@ChgAdded{Version=[2],Text=[No_Element represents a cursor that designates no |
| 4717 |
node. If an object of type Cursor is not otherwise initialized, it is |
| 4718 |
initialized to the same value as No_Element.]} |
| 4719 |
|
| 4720 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4721 |
@ChgAdded{Version=[2],Text=[The predefined "=" operator for type Cursor returns |
| 4722 |
True if both cursors are No_Element, or designate the same element in the same |
| 4723 |
container.]} |
| 4724 |
|
| 4725 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4726 |
@ChgAdded{Version=[2],Text=[Execution of the default implementation of the |
| 4727 |
Input, Output, Read, or Write attribute of type Cursor raises Program_Error.]} |
| 4728 |
|
| 4729 |
@begin{Reason} |
| 4730 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4731 |
@ChgAdded{Version=[2],Text=[A cursor will probably be implemented in terms |
| 4732 |
of one or more access values, and the effects of streaming access values is |
| 4733 |
unspecified. Rather than letting the user stream junk by accident, we mandate |
| 4734 |
that streaming of cursors raise Program_Error by default. The attributes |
| 4735 |
can always be specified if there is a need to support streaming.]} |
| 4736 |
@end{Reason} |
| 4737 |
|
| 4738 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]} |
| 4739 |
@ChgAdded{Version=[3],Text=[Map'Write for a Map object @i<M> writes |
| 4740 |
Length(@i<M>) elements of the map to the stream. It also may write |
| 4741 |
additional information about the map.]} |
| 4742 |
|
| 4743 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]} |
| 4744 |
@ChgAdded{Version=[3],Text=[Map'Read reads the representation of a map |
| 4745 |
from the stream, and assigns to @i<Item> a map with the same length and |
| 4746 |
elements as was written by Map'Write.]} |
| 4747 |
|
| 4748 |
@begin{Ramification} |
| 4749 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 4750 |
@ChgAdded{Version=[3],Text=[Streaming more elements than the container |
| 4751 |
length is wrong. For implementation implications of this rule, see the Implementation Note in |
| 4752 |
@RefSecNum{The Generic Package Containers.Vectors}.]} |
| 4753 |
@end{Ramification} |
| 4754 |
|
| 4755 |
|
| 4756 |
@begin{DescribeCode} |
| 4757 |
|
| 4758 |
@begin{Example} |
| 4759 |
@ChgRef{Version=[3],Kind=[Added]} |
| 4760 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean;]} |
| 4761 |
@end{Example} |
| 4762 |
|
| 4763 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 4764 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns True if Position designates |
| 4765 |
an element, and returns False otherwise.]} |
| 4766 |
|
| 4767 |
@begin{Honest} |
| 4768 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1],ARef=[AI05-0212-1]} |
| 4769 |
@ChgAdded{Version=[3],Text=[This function might not detect cursors that |
| 4770 |
designate deleted elements; such cursors are invalid (see below) and the |
| 4771 |
result of calling Has_Element with an invalid cursor is unspecified (but |
| 4772 |
not erroneous).]} |
| 4773 |
@end{Honest} |
| 4774 |
|
| 4775 |
@begin{Example} |
| 4776 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4777 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "=" (Left, Right : Map) @key{return} Boolean;]} |
| 4778 |
@end{Example} |
| 4779 |
|
| 4780 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4781 |
@ChgAdded{Version=[2],Type=[Leading],Text=[If Left and Right denote the same |
| 4782 |
map object, then the function returns True. If Left and Right have different |
| 4783 |
lengths, then the function returns False. Otherwise, for each key @i<K> in |
| 4784 |
Left, the function returns False if:]} |
| 4785 |
|
| 4786 |
@begin{Itemize} |
| 4787 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4788 |
@ChgAdded{Version=[2],Text=[a key equivalent to @i<K> is not present |
| 4789 |
in Right; or]} |
| 4790 |
|
| 4791 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4792 |
@ChgAdded{Version=[2],Text=[the element associated with @i<K> |
| 4793 |
in Left is not equal to the element associated with @i<K> in Right (using the |
| 4794 |
generic formal equality operator for elements).]} |
| 4795 |
@end{Itemize} |
| 4796 |
|
| 4797 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4798 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If the function has not returned a |
| 4799 |
result after checking all of the keys, it returns True. Any exception raised |
| 4800 |
during evaluation of key equivalence or element equality is propagated.]} |
| 4801 |
@begin{ImplNote} |
| 4802 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4803 |
@ChgAdded{Version=[2],Text=[This wording describes the canonical semantics. |
| 4804 |
However, the order and number of calls on the formal equality function is |
| 4805 |
unspecified for all of the operations that use it in this package, so an |
| 4806 |
implementation can call it as many or as few times as it needs to get the |
| 4807 |
correct answer. Specifically, there is no requirement to call the formal |
| 4808 |
equality additional times once the answer has been determined.]} |
| 4809 |
@end{ImplNote} |
| 4810 |
|
| 4811 |
@begin{Example} |
| 4812 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4813 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Length (Container : Map) @key{return} Count_Type;]} |
| 4814 |
@end{Example} |
| 4815 |
|
| 4816 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4817 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the number of nodes in Container.]} |
| 4818 |
|
| 4819 |
@begin{Example} |
| 4820 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4821 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Is_Empty (Container : Map) @key{return} Boolean;]} |
| 4822 |
@end{Example} |
| 4823 |
|
| 4824 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4825 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Length (Container) = 0.]} |
| 4826 |
|
| 4827 |
@begin{Example} |
| 4828 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4829 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Clear (Container : @key{in out} Map);]} |
| 4830 |
@end{Example} |
| 4831 |
|
| 4832 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4833 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Removes all the nodes from Container.]} |
| 4834 |
|
| 4835 |
@begin{Example} |
| 4836 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4837 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Key (Position : Cursor) @key{return} Key_Type;]} |
| 4838 |
@end{Example} |
| 4839 |
|
| 4840 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4841 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 4842 |
Constraint_Error is propagated. Otherwise, Key returns the key component of the |
| 4843 |
node designated by Position.]} |
| 4844 |
|
| 4845 |
@begin{Example} |
| 4846 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4847 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Element (Position : Cursor) @key{return} Element_Type;]} |
| 4848 |
@end{Example} |
| 4849 |
|
| 4850 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4851 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 4852 |
Constraint_Error is propagated. Otherwise, Element returns the element |
| 4853 |
component of the node designated by Position.]} |
| 4854 |
|
| 4855 |
@begin{Example} |
| 4856 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4857 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace_Element (Container : @key{in out} Map; |
| 4858 |
Position : @key{in} Cursor; |
| 4859 |
New_Item : @key{in} Element_Type);]} |
| 4860 |
@end{Example} |
| 4861 |
|
| 4862 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4863 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 4864 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, |
| 4865 |
then Constraint_Error is propagated; if Position does not designate an element |
| 4866 |
in Container, then Program_Error is propagated. |
| 4867 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} Replace_Element |
| 4868 |
assigns New_Item to the element of the node designated by Position.]} |
| 4869 |
|
| 4870 |
@begin{Example} |
| 4871 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4872 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Query_Element |
| 4873 |
(Position : @key{in} Cursor; |
| 4874 |
Process : @key{not null access procedure} (Key : @key{in} Key_Type; |
| 4875 |
Element : @key{in} Element_Type));]} |
| 4876 |
@end{Example} |
| 4877 |
|
| 4878 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4879 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1],ARef=[AI05-0265-1]} |
| 4880 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 4881 |
Constraint_Error is propagated. Otherwise, Query_Element calls |
| 4882 |
Process.@key{all} with the key and element from the node designated by Position |
| 4883 |
as the arguments. |
| 4884 |
@Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 4885 |
is propagated if Process.@key{all} tampers]} |
| 4886 |
with the elements of @Chg{Version=[3],New=[the map that contains the |
| 4887 |
element designated by Position is prohibited during the |
| 4888 |
execution of the call on Process.@key{all}],Old=[Container]}. Any exception raised by |
| 4889 |
Process.@key{all} is propagated.]} |
| 4890 |
|
| 4891 |
@begin{Example} |
| 4892 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4893 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Update_Element |
| 4894 |
(Container : @key{in out} Map; |
| 4895 |
Position : @key{in} Cursor; |
| 4896 |
Process : @key{not null access procedure} (Key : @key{in} Key_Type; |
| 4897 |
Element : @key{in out} Element_Type));]} |
| 4898 |
@end{Example} |
| 4899 |
|
| 4900 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 4901 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1],ARef=[AI05-0265-1]} |
| 4902 |
@ChgAdded{Version=[2],Text=[If Position equals No_Element, then |
| 4903 |
Constraint_Error is propagated; if Position does not designate an element in |
| 4904 |
Container, then Program_Error is propagated. |
| 4905 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} Update_Element calls |
| 4906 |
Process.@key{all} with the key and element from the node designated by Position |
| 4907 |
as the arguments. @Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 4908 |
is propagated if Process.@key{all} tampers]} |
| 4909 |
with the elements of Container@Chg{Version=[3],New=[ is prohibited during the |
| 4910 |
execution of the call on Process.@key{all}],Old=[]}. Any exception raised by |
| 4911 |
Process.@key{all} is propagated.]} |
| 4912 |
|
| 4913 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4914 |
@ChgAdded{Version=[2],Type=[Trailing],Type=[Trailing],Text=[If Element_Type is |
| 4915 |
unconstrained and definite, then the actual Element parameter of Process.@key{all} |
| 4916 |
shall be unconstrained.]} |
| 4917 |
|
| 4918 |
@begin{Ramification} |
| 4919 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 4920 |
@ChgAdded{Version=[2],Text=[This means that the elements cannot be directly |
| 4921 |
allocated from the heap; it must be possible to change the discriminants |
| 4922 |
of the element in place.]} |
| 4923 |
@end{Ramification} |
| 4924 |
|
| 4925 |
@begin{Example} |
| 4926 |
@ChgRef{Version=[3],Kind=[Added]} |
| 4927 |
@ChgAdded{Version=[3],Text=[@key[type] Constant_Reference_Type |
| 4928 |
(Element : @key[not null access constant] Element_Type) @key[is private] |
| 4929 |
@key[with] Implicit_Dereference => Element;]} |
| 4930 |
|
| 4931 |
@ChgRef{Version=[3],Kind=[Added]} |
| 4932 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[type] Reference_Type (Element : @key[not null access] Element_Type) @key[is private] |
| 4933 |
@key[with] Implicit_Dereference => Element;]} |
| 4934 |
@end{Example} |
| 4935 |
|
| 4936 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 4937 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[The types Constant_Reference_Type |
| 4938 |
and Reference_Type need finalization.@PDefn2{Term=<needs finalization>, |
| 4939 |
Sec=<language-defined type>}]} |
| 4940 |
|
| 4941 |
@ChgRef{Version=[3],Kind=[Added]} |
| 4942 |
@ChgAdded{Version=[3],Text=[The default initialization of an object of type |
| 4943 |
Constant_Reference_Type or Reference_Type propagates Program_Error.]} |
| 4944 |
|
| 4945 |
@begin{Reason} |
| 4946 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 4947 |
@ChgAdded{Version=[3],Text=[It is expected that Reference_Type (and |
| 4948 |
Constant_Reference_Type) will be a controlled type, for which finalization |
| 4949 |
will have some action to terminate the tampering check for the associated |
| 4950 |
container. If the object is created by default, however, there is no |
| 4951 |
associated container. Since this is useless, and supporting this case would |
| 4952 |
take extra work, we define it to raise an exception.]} |
| 4953 |
@end{Reason} |
| 4954 |
|
| 4955 |
@begin{Example} |
| 4956 |
@ChgRef{Version=[3],Kind=[Added]} |
| 4957 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] Map; |
| 4958 |
Position : @key[in] Cursor) |
| 4959 |
@key[return] Constant_Reference_Type;]} |
| 4960 |
@end{Example} |
| 4961 |
|
| 4962 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 4963 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 4964 |
Constant_Indexing and Implicit_Dereference aspects) provides a convenient way to |
| 4965 |
gain read access to an individual element of a map given a cursor.]} |
| 4966 |
|
| 4967 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]} |
| 4968 |
@ChgAdded{Version=[3],Text=[If Position equals No_Element, then Constraint_Error |
| 4969 |
is propagated; if Position does not designate an element in Container, then |
| 4970 |
Program_Error is propagated. Otherwise, Constant_Reference returns an object |
| 4971 |
whose discriminant is an access value that designates the element designated by |
| 4972 |
Position. Tampering with the elements of Container is prohibited while the |
| 4973 |
object returned by Constant_Reference exists and has not been finalized.]} |
| 4974 |
|
| 4975 |
@begin{Example} |
| 4976 |
@ChgRef{Version=[3],Kind=[Added]} |
| 4977 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference (Container : @key[aliased in out] Map; |
| 4978 |
Position : @key[in] Cursor) |
| 4979 |
@key[return] Reference_Type;]} |
| 4980 |
@end{Example} |
| 4981 |
|
| 4982 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 4983 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 4984 |
Variable_Indexing and Implicit_Dereference aspects) provides a convenient way to |
| 4985 |
gain read and write access to an individual element of a map given |
| 4986 |
a cursor.]} |
| 4987 |
|
| 4988 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]} |
| 4989 |
@ChgAdded{Version=[3],Text=[If Position equals No_Element, then Constraint_Error |
| 4990 |
is propagated; if Position does not designate an element in Container, then |
| 4991 |
Program_Error is propagated. Otherwise, Reference returns an object whose |
| 4992 |
discriminant is an access value that designates the element designated by |
| 4993 |
Position. Tampering with the elements of Container is prohibited while the |
| 4994 |
object returned by Reference exists and has not been finalized.]} |
| 4995 |
|
| 4996 |
@begin{Example} |
| 4997 |
@ChgRef{Version=[3],Kind=[Added]} |
| 4998 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] Map; |
| 4999 |
Key : @key[in] Key_Type) |
| 5000 |
@key[return] Constant_Reference_Type;]} |
| 5001 |
@end{Example} |
| 5002 |
|
| 5003 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 5004 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 5005 |
Constant_Indexing and Implicit_Dereference aspects) provides a convenient way to |
| 5006 |
gain read access to an individual element of a map given a key value.]} |
| 5007 |
|
| 5008 |
@ChgRef{Version=[3],Kind=[Added]} |
| 5009 |
@ChgAdded{Version=[3],Text=[Equivalent to |
| 5010 |
Constant_Reference (Container, Find (Container, Key)).]} |
| 5011 |
|
| 5012 |
@begin{Example} |
| 5013 |
@ChgRef{Version=[3],Kind=[Added]} |
| 5014 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference (Container : @key[aliased in out] Map; |
| 5015 |
Key : @key[in] Key_Type) |
| 5016 |
@key[return] Reference_Type;]} |
| 5017 |
@end{Example} |
| 5018 |
|
| 5019 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 5020 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 5021 |
Variable_Indexing and Implicit_Dereference aspects) provides a convenient way to |
| 5022 |
gain read and write access to an individual element of a map given |
| 5023 |
a key value.]} |
| 5024 |
|
| 5025 |
@ChgRef{Version=[3],Kind=[Added]} |
| 5026 |
@ChgAdded{Version=[3],Text=[Equivalent to Reference (Container, Find (Container, Key)).]} |
| 5027 |
|
| 5028 |
@begin{Example} |
| 5029 |
@ChgRef{Version=[3],Kind=[Added]} |
| 5030 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key{procedure} Assign (Target : @key{in out} Map; Source : @key{in} Map);]} |
| 5031 |
@end{Example} |
| 5032 |
|
| 5033 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0248-1]} |
| 5034 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[If Target denotes the same object as |
| 5035 |
Source, the operation has no effect. Otherwise, the key/element pairs of Source |
| 5036 |
are copied to Target as for an @nt{assignment_statement} assigning Source to |
| 5037 |
Target.]} |
| 5038 |
@begin{Discussion} |
| 5039 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1]} |
| 5040 |
@ChgAdded{Version=[3],Text=[This routine exists for compatibility with the |
| 5041 |
bounded map containers. For an unbounded map, @exam{Assign(A, B)} and |
| 5042 |
@exam{A := B} behave identically. For a bounded map, := will raise an |
| 5043 |
exception if the container capacities are different, while Assign will |
| 5044 |
not raise an exception if there is enough room in the target.]} |
| 5045 |
@end{Discussion} |
| 5046 |
|
| 5047 |
@begin{Example} |
| 5048 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5049 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Move (Target : @key{in out} Map; |
| 5050 |
Source : @key{in out} Map);]} |
| 5051 |
@end{Example} |
| 5052 |
|
| 5053 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5054 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0262-1]} |
| 5055 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Target denotes the same object |
| 5056 |
as Source, then @Chg{Version=[3],New=[the operation],Old=[Move]} |
| 5057 |
has no effect. Otherwise, @Chg{Version=[3],New=[the operation is equivalent |
| 5058 |
to Assign (Target, Source) followed by Clear (Source)],Old=[Move first calls |
| 5059 |
Clear (Target). Then, each node from Source is removed from Source and inserted |
| 5060 |
into Target. The length of Source is 0 after a successful call to Move]}.]} |
| 5061 |
|
| 5062 |
@begin{Example} |
| 5063 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5064 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Map; |
| 5065 |
Key : @key{in} Key_Type; |
| 5066 |
New_Item : @key{in} Element_Type; |
| 5067 |
Position : @key{out} Cursor; |
| 5068 |
Inserted : @key{out} Boolean);]} |
| 5069 |
@end{Example} |
| 5070 |
|
| 5071 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5072 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Insert checks if a node with a key |
| 5073 |
equivalent to Key is already present in Container. If a match is found, |
| 5074 |
Inserted is set to False and Position designates the element with the matching |
| 5075 |
key. Otherwise, Insert allocates a new node, initializes it to Key and |
| 5076 |
New_Item, and adds it to Container; Inserted is set to True and Position |
| 5077 |
designates the newly-inserted node. Any exception raised during allocation is |
| 5078 |
propagated and Container is not modified.]} |
| 5079 |
|
| 5080 |
@begin{Example} |
| 5081 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5082 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Map; |
| 5083 |
Key : @key{in} Key_Type; |
| 5084 |
Position : @key{out} Cursor; |
| 5085 |
Inserted : @key{out} Boolean);]} |
| 5086 |
@end{Example} |
| 5087 |
|
| 5088 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5089 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Insert inserts Key into Container |
| 5090 |
as per the five-parameter Insert, with the difference that an element |
| 5091 |
initialized by default (see @RefSecNum{Object Declarations}) is inserted.]} |
| 5092 |
|
| 5093 |
@begin{Example} |
| 5094 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5095 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Map; |
| 5096 |
Key : @key{in} Key_Type; |
| 5097 |
New_Item : @key{in} Element_Type);]} |
| 5098 |
@end{Example} |
| 5099 |
|
| 5100 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5101 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Insert inserts Key and New_Item |
| 5102 |
into Container as per the five-parameter Insert, with the difference that if a |
| 5103 |
node with a key equivalent to Key is already in the map, then Constraint_Error |
| 5104 |
is propagated.]} |
| 5105 |
|
| 5106 |
@begin{Ramification} |
| 5107 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5108 |
@ChgAdded{Version=[2],Type=[Leading],Text=[This is equivalent to:]} |
| 5109 |
@begin{Example} |
| 5110 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5111 |
@ChgAdded{Version=[2],Text=[@key{declare} |
| 5112 |
Inserted : Boolean; C : Cursor; |
| 5113 |
@key{begin} |
| 5114 |
Insert (Container, Key, New_Item, C, Inserted); |
| 5115 |
@key{if not} Inserted @key{then} |
| 5116 |
@key{raise} Constraint_Error; |
| 5117 |
@key{end if}; |
| 5118 |
@key{end};]} |
| 5119 |
@end{Example} |
| 5120 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5121 |
@ChgAdded{Version=[2],Text=[but doesn't require the hassle of |
| 5122 |
@key{out} parameters.]} |
| 5123 |
@end{Ramification} |
| 5124 |
|
| 5125 |
@begin{Example} |
| 5126 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5127 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Include (Container : @key{in out} Map; |
| 5128 |
Key : @key{in} Key_Type; |
| 5129 |
New_Item : @key{in} Element_Type);]} |
| 5130 |
@end{Example} |
| 5131 |
|
| 5132 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5133 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Include inserts Key and New_Item |
| 5134 |
into Container as per the five-parameter Insert, with the difference that if a |
| 5135 |
node with a key equivalent to Key is already in the map, then this operation |
| 5136 |
assigns Key and New_Item to the matching node. Any exception raised during |
| 5137 |
assignment is propagated.]} |
| 5138 |
|
| 5139 |
@begin{Ramification} |
| 5140 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5141 |
@ChgAdded{Version=[2],Type=[Leading],Text=[This is equivalent to:]} |
| 5142 |
@begin{Example} |
| 5143 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5144 |
@ChgAdded{Version=[2],Text=[@key{declare} |
| 5145 |
C : Cursor := Find (Container, Key); |
| 5146 |
@key{begin} |
| 5147 |
@key{if} C = No_Element @key{then} |
| 5148 |
Insert (Container, Key, New_Item); |
| 5149 |
@key{else} |
| 5150 |
Replace (Container, Key, New_Item); |
| 5151 |
@key{end if}; |
| 5152 |
@key{end};]} |
| 5153 |
@end{Example} |
| 5154 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5155 |
@ChgAdded{Version=[2],Text=[but this avoids doing the search twice.]} |
| 5156 |
@end{Ramification} |
| 5157 |
|
| 5158 |
@begin{Example} |
| 5159 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5160 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace (Container : @key{in out} Map; |
| 5161 |
Key : @key{in} Key_Type; |
| 5162 |
New_Item : @key{in} Element_Type);]} |
| 5163 |
@end{Example} |
| 5164 |
|
| 5165 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5166 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Replace checks if a node with a key |
| 5167 |
equivalent to Key is present in Container. If a match is found, Replace assigns |
| 5168 |
Key and New_Item to the matching node; otherwise, Constraint_Error is |
| 5169 |
propagated.]} |
| 5170 |
|
| 5171 |
@begin{Discussion} |
| 5172 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5173 |
@ChgAdded{Version=[2],Text=[We update the key as well as the |
| 5174 |
element, as the key might include additional information that does not |
| 5175 |
participate in equivalence. If only the element needs to be updated, use |
| 5176 |
Replace_Element (Find (Container, Key), New_Element).]} |
| 5177 |
@end{Discussion} |
| 5178 |
|
| 5179 |
@begin{Example} |
| 5180 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5181 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Exclude (Container : @key{in out} Map; |
| 5182 |
Key : @key{in} Key_Type);]} |
| 5183 |
@end{Example} |
| 5184 |
|
| 5185 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5186 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Exclude checks if a node with a key |
| 5187 |
equivalent to Key is present in Container. If a match is found, Exclude removes |
| 5188 |
the node from the map.]} |
| 5189 |
|
| 5190 |
@begin{Ramification} |
| 5191 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5192 |
@ChgAdded{Version=[2],Text=[Exclude should work on an empty map; nothing |
| 5193 |
happens in that case.]} |
| 5194 |
@end{Ramification} |
| 5195 |
|
| 5196 |
@begin{Example} |
| 5197 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5198 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Map; |
| 5199 |
Key : @key{in} Key_Type);]} |
| 5200 |
@end{Example} |
| 5201 |
|
| 5202 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5203 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Delete checks if a node with a key |
| 5204 |
equivalent to Key is present in Container. If a match is found, Delete removes |
| 5205 |
the node from the map; otherwise, Constraint_Error is propagated.]} |
| 5206 |
|
| 5207 |
@begin{Example} |
| 5208 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5209 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Map; |
| 5210 |
Position : @key{in out} Cursor);]} |
| 5211 |
@end{Example} |
| 5212 |
|
| 5213 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5214 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 5215 |
Constraint_Error is propagated. If Position does not designate an element in |
| 5216 |
Container, then Program_Error is propagated. Otherwise, Delete removes the node |
| 5217 |
designated by Position from the map. Position is set to No_Element on return.]} |
| 5218 |
|
| 5219 |
@begin{Ramification} |
| 5220 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5221 |
@ChgAdded{Version=[2],Text=[The check on Position checks that the cursor does |
| 5222 |
not belong to some other map. This check implies that a reference to the map |
| 5223 |
is included in the cursor value. This wording is not meant to require |
| 5224 |
detection of dangling cursors; such cursors are defined to be invalid, which |
| 5225 |
means that execution is erroneous, and any result is allowed (including not |
| 5226 |
raising an exception).]} |
| 5227 |
@end{Ramification} |
| 5228 |
|
| 5229 |
@begin{Example} |
| 5230 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5231 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First (Container : Map) @key{return} Cursor;]} |
| 5232 |
@end{Example} |
| 5233 |
|
| 5234 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5235 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Length (Container) = 0, then |
| 5236 |
First returns No_Element. Otherwise, First returns a cursor that designates the |
| 5237 |
first node in Container.]} |
| 5238 |
|
| 5239 |
@begin{Example} |
| 5240 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5241 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Next (Position : Cursor) @key{return} Cursor;]} |
| 5242 |
@end{Example} |
| 5243 |
|
| 5244 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5245 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a cursor that designates |
| 5246 |
the successor of the node designated by Position. If Position designates the |
| 5247 |
last node, then No_Element is returned. If Position equals No_Element, then |
| 5248 |
No_Element is returned.]} |
| 5249 |
|
| 5250 |
@begin{Example} |
| 5251 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5252 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Next (Position : @key{in out} Cursor);]} |
| 5253 |
@end{Example} |
| 5254 |
|
| 5255 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5256 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Next (Position).]} |
| 5257 |
|
| 5258 |
@begin{Example} |
| 5259 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5260 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Find (Container : Map; |
| 5261 |
Key : Key_Type) @key{return} Cursor;]} |
| 5262 |
@end{Example} |
| 5263 |
|
| 5264 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5265 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Length (Container) equals 0, |
| 5266 |
then Find returns No_Element. Otherwise, Find checks if a node with a key |
| 5267 |
equivalent to Key is present in Container. If a match is found, a cursor |
| 5268 |
designating the matching node is returned; otherwise, No_Element is returned.]} |
| 5269 |
|
| 5270 |
@begin{Example} |
| 5271 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5272 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Element (Container : Map; |
| 5273 |
Key : Key_Type) @key{return} Element_Type;]} |
| 5274 |
@end{Example} |
| 5275 |
|
| 5276 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5277 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Find (Container, Key)).]} |
| 5278 |
|
| 5279 |
@begin{Example} |
| 5280 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5281 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Contains (Container : Map; |
| 5282 |
Key : Key_Type) @key{return} Boolean;]} |
| 5283 |
@end{Example} |
| 5284 |
|
| 5285 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5286 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Find (Container, Key) /= No_Element.]} |
| 5287 |
|
| 5288 |
@begin{Example} |
| 5289 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5290 |
@ChgRef{Version=[3],Kind=[DeletedNoDelMsg]} |
| 5291 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@Chg{Version=[3],New=[],Old=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean;]}]} |
| 5292 |
@end{Example} |
| 5293 |
|
| 5294 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5295 |
@ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]} |
| 5296 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[],Old=[Returns True if Position designates |
| 5297 |
an element, and returns False otherwise.]}]} |
| 5298 |
|
| 5299 |
@begin{Honest} |
| 5300 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5301 |
@ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]} |
| 5302 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[This function may not detect cursors that |
| 5303 |
designate deleted elements; such cursors are invalid (see below) and the |
| 5304 |
result of calling Has_Element with an invalid cursor is unspecified (but |
| 5305 |
not erroneous).]}]} |
| 5306 |
@end{Honest} |
| 5307 |
@begin{NotIso} |
| 5308 |
@ChgAdded{Version=[3],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 72 and 73 |
| 5309 |
were moved above.>}]}@Comment{This message should be |
| 5310 |
deleted if the paragraphs are ever renumbered.} |
| 5311 |
@end{NotIso} |
| 5312 |
|
| 5313 |
@begin{Example} |
| 5314 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5315 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Iterate |
| 5316 |
(Container : @key{in} Map; |
| 5317 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 5318 |
@end{Example} |
| 5319 |
|
| 5320 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5321 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]} |
| 5322 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Iterate calls Process.@key{all} |
| 5323 |
with a cursor that designates each node in Container, starting with the first |
| 5324 |
node and moving the cursor according to the successor relation. |
| 5325 |
@Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 5326 |
is propagated if Process.@key{all} tampers]} |
| 5327 |
with the cursors of Container@Chg{Version=[3],New=[ is prohibited during the |
| 5328 |
execution of a call on Process.@key{all}],Old=[]}. Any exception raised by |
| 5329 |
Process.@key{all} is propagated.]} |
| 5330 |
|
| 5331 |
@begin{ImplNote} |
| 5332 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5333 |
@ChgAdded{Version=[2],Text=[The @lquotes@;tamper with cursors@rquotes@; |
| 5334 |
check takes place when the operations that insert or delete elements, and |
| 5335 |
so on, are called.]} |
| 5336 |
|
| 5337 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5338 |
@ChgAdded{Version=[2],Text=[See Iterate for vectors |
| 5339 |
(@RefSecNum{The Generic Package Containers.Vectors}) for a suggested |
| 5340 |
implementation of the check.]} |
| 5341 |
@end{ImplNote} |
| 5342 |
|
| 5343 |
@end{DescribeCode} |
| 5344 |
@end{StaticSem} |
| 5345 |
|
| 5346 |
@begin{Bounded} |
| 5347 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0022-1],ARef=[AI05-0248-1]} |
| 5348 |
@ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)} |
| 5349 |
It is a bounded error for the actual function |
| 5350 |
associated with a generic formal subprogram, when called as part of an |
| 5351 |
operation of a map package, to tamper with elements of any map parameter of |
| 5352 |
the operation. Either Program_Error is raised, or the operation works as |
| 5353 |
defined on the value of the map either prior to, or subsequent to, some or |
| 5354 |
all of the modifications to the map.]} |
| 5355 |
|
| 5356 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0027-1]} |
| 5357 |
@ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)} |
| 5358 |
It is a bounded error to call any subprogram |
| 5359 |
declared in the visible part of a map package |
| 5360 |
when the associated container has been finalized. If the operation takes |
| 5361 |
Container as an @key[in out] parameter, then it raises Constraint_Error or |
| 5362 |
Program_Error. Otherwise, the operation either proceeds as it would |
| 5363 |
for an empty container, or it raises Constraint_Error or Program_Error.]} |
| 5364 |
@end{Bounded} |
| 5365 |
|
| 5366 |
@begin{Erron} |
| 5367 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5368 |
@ChgAdded{Version=[2],Type=[Leading],Text=[ |
| 5369 |
A Cursor value is @i{invalid} if any of the following have occurred since it was |
| 5370 |
created:@Defn2{Term=[invalid cursor],Sec=[of a map]} |
| 5371 |
@PDefn2{Term=[cursor],Sec=[invalid]}]} |
| 5372 |
|
| 5373 |
@begin{Itemize} |
| 5374 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5375 |
@ChgAdded{Version=[2],Text=[The map that contains the node it designates has |
| 5376 |
been finalized;]} |
| 5377 |
|
| 5378 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0160-1]} |
| 5379 |
@ChgAdded{Version=[3],Text=[The map that contains the node it designates has |
| 5380 |
been used as the Target of a call to Assign, or as the target of an |
| 5381 |
@nt{assignment_statement};]} |
| 5382 |
|
| 5383 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5384 |
@ChgAdded{Version=[2],Text=[The map that contains the node it designates has |
| 5385 |
been used as the Source or Target of a call to Move; or]} |
| 5386 |
|
| 5387 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5388 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0160-1],ARef=[AI05-0262-1]} |
| 5389 |
@ChgAdded{Version=[2],Text=[The node it designates has been |
| 5390 |
@Chg{Version=[3],New=[removed],Old=[deleted]} from the map@Chg{Version=[3],New=[ |
| 5391 |
that previously contained the node],Old=[]}.]} |
| 5392 |
@begin{Ramification} |
| 5393 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]} |
| 5394 |
@ChgAdded{Version=[3],Text=[This can happen directly via calls to Clear, |
| 5395 |
Exclude, and Delete.]} |
| 5396 |
@end{Ramification} |
| 5397 |
@end{Itemize} |
| 5398 |
|
| 5399 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5400 |
@ChgAdded{Version=[2],Text=[The result of "=" or Has_Element is unspecified if |
| 5401 |
these functions are called with an invalid cursor parameter.@PDefn{unspecified} |
| 5402 |
Execution is erroneous if any other subprogram declared in |
| 5403 |
Containers.Hashed_Maps or Containers.Ordered_Maps is called with an invalid |
| 5404 |
cursor parameter.@PDefn2{Term=(erroneous execution),Sec=(cause)}]} |
| 5405 |
|
| 5406 |
@begin{Discussion} |
| 5407 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5408 |
@ChgAdded{Version=[2],Text=[The list above is intended to be exhaustive. In |
| 5409 |
other cases, a cursor value continues to designate its original element. For |
| 5410 |
instance, cursor values survive the insertion and deletion of other nodes.]} |
| 5411 |
|
| 5412 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5413 |
@ChgAdded{Version=[2],Text=[While it is possible to check for these cases, in |
| 5414 |
many cases the overhead necessary to make the check is substantial in time or |
| 5415 |
space. Implementations are encouraged to check for as many of these cases as |
| 5416 |
possible and raise Program_Error if detected.]} |
| 5417 |
@end{Discussion} |
| 5418 |
|
| 5419 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 5420 |
@ChgAdded{Version=[3],Text=[Execution is erroneous if the map associated with |
| 5421 |
the result of a call to Reference or Constant_Reference is finalized before the |
| 5422 |
result object returned by the call to Reference or Constant_Reference is |
| 5423 |
finalized.]} |
| 5424 |
@begin{Reason} |
| 5425 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 5426 |
@ChgAdded{Version=[3],Text=[Each object of Reference_Type and |
| 5427 |
Constant_Reference_Type probably contains some reference to the originating |
| 5428 |
container. If that container is prematurely finalized (which is only possible |
| 5429 |
via Unchecked_Deallocation, as accessibility checks prevent passing a |
| 5430 |
container to Reference that will not live as long as the result), the |
| 5431 |
finalization of the object of Reference_Type will try to access a nonexistent |
| 5432 |
object. This is a normal case of a dangling pointer created by |
| 5433 |
Unchecked_Deallocation; we have to explicitly mention it here as the pointer |
| 5434 |
in question is not visible in the specification of the type. (This is the same |
| 5435 |
reason we have to say this for invalid cursors.)]} |
| 5436 |
@end{Reason} |
| 5437 |
@end{Erron} |
| 5438 |
|
| 5439 |
@begin{ImplReq} |
| 5440 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5441 |
@ChgAdded{Version=[2],Text=[No storage associated with a Map object shall be |
| 5442 |
lost upon assignment or scope exit.]} |
| 5443 |
|
| 5444 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5445 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]} |
| 5446 |
@ChgAdded{Version=[2],Text=[The execution of an @nt{assignment_statement} for |
| 5447 |
a map shall have the effect of copying the elements from the source map |
| 5448 |
object to the target map object@Chg{Version=[3],New=[ and changing the length |
| 5449 |
of the target object to that of the source object],Old=[]}.]} |
| 5450 |
|
| 5451 |
@begin{ImplNote} |
| 5452 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5453 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0298-1]} |
| 5454 |
@ChgAdded{Version=[2],Text=[An assignment of a Map is a @lquotes@;deep@rquotes |
| 5455 |
copy; that is the elements are copied as well as the data structures. |
| 5456 |
We say @lquotes@;effect of@rquotes in order to allow the implementation to |
| 5457 |
avoid copying elements immediately if it wishes. For instance, an |
| 5458 |
implementation that avoided copying until one of the containers is modified |
| 5459 |
would be allowed.@Chg{Version=[3],New=[ (Note that this implementation would |
| 5460 |
require care, see @RefSecNum{The Generic Package Containers.Vectors} for more.)],Old=[]}]} |
| 5461 |
@end{ImplNote} |
| 5462 |
@end{ImplReq} |
| 5463 |
|
| 5464 |
@begin{ImplAdvice} |
| 5465 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5466 |
@ChgAdded{Version=[2],Text=[Move should not copy elements, and should minimize |
| 5467 |
copying of internal data structures.]} |
| 5468 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 5469 |
Text=[Move for a map should not copy elements, and should |
| 5470 |
minimize copying of internal data structures.]}]} |
| 5471 |
|
| 5472 |
@begin{ImplNote} |
| 5473 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5474 |
@ChgAdded{Version=[2],Text=[Usually that can be accomplished simply by |
| 5475 |
moving the pointer(s) to the internal data structures from the Source |
| 5476 |
container to the Target container.]} |
| 5477 |
@end{ImplNote} |
| 5478 |
|
| 5479 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5480 |
@ChgAdded{Version=[2],Text=[If an exception is propagated from a map |
| 5481 |
operation, no storage should be lost, nor any elements removed from a map |
| 5482 |
unless specified by the operation.]} |
| 5483 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 5484 |
Text=[If an exception is propagated from a map |
| 5485 |
operation, no storage should be lost, nor any elements removed from a map |
| 5486 |
unless specified by the operation.]}]} |
| 5487 |
|
| 5488 |
@begin{Reason} |
| 5489 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5490 |
@ChgAdded{Version=[2],Text=[This is important so that programs can recover |
| 5491 |
from errors. But we don't want to require heroic efforts, so we just require |
| 5492 |
documentation of cases where this can't be accomplished.]} |
| 5493 |
@end{Reason} |
| 5494 |
|
| 5495 |
@end{ImplAdvice} |
| 5496 |
|
| 5497 |
@begin{DiffWord95} |
| 5498 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5499 |
@ChgAdded{Version=[2],Text=[This description of maps is new; the |
| 5500 |
extensions are documented with the specific packages.]} |
| 5501 |
@end{DiffWord95} |
| 5502 |
|
| 5503 |
@begin{Extend2005} |
| 5504 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]} |
| 5505 |
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005} |
| 5506 |
Added reference support to make map containers more |
| 5507 |
convenient to use.]} |
| 5508 |
@end{Extend2005} |
| 5509 |
|
| 5510 |
@begin{DiffWord2005} |
| 5511 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 5512 |
@ChgAdded{Version=[3],Text=[Added procedure Assign; |
| 5513 |
the extension and incompatibility is documented with the specific packages.]} |
| 5514 |
|
| 5515 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 5516 |
@ChgAdded{Version=[3],Text=[Generalized the definition |
| 5517 |
of Move. Specified which elements are read/written by stream attributes.]} |
| 5518 |
|
| 5519 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0022-1]} |
| 5520 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName |
| 5521 |
to cover tampering by generic actual subprograms.]} |
| 5522 |
|
| 5523 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0027-1]} |
| 5524 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName |
| 5525 |
to cover access to finalized map containers.]} |
| 5526 |
|
| 5527 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]} |
| 5528 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Revised the definition |
| 5529 |
of invalid cursors to cover missing (and new) cases.]} |
| 5530 |
|
| 5531 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0265-1]} |
| 5532 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Defined when a container |
| 5533 |
prohibits tampering in order to more clearly define where the check is |
| 5534 |
made and the exception raised.]} |
| 5535 |
@end{DiffWord2005} |
| 5536 |
|
| 5537 |
@begin{DiffWord2012} |
| 5538 |
@ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0110-1]} |
| 5539 |
@ChgAdded{Version=[4],Text=[@b<Corrigendum:> Clarified that tampering checks |
| 5540 |
precede all other checks made by a subprogram (but come after those associated |
| 5541 |
with the call).]} |
| 5542 |
@end{DiffWord2012} |
| 5543 |
|
| 5544 |
|
| 5545 |
@LabeledAddedSubclause{Version=[2],Name=[The Generic Package Containers.Hashed_Maps]} |
| 5546 |
|
| 5547 |
@begin{StaticSem} |
| 5548 |
|
| 5549 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5550 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library |
| 5551 |
package Containers.Hashed_Maps has the following declaration:]} |
| 5552 |
@begin{Example} |
| 5553 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5554 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0084-1],ARef=[AI05-0212-1]} |
| 5555 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[@key[with] Ada.Iterator_Interfaces; |
| 5556 |
],Old=[]}@key{generic} |
| 5557 |
@key{type} Key_Type @key{is private}; |
| 5558 |
@key{type} Element_Type @key{is private}; |
| 5559 |
@key{with function} Hash (Key : Key_Type) @key{return} Hash_Type; |
| 5560 |
@key{with function} Equivalent_Keys (Left, Right : Key_Type) |
| 5561 |
@key{return} Boolean; |
| 5562 |
@key{with function} "=" (Left, Right : Element_Type) |
| 5563 |
@key{return} Boolean @Chg{Version=[3],New=[@b<is>],Old=[is]} <>; |
| 5564 |
@key{package} Ada.Containers.Hashed_Maps @key{is}@ChildUnit{Parent=[Ada.Containers],Child=[Hashed_Maps]} |
| 5565 |
@key{pragma} Preelaborate(Hashed_Maps);@Chg{Version=[3],New=[ |
| 5566 |
@key{pragma} Remote_Types(Hashed_Maps);],Old=[]}]} |
| 5567 |
|
| 5568 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5569 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]} |
| 5570 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Map} @key{is tagged private}@Chg{Version=[3],New=[ |
| 5571 |
@key[with] Constant_Indexing => Constant_Reference, |
| 5572 |
Variable_Indexing => Reference, |
| 5573 |
Default_Iterator => Iterate, |
| 5574 |
Iterator_Element => Element_Type],Old=[]}; |
| 5575 |
@key{pragma} Preelaborable_Initialization(Map);]} |
| 5576 |
|
| 5577 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5578 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private}; |
| 5579 |
@key{pragma} Preelaborable_Initialization(Cursor);]} |
| 5580 |
|
| 5581 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5582 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{Empty_Map} : @key{constant} Map;]} |
| 5583 |
|
| 5584 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5585 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]} |
| 5586 |
|
| 5587 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 5588 |
@ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]} |
| 5589 |
|
| 5590 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 5591 |
@ChgAdded{Version=[3],Text=[ @key[package] @AdaPackDefn{Map_Iterator_Interfaces} @key[is new] |
| 5592 |
Ada.Iterator_Interfaces (Cursor, Has_Element);]} |
| 5593 |
|
| 5594 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5595 |
@ChgAdded{Version=[2],Text=[ @key{function} "=" (Left, Right : Map) @key{return} Boolean;]} |
| 5596 |
|
| 5597 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5598 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Capacity} (Container : Map) @key{return} Count_Type;]} |
| 5599 |
|
| 5600 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5601 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reserve_Capacity} (Container : @key{in out} Map; |
| 5602 |
Capacity : @key{in} Count_Type);]} |
| 5603 |
|
| 5604 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5605 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Length} (Container : Map) @key{return} Count_Type;]} |
| 5606 |
|
| 5607 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5608 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Empty} (Container : Map) @key{return} Boolean;]} |
| 5609 |
|
| 5610 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5611 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Clear} (Container : @key{in out} Map);]} |
| 5612 |
|
| 5613 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5614 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Key} (Position : Cursor) @key{return} Key_Type;]} |
| 5615 |
|
| 5616 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5617 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Position : Cursor) @key{return} Element_Type;]} |
| 5618 |
|
| 5619 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5620 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} Map; |
| 5621 |
Position : @key{in} Cursor; |
| 5622 |
New_Item : @key{in} Element_Type);]} |
| 5623 |
|
| 5624 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5625 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element} |
| 5626 |
(Position : @key{in} Cursor; |
| 5627 |
Process : @key{not null access procedure} (Key : @key{in} Key_Type; |
| 5628 |
Element : @key{in} Element_Type));]} |
| 5629 |
|
| 5630 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5631 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element} |
| 5632 |
(Container : @key{in out} Map; |
| 5633 |
Position : @key{in} Cursor; |
| 5634 |
Process : @key{not null access procedure} |
| 5635 |
(Key : @key{in} Key_Type; |
| 5636 |
Element : @key{in out} Element_Type));]} |
| 5637 |
|
| 5638 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 5639 |
@ChgAdded{Version=[3],Text=[ @key[type] Constant_Reference_Type |
| 5640 |
(Element : @key[not null access constant] Element_Type) @key[is private] |
| 5641 |
@key[with] Implicit_Dereference => Element;]} |
| 5642 |
|
| 5643 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 5644 |
@ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Reference_Type} (Element : @key[not null access] Element_Type) @key[is private] |
| 5645 |
@key[with] Implicit_Dereference => Element;]} |
| 5646 |
|
| 5647 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 5648 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Map; |
| 5649 |
Position : @key[in] Cursor) |
| 5650 |
@key[return] Constant_Reference_Type;]} |
| 5651 |
|
| 5652 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 5653 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] Map; |
| 5654 |
Position : @key[in] Cursor) |
| 5655 |
@key[return] Reference_Type;]} |
| 5656 |
|
| 5657 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 5658 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Map; |
| 5659 |
Key : @key[in] Key_Type) |
| 5660 |
@key[return] Constant_Reference_Type;]} |
| 5661 |
|
| 5662 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 5663 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] Map; |
| 5664 |
Key : @key[in] Key_Type) |
| 5665 |
@key[return] Reference_Type;]} |
| 5666 |
|
| 5667 |
@ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]} |
| 5668 |
@ChgAdded{Version=[3],Text=[ @key[procedure] @AdaSubDefn{Assign} (Target : @key[in out] Map; Source : @key[in] Map);]} |
| 5669 |
|
| 5670 |
@ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]} |
| 5671 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Copy} (Source : Map; Capacity : Count_Type := 0) @key[return] Map;]} |
| 5672 |
|
| 5673 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5674 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Move} (Target : @key{in out} Map; |
| 5675 |
Source : @key{in out} Map);]} |
| 5676 |
|
| 5677 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5678 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Map; |
| 5679 |
Key : @key{in} Key_Type; |
| 5680 |
New_Item : @key{in} Element_Type; |
| 5681 |
Position : @key{out} Cursor; |
| 5682 |
Inserted : @key{out} Boolean);]} |
| 5683 |
|
| 5684 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5685 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Map; |
| 5686 |
Key : @key{in} Key_Type; |
| 5687 |
Position : @key{out} Cursor; |
| 5688 |
Inserted : @key{out} Boolean);]} |
| 5689 |
|
| 5690 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5691 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Map; |
| 5692 |
Key : @key{in} Key_Type; |
| 5693 |
New_Item : @key{in} Element_Type);]} |
| 5694 |
|
| 5695 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5696 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Include} (Container : @key{in out} Map; |
| 5697 |
Key : @key{in} Key_Type; |
| 5698 |
New_Item : @key{in} Element_Type);]} |
| 5699 |
|
| 5700 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5701 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace} (Container : @key{in out} Map; |
| 5702 |
Key : @key{in} Key_Type; |
| 5703 |
New_Item : @key{in} Element_Type);]} |
| 5704 |
|
| 5705 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5706 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Exclude} (Container : @key{in out} Map; |
| 5707 |
Key : @key{in} Key_Type);]} |
| 5708 |
|
| 5709 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5710 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Map; |
| 5711 |
Key : @key{in} Key_Type);]} |
| 5712 |
|
| 5713 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5714 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Map; |
| 5715 |
Position : @key{in out} Cursor);]} |
| 5716 |
|
| 5717 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5718 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First} (Container : Map) |
| 5719 |
@key{return} Cursor;]} |
| 5720 |
|
| 5721 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5722 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Next} (Position : Cursor) @key{return} Cursor;]} |
| 5723 |
|
| 5724 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5725 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Next} (Position : @key{in out} Cursor);]} |
| 5726 |
|
| 5727 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5728 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Map; |
| 5729 |
Key : Key_Type) |
| 5730 |
@key{return} Cursor;]} |
| 5731 |
|
| 5732 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5733 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Container : Map; |
| 5734 |
Key : Key_Type) |
| 5735 |
@key{return} Element_Type;]} |
| 5736 |
|
| 5737 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5738 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Map; |
| 5739 |
Key : Key_Type) @key{return} Boolean;]} |
| 5740 |
|
| 5741 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5742 |
@ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0212-1]} |
| 5743 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]}]} |
| 5744 |
|
| 5745 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5746 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Keys} (Left, Right : Cursor) |
| 5747 |
@key{return} Boolean;]} |
| 5748 |
|
| 5749 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5750 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Keys} (Left : Cursor; |
| 5751 |
Right : Key_Type) |
| 5752 |
@key{return} Boolean;]} |
| 5753 |
|
| 5754 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5755 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Keys} (Left : Key_Type; |
| 5756 |
Right : Cursor) |
| 5757 |
@key{return} Boolean;]} |
| 5758 |
|
| 5759 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5760 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Iterate} |
| 5761 |
(Container : @key{in} Map; |
| 5762 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 5763 |
|
| 5764 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 5765 |
@ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] Map) |
| 5766 |
@key[return] Map_Iterator_Interfaces.Forward_Iterator'Class;]} |
| 5767 |
|
| 5768 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5769 |
@ChgAdded{Version=[2],Text=[@key{private}]} |
| 5770 |
|
| 5771 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5772 |
@ChgAdded{Version=[2],Text=[ ... -- @RI[not specified by the language]]} |
| 5773 |
|
| 5774 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5775 |
@ChgAdded{Version=[2],Text=[@key{end} Ada.Containers.Hashed_Maps;]} |
| 5776 |
|
| 5777 |
@end{Example} |
| 5778 |
|
| 5779 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5780 |
@ChgAdded{Version=[2],Text=[An object of type Map contains an expandable hash |
| 5781 |
table, which is used to provide direct access to nodes. The @i<capacity> of an |
| 5782 |
object of type Map is the maximum number of nodes that can be inserted into the |
| 5783 |
hash table prior to it being automatically |
| 5784 |
expanded.@Defn2{Term=[capacity],Sec=[of a hashed map]}]} |
| 5785 |
|
| 5786 |
@begin{ImplNote} |
| 5787 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5788 |
@ChgAdded{Version=[2],Text=[The expected implementation for a Map uses a |
| 5789 |
hash table which is grown when it is too small, with linked lists hanging off |
| 5790 |
of each bucket. Note that in that implementation a cursor needs a back |
| 5791 |
pointer to the Map object to implement iteration; that could either be in the |
| 5792 |
nodes, or in the cursor object. To provide an average @i{O}(1) access time, |
| 5793 |
capacity would typically equal the number of buckets in such an |
| 5794 |
implementation, so that the average bucket linked list length would be no |
| 5795 |
more than 1.0.]} |
| 5796 |
|
| 5797 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5798 |
@ChgAdded{Version=[2],Text=[There is no defined relationship between elements |
| 5799 |
in a hashed map. Typically, iteration will return elements in the order that |
| 5800 |
they are hashed in.]} |
| 5801 |
@end{ImplNote} |
| 5802 |
|
| 5803 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5804 |
@ChgAdded{Version=[2],Text=[@Defn2{Term={equivalent key},Sec={of a hashed map}} |
| 5805 |
Two keys @i<K1> and @i<K2> are defined to be @i<equivalent> if |
| 5806 |
Equivalent_Keys (@i<K1>, @i<K2>) returns True.]} |
| 5807 |
|
| 5808 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5809 |
@ChgAdded{Version=[2],Text=[The actual function for the generic formal function |
| 5810 |
Hash is expected to return the same value each time it is called with a |
| 5811 |
particular key value. For any two equivalent key values, the actual for Hash is |
| 5812 |
expected to return the same value. If the actual for Hash behaves in some other |
| 5813 |
manner, the behavior of this package is unspecified. Which subprograms of this |
| 5814 |
package call Hash, and how many times they call it, is |
| 5815 |
unspecified.@PDefn{unspecified}]} |
| 5816 |
|
| 5817 |
@begin{ImplNote} |
| 5818 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5819 |
@ChgAdded{Version=[2],Text=[The implementation is not required to protect |
| 5820 |
against Hash raising an exception, or returning random numbers, or any other |
| 5821 |
@lquotes@;bad@rquotes behavior. It's not practical to do so, and a broken |
| 5822 |
Hash function makes the container unusable.]} |
| 5823 |
|
| 5824 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5825 |
@ChgAdded{Version=[2],Text=[The implementation can call Hash whenever it is |
| 5826 |
needed; we don't want to specify how often that happens. The result must |
| 5827 |
remain the same (this is logically a pure function), or the behavior is |
| 5828 |
unspecified.]} |
| 5829 |
@end{ImplNote} |
| 5830 |
|
| 5831 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5832 |
@ChgAdded{Version=[2],Text=[The actual function for the generic formal function |
| 5833 |
Equivalent_Keys on Key_Type values is expected to return the same value each |
| 5834 |
time it is called with a particular pair of key values. It should define an |
| 5835 |
equivalence relationship, that is, be reflexive, symmetric, and transitive. If |
| 5836 |
the actual for Equivalent_Keys behaves in some other manner, the behavior of |
| 5837 |
this package is unspecified. Which subprograms of this package call |
| 5838 |
Equivalent_Keys, and how many times they call it, is |
| 5839 |
unspecified.@PDefn{unspecified}]} |
| 5840 |
|
| 5841 |
@begin{ImplNote} |
| 5842 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5843 |
@ChgAdded{Version=[2],Text=[As with Hash, the implementation is not required |
| 5844 |
to protect against Equivalent_Keys raising an exception or returning random |
| 5845 |
results. Similarly, the implementation can call this operation whenever it is |
| 5846 |
needed. The result must remain the same (this is a logically pure function), |
| 5847 |
or the behavior is unspecified.]} |
| 5848 |
@end{ImplNote} |
| 5849 |
|
| 5850 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5851 |
@ChgAdded{Version=[2],Text=[If the value of a key stored in a node of a map is |
| 5852 |
changed other than by an operation in this package such that at least one of |
| 5853 |
Hash or Equivalent_Keys give different results, the behavior of this package is |
| 5854 |
unspecified.@PDefn{unspecified}]} |
| 5855 |
|
| 5856 |
@begin{ImplNote} |
| 5857 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5858 |
@ChgAdded{Version=[2],Text=[The implementation is not required to protect |
| 5859 |
against changes to key values other than via the operations declared in the |
| 5860 |
Hashed_Maps package.]} |
| 5861 |
|
| 5862 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5863 |
@ChgAdded{Version=[2],Type=[Leading],Text=[To see how this could happen, |
| 5864 |
imagine an instance of Hashed_Maps where the key type is an |
| 5865 |
access-to-variable type and Hash returns a value derived from the components |
| 5866 |
of the designated object. Then, any operation that has a key value could |
| 5867 |
modify those components and change the hash value:]} |
| 5868 |
|
| 5869 |
@begin{Example} |
| 5870 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5871 |
@ChgAdded{Version=[2],Text=[Key (Map).Some_Component := New_Value;]} |
| 5872 |
@end{Example} |
| 5873 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5874 |
@ChgAdded{Version=[2],Text=[This is really a design error on the part of the |
| 5875 |
user of the map; it shouldn't be possible to modify keys stored in a map. But |
| 5876 |
we can't prevent this error anymore than we can prevent someone passing as |
| 5877 |
Hash a random number generator.]} |
| 5878 |
@end{ImplNote} |
| 5879 |
|
| 5880 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5881 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[first node],Sec=[of a hashed map]} |
| 5882 |
@Defn2{Term=[last node],Sec=[of a hashed map]} |
| 5883 |
@Defn2{Term=[successor node],Sec=[of a hashed map]}Which nodes are the first node and the last node of a map, and which node is the |
| 5884 |
successor of a given node, are unspecified, other than the general semantics |
| 5885 |
described in @RefSecNum{Maps}.@PDefn{unspecified}]} |
| 5886 |
|
| 5887 |
@begin{ImplNote} |
| 5888 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5889 |
@ChgAdded{Version=[2],Text=[Typically the first node will be the first node |
| 5890 |
in the first bucket, the last node will be the last node in the last bucket, |
| 5891 |
and the successor will be obtained by following the collision list, and going |
| 5892 |
to the next bucket at the end of each bucket.]} |
| 5893 |
@end{ImplNote} |
| 5894 |
|
| 5895 |
@begin{DescribeCode} |
| 5896 |
|
| 5897 |
@begin{Example} |
| 5898 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5899 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Capacity (Container : Map) @key{return} Count_Type;]} |
| 5900 |
@end{Example} |
| 5901 |
|
| 5902 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5903 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the capacity of Container.]} |
| 5904 |
|
| 5905 |
@begin{Example} |
| 5906 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5907 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reserve_Capacity (Container : @key{in out} Map; |
| 5908 |
Capacity : @key{in} Count_Type);]} |
| 5909 |
@end{Example} |
| 5910 |
|
| 5911 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5912 |
@ChgAdded{Version=[2],Text=[Reserve_Capacity allocates a new hash table such |
| 5913 |
that the length of the resulting map can become at least the value Capacity |
| 5914 |
without requiring an additional call to Reserve_Capacity, and is large enough |
| 5915 |
to hold the current length of Container. Reserve_Capacity then rehashes the |
| 5916 |
nodes in Container onto the new hash table. It replaces the old hash table with |
| 5917 |
the new hash table, and then deallocates the old hash table. Any exception |
| 5918 |
raised during allocation is propagated and Container is not modified.]} |
| 5919 |
|
| 5920 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5921 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Reserve_Capacity tampers with the |
| 5922 |
cursors of Container.]} |
| 5923 |
|
| 5924 |
@begin{ImplNote} |
| 5925 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5926 |
@ChgAdded{Version=[2],Text=[This routine is used to preallocate the internal |
| 5927 |
hash table to the specified capacity such that future Inserts do not require |
| 5928 |
expansion of the hash table. Therefore, the implementation should allocate |
| 5929 |
the needed memory to make that true at this point, even though the visible |
| 5930 |
semantics could be preserved by waiting until enough elements are inserted.]} |
| 5931 |
|
| 5932 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5933 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]} |
| 5934 |
@ChgAdded{Version=[2],Text=[While Reserve_Capacity can be used to reduce the |
| 5935 |
capacity of a map, we do not specify whether an implementation actually |
| 5936 |
supports reduction of the capacity. Since the actual capacity can be anything |
| 5937 |
greater than or equal to @Chg{Version=[3],New=[Capacity],Old=[Count]}, |
| 5938 |
an implementation never has to reduce the capacity.]} |
| 5939 |
|
| 5940 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5941 |
@ChgAdded{Version=[2],Text=[Reserve_Capacity tampers with the cursors, as |
| 5942 |
rehashing probably will change the order that elements are stored in the |
| 5943 |
map.]} |
| 5944 |
@end{ImplNote} |
| 5945 |
|
| 5946 |
@begin{Example} |
| 5947 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5948 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Clear (Container : @key{in out} Map);]} |
| 5949 |
@end{Example} |
| 5950 |
|
| 5951 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 5952 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[In addition to the semantics |
| 5953 |
described in @RefSecNum{Maps}, Clear does not affect the capacity of |
| 5954 |
Container.]} |
| 5955 |
|
| 5956 |
@begin{Example} |
| 5957 |
@ChgRef{Version=[3],Kind=[Added]} |
| 5958 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[procedure] Assign (Target : @key[in out] Map; Source : @key[in] Map);]} |
| 5959 |
@end{Example} |
| 5960 |
|
| 5961 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0248-1]} |
| 5962 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[In addition to the semantics |
| 5963 |
described in @RefSecNum{Maps}, if the length of Source is greater than the |
| 5964 |
capacity of Target, |
| 5965 |
Reserve_Capacity (Target, Length (Source)) is called before assigning |
| 5966 |
any elements.]} |
| 5967 |
|
| 5968 |
@begin{Example} |
| 5969 |
@ChgRef{Version=[3],Kind=[Added]} |
| 5970 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Copy (Source : Map; Capacity : Count_Type := 0) @key[return] Map;]} |
| 5971 |
@end{Example} |
| 5972 |
|
| 5973 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 5974 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns a map whose keys and |
| 5975 |
elements are initialized from the keys and elements of Source. If Capacity is 0, |
| 5976 |
then the map capacity is the length of Source; if Capacity is equal to or |
| 5977 |
greater than the length of Source, the map capacity is at least the specified |
| 5978 |
value. Otherwise, the operation propagates Capacity_Error.]} |
| 5979 |
|
| 5980 |
@begin{ImplNote} |
| 5981 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5982 |
@ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[In:]} |
| 5983 |
|
| 5984 |
@begin{Example} |
| 5985 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5986 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Move (Target : @key{in out} Map; |
| 5987 |
Source : @key{in out} Map);]} |
| 5988 |
@end{Example} |
| 5989 |
|
| 5990 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5991 |
@ChgAdded{Version=[2],Text=[The intended implementation is that the internal |
| 5992 |
hash table of Target is first deallocated; then the internal hash table is |
| 5993 |
removed from Source and moved to Target.]} |
| 5994 |
@end{ImplNote} |
| 5995 |
|
| 5996 |
@begin{Example} |
| 5997 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 5998 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Map; |
| 5999 |
Key : @key{in} Key_Type; |
| 6000 |
New_Item : @key{in} Element_Type; |
| 6001 |
Position : @key{out} Cursor; |
| 6002 |
Inserted : @key{out} Boolean);]} |
| 6003 |
@end{Example} |
| 6004 |
|
| 6005 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6006 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[In addition to the semantics |
| 6007 |
described in @RefSecNum{Maps}, if Length (Container) equals Capacity |
| 6008 |
(Container), then Insert first calls Reserve_Capacity to increase the capacity |
| 6009 |
of Container to some larger value.]} |
| 6010 |
|
| 6011 |
@begin{ImplNote} |
| 6012 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6013 |
@ChgAdded{Version=[2],Text=[Insert should only compare keys that hash to the |
| 6014 |
same bucket in the hash table.]} |
| 6015 |
|
| 6016 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6017 |
@ChgAdded{Version=[2],Text=[We specify when Reserve_Capacity is called to bound |
| 6018 |
the overhead of capacity expansion operations (which are potentially |
| 6019 |
expensive). Moreover, expansion can be predicted by comparing Capacity(Map) to |
| 6020 |
Length(Map). Since we don't specify by how much the hash table is expanded, |
| 6021 |
this only can be used to predict the next expansion, not later ones.]} |
| 6022 |
|
| 6023 |
@end{ImplNote} |
| 6024 |
@begin{ImplNote} |
| 6025 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6026 |
@ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[In:]} |
| 6027 |
|
| 6028 |
@begin{Example} |
| 6029 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6030 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Exclude (Container : @key{in out} Map; |
| 6031 |
Key : @key{in} Key_Type);]} |
| 6032 |
@end{Example} |
| 6033 |
|
| 6034 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6035 |
@ChgAdded{Version=[2],Text=[Exclude should only compare keys that hash to the same bucket in the hash |
| 6036 |
table.]} |
| 6037 |
|
| 6038 |
@end{ImplNote} |
| 6039 |
@begin{ImplNote} |
| 6040 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6041 |
@ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[In:]} |
| 6042 |
|
| 6043 |
@begin{Example} |
| 6044 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6045 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Map; |
| 6046 |
Key : @key{in} Key_Type);]} |
| 6047 |
@end{Example} |
| 6048 |
|
| 6049 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6050 |
@ChgAdded{Version=[2],Text=[Delete should only compare keys that hash to the |
| 6051 |
same bucket in the hash table. The node containing the element may be |
| 6052 |
deallocated now, or it may be saved and reused later.]} |
| 6053 |
|
| 6054 |
@end{ImplNote} |
| 6055 |
@begin{ImplNote} |
| 6056 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6057 |
@ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[In:]} |
| 6058 |
|
| 6059 |
@begin{Example} |
| 6060 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6061 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First (Container : Map) @key{return} Cursor;]} |
| 6062 |
@end{Example} |
| 6063 |
|
| 6064 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6065 |
@ChgAdded{Version=[2],Text=[In a typical implementation, this will be the first node in the lowest numbered |
| 6066 |
hash bucket that contains a node.]} |
| 6067 |
|
| 6068 |
@end{ImplNote} |
| 6069 |
@begin{ImplNote} |
| 6070 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6071 |
@ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[In:]} |
| 6072 |
|
| 6073 |
@begin{Example} |
| 6074 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6075 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Next (Position : Cursor) @key{return} Cursor;]} |
| 6076 |
@end{Example} |
| 6077 |
|
| 6078 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6079 |
@ChgAdded{Version=[2],Text=[In a typical implementation, this will return the next node in a bucket; if |
| 6080 |
Position is the last node in a bucket, this will return the first node in the |
| 6081 |
next nonempty bucket.]} |
| 6082 |
|
| 6083 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6084 |
@ChgAdded{Version=[2],Text=[A typical implementation will need to a keep a pointer at the map container |
| 6085 |
in the cursor in order to implement this function.]} |
| 6086 |
@end{ImplNote} |
| 6087 |
@begin{ImplNote} |
| 6088 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6089 |
@ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[In:]} |
| 6090 |
|
| 6091 |
@begin{Example} |
| 6092 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6093 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Find (Container : Map; |
| 6094 |
Key : Key_Type) @key{return} Cursor;]} |
| 6095 |
@end{Example} |
| 6096 |
|
| 6097 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6098 |
@ChgAdded{Version=[2],Text=[Find should only compare keys that hash to the same bucket in the hash table.]} |
| 6099 |
|
| 6100 |
@end{ImplNote} |
| 6101 |
|
| 6102 |
@begin{Example} |
| 6103 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6104 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Keys (Left, Right : Cursor) |
| 6105 |
@key{return} Boolean;]} |
| 6106 |
@end{Example} |
| 6107 |
|
| 6108 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6109 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Equivalent_Keys (Key |
| 6110 |
(Left), Key (Right)).]} |
| 6111 |
|
| 6112 |
@begin{Example} |
| 6113 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6114 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Keys (Left : Cursor; |
| 6115 |
Right : Key_Type) @key{return} Boolean;]} |
| 6116 |
@end{Example} |
| 6117 |
|
| 6118 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6119 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Equivalent_Keys (Key |
| 6120 |
(Left), Right).]} |
| 6121 |
|
| 6122 |
@begin{Example} |
| 6123 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6124 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Keys (Left : Key_Type; |
| 6125 |
Right : Cursor) @key{return} Boolean;]} |
| 6126 |
@end{Example} |
| 6127 |
|
| 6128 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6129 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Equivalent_Keys |
| 6130 |
(Left, Key (Right)).]} |
| 6131 |
|
| 6132 |
@begin{Example} |
| 6133 |
@ChgRef{Version=[3],Kind=[Added]} |
| 6134 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Map) |
| 6135 |
@key[return] Map_Iterator_Interfaces.Forward_Iterator'Class;]} |
| 6136 |
@end{Example} |
| 6137 |
|
| 6138 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]} |
| 6139 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Iterate returns an |
| 6140 |
iterator object (see @RefSecNum{User-Defined Iterator Types}) that |
| 6141 |
will generate a value for a loop parameter (see |
| 6142 |
@RefSecNum{Generalized Loop Iteration}) designating |
| 6143 |
each node in Container, starting with the first node and moving the cursor |
| 6144 |
according to the successor relation. |
| 6145 |
Tampering with the cursors of Container is prohibited while |
| 6146 |
the iterator object exists (in particular, in |
| 6147 |
the @nt{sequence_of_statements} of the @nt{loop_statement} whose |
| 6148 |
@nt{iterator_specification} denotes this object). The iterator object needs |
| 6149 |
finalization.]} |
| 6150 |
|
| 6151 |
@end{DescribeCode} |
| 6152 |
@end{StaticSem} |
| 6153 |
|
| 6154 |
@begin{ImplAdvice} |
| 6155 |
|
| 6156 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6157 |
@ChgAdded{Version=[2],Text=[If @i<N> is the length of a map, the average time |
| 6158 |
complexity of the subprograms Element, Insert, Include, Replace, Delete, |
| 6159 |
Exclude and Find that take a key parameter should be @i{O}(log @i<N>). The average |
| 6160 |
time complexity of the subprograms that take a cursor parameter should be @i{O}(1). |
| 6161 |
The average time complexity of Reserve_Capacity should be @i{O}(@i<N>).]} |
| 6162 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 6163 |
Text=[The average time complexity of Element, Insert, Include, Replace, |
| 6164 |
Delete, Exclude and Find operations that |
| 6165 |
take a key parameter for Containers.Hashed_Maps should be |
| 6166 |
@i{O}(log @i<N>). The average |
| 6167 |
time complexity of the subprograms of Containers.Hashed_Maps that take |
| 6168 |
a cursor parameter should be @i{O}(1). The average time complexity of |
| 6169 |
Containers.Hashed_Maps.Reserve_Capacity should be @i{O}(@i<N>).]}]} |
| 6170 |
|
| 6171 |
@begin{Reason} |
| 6172 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6173 |
@ChgAdded{Version=[2],Text=[We do not mean to overly constrain implementation |
| 6174 |
strategies here. However, it is important for portability that the |
| 6175 |
performance of large containers has roughly the same factors on different |
| 6176 |
implementations. If a program is moved to an implementation for which Find is |
| 6177 |
@i{O}(@i<N>), that program could be unusable when the maps are large. We allow |
| 6178 |
@i{O}(log @i<N>) access because the proportionality constant and caching effects |
| 6179 |
are likely to be larger than the log factor, and we don't want to discourage |
| 6180 |
innovative implementations.]} |
| 6181 |
@end{Reason} |
| 6182 |
@end{ImplAdvice} |
| 6183 |
|
| 6184 |
@begin{Extend95} |
| 6185 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6186 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 6187 |
The generic package Containers.Hashed_Maps is new.]} |
| 6188 |
@end{Extend95} |
| 6189 |
|
| 6190 |
@begin{Incompatible2005} |
| 6191 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 6192 |
@ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Subprograms Assign and Copy |
| 6193 |
are added to Containers.Hashed_Maps. If an instance of Containers.Hashed_Maps |
| 6194 |
is referenced in a @nt{use_clause}, and an entity @i<E> with the same |
| 6195 |
@nt{defining_identifier} as a new entity in Containers.Hashed_Maps is |
| 6196 |
defined in a package that is also referenced in a @nt{use_clause}, the |
| 6197 |
entity @i<E> may no longer be use-visible, resulting in errors. This should |
| 6198 |
be rare and is easily fixed if it does occur.]} |
| 6199 |
@end{Incompatible2005} |
| 6200 |
|
| 6201 |
@begin{Extend2005} |
| 6202 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]} |
| 6203 |
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005} |
| 6204 |
Added iterator and indexing support to make hashed map containers more |
| 6205 |
convenient to use.]} |
| 6206 |
@end{Extend2005} |
| 6207 |
|
| 6208 |
@begin{Diffword2005} |
| 6209 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0084-1]} |
| 6210 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a pragma |
| 6211 |
Remote_Types so that containers can be used in distributed programs.]} |
| 6212 |
@end{Diffword2005} |
| 6213 |
|
| 6214 |
|
| 6215 |
@LabeledAddedSubclause{Version=[2],Name=[The Generic Package Containers.Ordered_Maps]} |
| 6216 |
|
| 6217 |
@begin{StaticSem} |
| 6218 |
|
| 6219 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6220 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library |
| 6221 |
package Containers.Ordered_Maps has the following declaration:]} |
| 6222 |
@begin{Example} |
| 6223 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6224 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0084-1],ARef=[AI05-0212-1]} |
| 6225 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[@key[with] Ada.Iterator_Interfaces; |
| 6226 |
],Old=[]}@key{generic} |
| 6227 |
@key{type} Key_Type @key{is private}; |
| 6228 |
@key{type} Element_Type @key{is private}; |
| 6229 |
@key{with function} "<" (Left, Right : Key_Type) @key{return} Boolean @key{is} <>; |
| 6230 |
@key{with function} "=" (Left, Right : Element_Type) @key{return} Boolean @key{is} <>; |
| 6231 |
@key{package} Ada.Containers.Ordered_Maps @key{is}@ChildUnit{Parent=[Ada.Containers],Child=[Ordered_Maps]} |
| 6232 |
@key{pragma} Preelaborate(Ordered_Maps);@Chg{Version=[3],New=[ |
| 6233 |
@key{pragma} Remote_Types(Ordered_Maps);],Old=[]}]} |
| 6234 |
|
| 6235 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6236 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Keys} (Left, Right : Key_Type) @key{return} Boolean;]} |
| 6237 |
|
| 6238 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6239 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]} |
| 6240 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Map} @key{is tagged private}@Chg{Version=[3],New=[ |
| 6241 |
@key[with] Constant_Indexing => Constant_Reference, |
| 6242 |
Variable_Indexing => Reference, |
| 6243 |
Default_Iterator => Iterate, |
| 6244 |
Iterator_Element => Element_Type],Old=[]}; |
| 6245 |
@key{pragma} Preelaborable_Initialization(Map);]} |
| 6246 |
|
| 6247 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6248 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private}; |
| 6249 |
@key{pragma} Preelaborable_Initialization(Cursor);]} |
| 6250 |
|
| 6251 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6252 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{Empty_Map} : @key{constant} Map;]} |
| 6253 |
|
| 6254 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6255 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]} |
| 6256 |
|
| 6257 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 6258 |
@ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]} |
| 6259 |
|
| 6260 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 6261 |
@ChgAdded{Version=[3],Text=[ @key[package] @AdaPackDefn{Map_Iterator_Interfaces} @key[is new] |
| 6262 |
Ada.Iterator_Interfaces (Cursor, Has_Element);]} |
| 6263 |
|
| 6264 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6265 |
@ChgAdded{Version=[2],Text=[ @key{function} "=" (Left, Right : Map) @key{return} Boolean;]} |
| 6266 |
|
| 6267 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6268 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Length} (Container : Map) @key{return} Count_Type;]} |
| 6269 |
|
| 6270 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6271 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Empty} (Container : Map) @key{return} Boolean;]} |
| 6272 |
|
| 6273 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6274 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Clear} (Container : @key{in out} Map);]} |
| 6275 |
|
| 6276 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6277 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Key} (Position : Cursor) @key{return} Key_Type;]} |
| 6278 |
|
| 6279 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6280 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Position : Cursor) @key{return} Element_Type;]} |
| 6281 |
|
| 6282 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6283 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} Map; |
| 6284 |
Position : @key{in} Cursor; |
| 6285 |
New_Item : @key{in} Element_Type);]} |
| 6286 |
|
| 6287 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6288 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element} |
| 6289 |
(Position : @key{in} Cursor; |
| 6290 |
Process : @key{not null access procedure} (Key : @key{in} Key_Type; |
| 6291 |
Element : @key{in} Element_Type));]} |
| 6292 |
|
| 6293 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6294 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element} |
| 6295 |
(Container : @key{in out} Map; |
| 6296 |
Position : @key{in} Cursor; |
| 6297 |
Process : @key{not null access procedure} |
| 6298 |
(Key : @key{in} Key_Type; |
| 6299 |
Element : @key{in out} Element_Type));]} |
| 6300 |
|
| 6301 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 6302 |
@ChgAdded{Version=[3],Text=[ @key[type] Constant_Reference_Type |
| 6303 |
(Element : @key[not null access constant] Element_Type) @key[is private] |
| 6304 |
@key[with] Implicit_Dereference => Element;]} |
| 6305 |
|
| 6306 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 6307 |
@ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Reference_Type} (Element : @key[not null access] Element_Type) @key[is private] |
| 6308 |
@key[with] Implicit_Dereference => Element;]} |
| 6309 |
|
| 6310 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 6311 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Map; |
| 6312 |
Position : @key[in] Cursor) |
| 6313 |
@key[return] Constant_Reference_Type;]} |
| 6314 |
|
| 6315 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 6316 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] Map; |
| 6317 |
Position : @key[in] Cursor) |
| 6318 |
@key[return] Reference_Type;]} |
| 6319 |
|
| 6320 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 6321 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Map; |
| 6322 |
Key : @key[in] Key_Type) |
| 6323 |
@key[return] Constant_Reference_Type;]} |
| 6324 |
|
| 6325 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 6326 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] Map; |
| 6327 |
Key : @key[in] Key_Type) |
| 6328 |
@key[return] Reference_Type;]} |
| 6329 |
|
| 6330 |
@ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]} |
| 6331 |
@ChgAdded{Version=[3],Text=[ @key[procedure] @AdaSubDefn{Assign} (Target : @key[in out] Map; Source : @key[in] Map);]} |
| 6332 |
|
| 6333 |
@ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]} |
| 6334 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Copy} (Source : Map) @key[return] Map;]} |
| 6335 |
|
| 6336 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6337 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Move} (Target : @key{in out} Map; |
| 6338 |
Source : @key{in out} Map);]} |
| 6339 |
|
| 6340 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6341 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Map; |
| 6342 |
Key : @key{in} Key_Type; |
| 6343 |
New_Item : @key{in} Element_Type; |
| 6344 |
Position : @key{out} Cursor; |
| 6345 |
Inserted : @key{out} Boolean);]} |
| 6346 |
|
| 6347 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6348 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Map; |
| 6349 |
Key : @key{in} Key_Type; |
| 6350 |
Position : @key{out} Cursor; |
| 6351 |
Inserted : @key{out} Boolean);]} |
| 6352 |
|
| 6353 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6354 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Map; |
| 6355 |
Key : @key{in} Key_Type; |
| 6356 |
New_Item : @key{in} Element_Type);]} |
| 6357 |
|
| 6358 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6359 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Include} (Container : @key{in out} Map; |
| 6360 |
Key : @key{in} Key_Type; |
| 6361 |
New_Item : @key{in} Element_Type);]} |
| 6362 |
|
| 6363 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6364 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace} (Container : @key{in out} Map; |
| 6365 |
Key : @key{in} Key_Type; |
| 6366 |
New_Item : @key{in} Element_Type);]} |
| 6367 |
|
| 6368 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6369 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Exclude} (Container : @key{in out} Map; |
| 6370 |
Key : @key{in} Key_Type);]} |
| 6371 |
|
| 6372 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6373 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Map; |
| 6374 |
Key : @key{in} Key_Type);]} |
| 6375 |
|
| 6376 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6377 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Map; |
| 6378 |
Position : @key{in out} Cursor);]} |
| 6379 |
|
| 6380 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6381 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_First} (Container : @key{in out} Map);]} |
| 6382 |
|
| 6383 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6384 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_Last} (Container : @key{in out} Map);]} |
| 6385 |
|
| 6386 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6387 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First} (Container : Map) @key{return} Cursor;]} |
| 6388 |
|
| 6389 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6390 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First_Element} (Container : Map) @key{return} Element_Type;]} |
| 6391 |
|
| 6392 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6393 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First_Key} (Container : Map) @key{return} Key_Type;]} |
| 6394 |
|
| 6395 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6396 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last} (Container : Map) @key{return} Cursor;]} |
| 6397 |
|
| 6398 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6399 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last_Element} (Container : Map) @key{return} Element_Type;]} |
| 6400 |
|
| 6401 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6402 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last_Key} (Container : Map) @key{return} Key_Type;]} |
| 6403 |
|
| 6404 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6405 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Next} (Position : Cursor) @key{return} Cursor;]} |
| 6406 |
|
| 6407 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6408 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Next} (Position : @key{in out} Cursor);]} |
| 6409 |
|
| 6410 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6411 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Previous} (Position : Cursor) @key{return} Cursor;]} |
| 6412 |
|
| 6413 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6414 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Previous} (Position : @key{in out} Cursor);]} |
| 6415 |
|
| 6416 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6417 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Map; |
| 6418 |
Key : Key_Type) @key{return} Cursor;]} |
| 6419 |
|
| 6420 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6421 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Container : Map; |
| 6422 |
Key : Key_Type) @key{return} Element_Type;]} |
| 6423 |
|
| 6424 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6425 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Floor} (Container : Map; |
| 6426 |
Key : Key_Type) @key{return} Cursor;]} |
| 6427 |
|
| 6428 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6429 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Ceiling} (Container : Map; |
| 6430 |
Key : Key_Type) @key{return} Cursor;]} |
| 6431 |
|
| 6432 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6433 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Map; |
| 6434 |
Key : Key_Type) @key{return} Boolean;]} |
| 6435 |
|
| 6436 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6437 |
@ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0212-1]} |
| 6438 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]}]} |
| 6439 |
|
| 6440 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6441 |
@ChgAdded{Version=[2],Text=[ @key{function} "<" (Left, Right : Cursor) @key{return} Boolean;]} |
| 6442 |
|
| 6443 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6444 |
@ChgAdded{Version=[2],Text=[ @key{function} ">" (Left, Right : Cursor) @key{return} Boolean;]} |
| 6445 |
|
| 6446 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6447 |
@ChgAdded{Version=[2],Text=[ @key{function} "<" (Left : Cursor; Right : Key_Type) @key{return} Boolean;]} |
| 6448 |
|
| 6449 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6450 |
@ChgAdded{Version=[2],Text=[ @key{function} ">" (Left : Cursor; Right : Key_Type) @key{return} Boolean;]} |
| 6451 |
|
| 6452 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6453 |
@ChgAdded{Version=[2],Text=[ @key{function} "<" (Left : Key_Type; Right : Cursor) @key{return} Boolean;]} |
| 6454 |
|
| 6455 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6456 |
@ChgAdded{Version=[2],Text=[ @key{function} ">" (Left : Key_Type; Right : Cursor) @key{return} Boolean;]} |
| 6457 |
|
| 6458 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6459 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Iterate} |
| 6460 |
(Container : @key{in} Map; |
| 6461 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 6462 |
|
| 6463 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6464 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reverse_Iterate} |
| 6465 |
(Container : @key{in} Map; |
| 6466 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 6467 |
|
| 6468 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 6469 |
@ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] Map) |
| 6470 |
@key[return] Map_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 6471 |
|
| 6472 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0262-1]} |
| 6473 |
@ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] Map; Start : @key[in] Cursor) |
| 6474 |
@key[return] Map_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 6475 |
|
| 6476 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6477 |
@ChgAdded{Version=[2],Text=[@key{private}]} |
| 6478 |
|
| 6479 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6480 |
@ChgAdded{Version=[2],Text=[ ... -- @RI[not specified by the language]]} |
| 6481 |
|
| 6482 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6483 |
@ChgAdded{Version=[2],Text=[@key{end} Ada.Containers.Ordered_Maps;]} |
| 6484 |
|
| 6485 |
@end{Example} |
| 6486 |
|
| 6487 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6488 |
@ChgAdded{Version=[2],Text=[@Defn2{Term={equivalent key},Sec={of an ordered map}} |
| 6489 |
Two keys @i<K1> and @i<K2> are @i<equivalent> if both @i<K1> < @i<K2> and |
| 6490 |
@i<K2> < @i<K1> return False, using the generic formal "<" operator for keys. |
| 6491 |
Function Equivalent_Keys returns True if Left and Right are equivalent, and |
| 6492 |
False otherwise.]} |
| 6493 |
|
| 6494 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6495 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0044-1]} |
| 6496 |
@ChgAdded{Version=[2],Text=[The actual function for the generic formal function |
| 6497 |
"<" on Key_Type values is expected to return the same value each time it is |
| 6498 |
called with a particular pair of key values. It should define a strict |
| 6499 |
@Chg{Version=[3],New=[weak ],Old=[]}ordering relationship@Chg{Version=[3], |
| 6500 |
New=[ (see @RefSecNum{Containers})],Old=[, that is, be irreflexive, asymmetric, |
| 6501 |
and transitive]}. If the |
| 6502 |
actual for "<" behaves in some other manner, the behavior of this package is |
| 6503 |
unspecified. Which subprograms of this package call "<" and how many times they |
| 6504 |
call it, is unspecified.@PDefn{unspecified}]} |
| 6505 |
|
| 6506 |
@begin{ImplNote} |
| 6507 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6508 |
@ChgAdded{Version=[2],Text=[The implementation is not required to protect |
| 6509 |
against "<" raising an exception, or returning random results, or any |
| 6510 |
other @lquotes@;bad@rquotes behavior. It's not practical to do so, and a |
| 6511 |
broken "<" function makes the container unusable.]} |
| 6512 |
|
| 6513 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6514 |
@ChgAdded{Version=[2],Text=[The implementation can call "<" whenever |
| 6515 |
it is needed; we don't want to specify how often that happens. The result |
| 6516 |
must remain the same (this is a logically pure function), or the behavior is |
| 6517 |
unspecified.]} |
| 6518 |
@end{ImplNote} |
| 6519 |
|
| 6520 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6521 |
@ChgAdded{Version=[2],Text=[If the value of a key stored in a map is changed |
| 6522 |
other than by an operation in this package such that at least one of "<" or "=" |
| 6523 |
give different results, the behavior of this package is |
| 6524 |
unspecified.@PDefn{unspecified}]} |
| 6525 |
|
| 6526 |
@begin{ImplNote} |
| 6527 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6528 |
@ChgAdded{Version=[2],Text=[The implementation is not required to protect |
| 6529 |
against changes to key values other than via the operations declared in the |
| 6530 |
Ordered_Maps package.]} |
| 6531 |
|
| 6532 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6533 |
@ChgAdded{Version=[2],Type=[Leading],Text=[To see how this could happen, |
| 6534 |
imagine an instance of Ordered_Maps package where the key type is an |
| 6535 |
access-to-variable type and "<" returns a value derived from comparing the |
| 6536 |
components of the designated objects. Then, any operation that has a key |
| 6537 |
value (even if the key value is constant) could modify those components and |
| 6538 |
change the result of "<":]} |
| 6539 |
|
| 6540 |
@begin{example} |
| 6541 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6542 |
@ChgAdded{Version=[2],Text=[Key (Map).Some_Component := New_Value;]} |
| 6543 |
@end{example} |
| 6544 |
|
| 6545 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6546 |
@ChgAdded{Version=[2],Text=[This is really a design error on the part of the |
| 6547 |
user of the map; it shouldn't be possible to modify keys stored in a map such |
| 6548 |
that "<" changes. But we can't prevent this error anymore than we can prevent |
| 6549 |
someone passing as "<" a routine that produces random answers.]} |
| 6550 |
@end{ImplNote} |
| 6551 |
|
| 6552 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6553 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]} |
| 6554 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[first node],Sec=[of an ordered map]} |
| 6555 |
@Defn2{Term=[last node],Sec=[of an ordered map]} |
| 6556 |
@Defn2{Term=[successor node],Sec=[of an ordered map]}@Chg{Version=[3],New=[ |
| 6557 |
@Defn2{Term=[predecessor node],Sec=[of an ordered map]}],Old=[]} |
| 6558 |
The @Chg{Version=[3],New=[@i<first node>],Old=[first node]} |
| 6559 |
of a nonempty map is the one whose key is less than the key of |
| 6560 |
all the other nodes in the map. The @Chg{Version=[3],New=[@i<last node>],Old=[last node]} |
| 6561 |
of a nonempty map is the one |
| 6562 |
whose key is greater than the key of all the other elements in the map. The |
| 6563 |
@Chg{Version=[3],New=[@i<successor>],Old=[successor]} |
| 6564 |
of a node is the node with the smallest key that is larger than the |
| 6565 |
key of the given node. The @Chg{Version=[3],New=[@i<predecessor>],Old=[predecessor]} |
| 6566 |
of a node is the node with the largest key that is smaller than the key of the |
| 6567 |
given node. All comparisons are done using the generic formal "<" operator for |
| 6568 |
keys.]} |
| 6569 |
|
| 6570 |
@begin{DescribeCode} |
| 6571 |
|
| 6572 |
@begin{Example} |
| 6573 |
@ChgRef{Version=[3],Kind=[Added]} |
| 6574 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Copy (Source : Map) @key[return] Map;]} |
| 6575 |
@end{Example} |
| 6576 |
|
| 6577 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 6578 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns a map whose keys and |
| 6579 |
elements are initialized from the corresponding keys and elements of Source.]} |
| 6580 |
|
| 6581 |
|
| 6582 |
@begin{Example} |
| 6583 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6584 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_First (Container : @key{in out} Map);]} |
| 6585 |
@end{Example} |
| 6586 |
|
| 6587 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6588 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 6589 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Delete_First |
| 6590 |
has no effect. Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 6591 |
the node designated by First (Container) is removed |
| 6592 |
from Container. Delete_First tampers with the cursors of Container.]} |
| 6593 |
|
| 6594 |
@begin{Example} |
| 6595 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6596 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_Last (Container : @key{in out} Map);]} |
| 6597 |
@end{Example} |
| 6598 |
|
| 6599 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6600 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 6601 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Delete_Last |
| 6602 |
has no effect. Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 6603 |
the node designated by Last (Container) is removed |
| 6604 |
from Container. Delete_Last tampers with the cursors of Container.]} |
| 6605 |
|
| 6606 |
@begin{Example} |
| 6607 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6608 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First_Element (Container : Map) @key{return} Element_Type;]} |
| 6609 |
@end{Example} |
| 6610 |
|
| 6611 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6612 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (First (Container)).]} |
| 6613 |
|
| 6614 |
@begin{Example} |
| 6615 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6616 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First_Key (Container : Map) @key{return} Key_Type;]} |
| 6617 |
@end{Example} |
| 6618 |
|
| 6619 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6620 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (First (Container)).]} |
| 6621 |
|
| 6622 |
@begin{Example} |
| 6623 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6624 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last (Container : Map) @key{return} Cursor;]} |
| 6625 |
@end{Example} |
| 6626 |
|
| 6627 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6628 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a cursor that designates |
| 6629 |
the last node in Container. If Container is empty, returns No_Element.]} |
| 6630 |
|
| 6631 |
@begin{Example} |
| 6632 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6633 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last_Element (Container : Map) @key{return} Element_Type;]} |
| 6634 |
@end{Example} |
| 6635 |
|
| 6636 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6637 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Last (Container)).]} |
| 6638 |
|
| 6639 |
@begin{Example} |
| 6640 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6641 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last_Key (Container : Map) @key{return} Key_Type;]} |
| 6642 |
@end{Example} |
| 6643 |
|
| 6644 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6645 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (Last (Container)).]} |
| 6646 |
|
| 6647 |
@begin{Example} |
| 6648 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6649 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Previous (Position : Cursor) @key{return} Cursor;]} |
| 6650 |
@end{Example} |
| 6651 |
|
| 6652 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6653 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]} |
| 6654 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 6655 |
Previous returns No_Element. Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 6656 |
Previous returns a cursor designating the @Chg{Version=[3],New=[predecessor |
| 6657 |
],Old=[]}node @Chg{Version=[3],New=[of],Old=[that precedes]} the one designated |
| 6658 |
by Position. If Position designates the first element, then Previous returns |
| 6659 |
No_Element.]} |
| 6660 |
|
| 6661 |
@begin{Example} |
| 6662 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6663 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Previous (Position : @key{in out} Cursor);]} |
| 6664 |
@end{Example} |
| 6665 |
|
| 6666 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6667 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Previous (Position).]} |
| 6668 |
|
| 6669 |
@begin{Example} |
| 6670 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6671 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Floor (Container : Map; |
| 6672 |
Key : Key_Type) @key{return} Cursor;]} |
| 6673 |
@end{Example} |
| 6674 |
|
| 6675 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6676 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 6677 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Floor searches for the last node |
| 6678 |
whose key is not greater than Key, using the generic formal "<" operator for keys. |
| 6679 |
If such a node is found, a cursor that designates it is returned. |
| 6680 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 6681 |
No_Element is returned.]} |
| 6682 |
|
| 6683 |
@begin{Example} |
| 6684 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6685 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Ceiling (Container : Map; |
| 6686 |
Key : Key_Type) @key{return} Cursor;]} |
| 6687 |
@end{Example} |
| 6688 |
|
| 6689 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6690 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 6691 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Ceiling searches for the first node |
| 6692 |
whose key is not less than Key, using the generic formal "<" operator for keys. |
| 6693 |
If such a node is found, a cursor that designates it is returned. |
| 6694 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} No_Element is returned.]} |
| 6695 |
|
| 6696 |
@begin{Example} |
| 6697 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6698 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "<" (Left, Right : Cursor) @key{return} Boolean;]} |
| 6699 |
@end{Example} |
| 6700 |
|
| 6701 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6702 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (Left) < Key (Right).]} |
| 6703 |
|
| 6704 |
@begin{Example} |
| 6705 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6706 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} ">" (Left, Right : Cursor) @key{return} Boolean;]} |
| 6707 |
@end{Example} |
| 6708 |
|
| 6709 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6710 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (Right) < Key (Left).]} |
| 6711 |
|
| 6712 |
@begin{Example} |
| 6713 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6714 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "<" (Left : Cursor; Right : Key_Type) @key{return} Boolean;]} |
| 6715 |
@end{Example} |
| 6716 |
|
| 6717 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6718 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (Left) < Right.]} |
| 6719 |
|
| 6720 |
@begin{Example} |
| 6721 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6722 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} ">" (Left : Cursor; Right : Key_Type) @key{return} Boolean;]} |
| 6723 |
@end{Example} |
| 6724 |
|
| 6725 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6726 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Right < Key (Left).]} |
| 6727 |
|
| 6728 |
@begin{Example} |
| 6729 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6730 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "<" (Left : Key_Type; Right : Cursor) @key{return} Boolean;]} |
| 6731 |
@end{Example} |
| 6732 |
|
| 6733 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6734 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Left < Key (Right).]} |
| 6735 |
|
| 6736 |
@begin{Example} |
| 6737 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6738 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} ">" (Left : Key_Type; Right : Cursor) @key{return} Boolean;]} |
| 6739 |
@end{Example} |
| 6740 |
|
| 6741 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6742 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (Right) < Left.]} |
| 6743 |
|
| 6744 |
@begin{Example} |
| 6745 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6746 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reverse_Iterate |
| 6747 |
(Container : @key{in} Map; |
| 6748 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 6749 |
@end{Example} |
| 6750 |
|
| 6751 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6752 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]} |
| 6753 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Iterates over the nodes in |
| 6754 |
Container as per @Chg{Version=[3],New=[procedure ],Old=[]}Iterate, |
| 6755 |
with the difference that the nodes are traversed in |
| 6756 |
predecessor order, starting with the last node.]} |
| 6757 |
|
| 6758 |
@begin{Example} |
| 6759 |
@ChgRef{Version=[3],Kind=[Added]} |
| 6760 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Map) |
| 6761 |
@key[return] Map_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 6762 |
@end{Example} |
| 6763 |
|
| 6764 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]} |
| 6765 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Iterate returns a reversible |
| 6766 |
iterator object (see @RefSecNum{User-Defined Iterator Types}) that |
| 6767 |
will generate a value for a loop parameter |
| 6768 |
(see @RefSecNum{Generalized Loop Iteration}) designating |
| 6769 |
each node in Container, starting with the first node and moving the cursor |
| 6770 |
according to the successor relation when used as a forward iterator, and |
| 6771 |
starting with the last node and moving the cursor according to the predecessor |
| 6772 |
relation when used as a reverse iterator. |
| 6773 |
Tampering with the cursors of Container is prohibited while |
| 6774 |
the iterator object exists (in particular, in |
| 6775 |
the @nt{sequence_of_statements} of the @nt{loop_statement} whose |
| 6776 |
@nt{iterator_specification} denotes this object). The iterator object needs |
| 6777 |
finalization.]} |
| 6778 |
|
| 6779 |
@begin{Example} |
| 6780 |
@ChgRef{Version=[3],Kind=[Added]} |
| 6781 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Map; Start : @key[in] Cursor) |
| 6782 |
@key[return] Map_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 6783 |
@end{Example} |
| 6784 |
|
| 6785 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0262-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]} |
| 6786 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[If Start is not No_Element and does not designate an item in Container, |
| 6787 |
then Program_Error is propagated. If Start is No_Element, then Constraint_Error |
| 6788 |
is propagated. Otherwise, Iterate returns a reversible iterator object |
| 6789 |
(see @RefSecNum{User-Defined Iterator Types}) that will generate |
| 6790 |
a value for a loop parameter (see @RefSecNum{Generalized Loop Iteration}) |
| 6791 |
designating each node in Container, starting with |
| 6792 |
the node designated by Start and moving the cursor according to the successor |
| 6793 |
relation when used as a forward iterator, or moving the cursor according to the |
| 6794 |
predecessor relation when used as a reverse iterator. Tampering with the cursors |
| 6795 |
of Container is prohibited while the iterator object exists (in particular, in |
| 6796 |
the @nt{sequence_of_statements} of the @nt{loop_statement} whose |
| 6797 |
@nt{iterator_specification} denotes this object). The iterator object needs |
| 6798 |
finalization.]} |
| 6799 |
|
| 6800 |
@begin{Discussion} |
| 6801 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 6802 |
@ChgAdded{Version=[3],Type=[Leading],Text=[Exits are allowed from the loops |
| 6803 |
created using the iterator objects. In particular, to stop the iteration at a |
| 6804 |
particular cursor, just add]} |
| 6805 |
@begin{Example} |
| 6806 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 6807 |
@ChgAdded{Version=[3],Text=[@key[exit when] Cur = Stop;]} |
| 6808 |
@end{Example} |
| 6809 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 6810 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[in the body of the loop (assuming |
| 6811 |
that @exam{Cur} is the loop parameter and @exam{Stop} is the cursor that you |
| 6812 |
want to stop at).]} |
| 6813 |
@end{Discussion} |
| 6814 |
@end{DescribeCode} |
| 6815 |
@end{StaticSem} |
| 6816 |
|
| 6817 |
@begin{ImplAdvice} |
| 6818 |
|
| 6819 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6820 |
@ChgAdded{Version=[2],Text=[If @i<N> is the length of a map, then the |
| 6821 |
worst-case time complexity of the |
| 6822 |
Element, Insert, Include, Replace, Delete, Exclude and Find operations that |
| 6823 |
take a key parameter should be @i{O}((log @i<N>)**2) or better. The worst-case |
| 6824 |
time complexity of the subprograms that take a cursor parameter should be @i{O}(1).]} |
| 6825 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 6826 |
Text=[The worst-case time complexity of Element, Insert, Include, Replace, |
| 6827 |
Delete, Exclude and Find operations that |
| 6828 |
take a key parameter for Containers.Ordered_Maps should be |
| 6829 |
@i{O}((log @i<N>)**2) or better. The worst-case |
| 6830 |
time complexity of the subprograms of Containers.Ordered_Maps that take |
| 6831 |
a cursor parameter should be @i{O}(1).]}]} |
| 6832 |
|
| 6833 |
@begin{ImplNote} |
| 6834 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6835 |
@ChgAdded{Version=[2],Text=[A balanced (red-black) tree for keys has |
| 6836 |
@i{O}(log @i<N>) worst-case performance. Note that a @i{O}(@i<N>) worst-case |
| 6837 |
implementation (like a list) would be wrong.]} |
| 6838 |
@end{ImplNote} |
| 6839 |
|
| 6840 |
@begin{Reason} |
| 6841 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6842 |
@ChgAdded{Version=[2],Text=[We do not mean to overly constrain implementation |
| 6843 |
strategies here. However, it is important for portability that the |
| 6844 |
performance of large containers has roughly the same factors on different |
| 6845 |
implementations. If a program is moved to an implementation that takes @i{O}(@i<N>) |
| 6846 |
to find elements, that program could be unusable when the maps are large. We |
| 6847 |
allow the extra log @i<N> factors because the proportionality constant and |
| 6848 |
caching effects are likely to be larger than the log factor, and we don't |
| 6849 |
want to discourage innovative implementations.]} |
| 6850 |
@end{Reason} |
| 6851 |
|
| 6852 |
@end{ImplAdvice} |
| 6853 |
|
| 6854 |
@begin{Extend95} |
| 6855 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6856 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 6857 |
The generic package Containers.Ordered_Maps is new.]} |
| 6858 |
@end{Extend95} |
| 6859 |
|
| 6860 |
@begin{Incompatible2005} |
| 6861 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 6862 |
@ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Subprograms Assign and Copy |
| 6863 |
are added to Containers.Ordered_Maps. If an instance of Containers.Ordered_Maps |
| 6864 |
is referenced in a @nt{use_clause}, and an entity @i<E> with the same |
| 6865 |
@nt{defining_identifier} as a new entity in Containers.Ordered_Maps is |
| 6866 |
defined in a package that is also referenced in a @nt{use_clause}, the |
| 6867 |
entity @i<E> may no longer be use-visible, resulting in errors. This should |
| 6868 |
be rare and is easily fixed if it does occur.]} |
| 6869 |
@end{Incompatible2005} |
| 6870 |
|
| 6871 |
@begin{Extend2005} |
| 6872 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]} |
| 6873 |
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005} |
| 6874 |
Added iterator and indexing support to make ordered map containers more |
| 6875 |
convenient to use.]} |
| 6876 |
@end{Extend2005} |
| 6877 |
|
| 6878 |
@begin{DiffWord2005} |
| 6879 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]} |
| 6880 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Redefined "<" actuals |
| 6881 |
to require a strict weak ordering; the old definition allowed |
| 6882 |
indeterminant comparisons that would not have worked in a container.]} |
| 6883 |
|
| 6884 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0084-1]} |
| 6885 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a pragma |
| 6886 |
Remote_Types so that containers can be used in distributed programs.]} |
| 6887 |
@end{DiffWord2005} |
| 6888 |
|
| 6889 |
|
| 6890 |
@LabeledAddedSubclause{Version=[2],Name=[Sets]} |
| 6891 |
|
| 6892 |
@begin{Intro} |
| 6893 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6894 |
@ChgAdded{Version=[2],Text=[The language-defined generic packages |
| 6895 |
Containers.Hashed_Sets and Containers.Ordered_Sets provide private types Set |
| 6896 |
and Cursor, and a set of operations for each type. A set container allows |
| 6897 |
elements of an arbitrary type to be stored without duplication. A hashed set |
| 6898 |
uses a hash function to organize elements, while an ordered set orders its |
| 6899 |
element per a specified relation.@Defn{set container} |
| 6900 |
@Defn2{Term=[container],Sec=[set]}]} |
| 6901 |
|
| 6902 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6903 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]} |
| 6904 |
@ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[subclause],Old=[section]} |
| 6905 |
describes the declarations that are common to both kinds of sets. |
| 6906 |
See @RefSecNum{The Generic Package Containers.Hashed_Sets} for a description of the |
| 6907 |
semantics specific to |
| 6908 |
Containers.Hashed_Sets and @RefSecNum{The Generic Package Containers.Ordered_Sets} for |
| 6909 |
a description of the semantics specific to Containers.Ordered_Sets.]} |
| 6910 |
@end{Intro} |
| 6911 |
|
| 6912 |
@begin{StaticSem} |
| 6913 |
|
| 6914 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6915 |
@ChgAdded{Version=[2],Text=[The actual function for the generic formal function |
| 6916 |
"=" on Element_Type values is expected to define a reflexive and symmetric |
| 6917 |
relationship and return the same result value each time it is called with a |
| 6918 |
particular pair of values. If it behaves in some other manner, the function |
| 6919 |
"=" on set values returns an unspecified value. The |
| 6920 |
exact arguments and number of calls of this generic formal function by the |
| 6921 |
function "=" on set values are unspecified.@PDefn{unspecified}]} |
| 6922 |
|
| 6923 |
@begin{Ramification} |
| 6924 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6925 |
@ChgAdded{Version=[2],Text=[If the actual function for "=" is not symmetric |
| 6926 |
and consistent, the result returned by the "=" for Set objects cannot be |
| 6927 |
predicted. The implementation is not required to protect |
| 6928 |
against "=" raising an exception, or returning random results, or any |
| 6929 |
other @lquotes@;bad@rquotes behavior. And it can call "=" in whatever |
| 6930 |
manner makes sense. But note that only the result of "=" for Set objects |
| 6931 |
is unspecified; other subprograms are not allowed to break if "=" is bad |
| 6932 |
(they aren't expected to use "=").]} |
| 6933 |
@end{Ramification} |
| 6934 |
|
| 6935 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6936 |
@ChgAdded{Version=[2],Text=[The type Set is used to represent sets. The type |
| 6937 |
Set needs finalization@PDefn2{Term=<needs finalization>,Sec=<language-defined type>} |
| 6938 |
(see @RefSecNum{Assignment and Finalization}).]} |
| 6939 |
|
| 6940 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6941 |
@ChgAdded{Version=[2],Text=[A set contains elements. Set cursors designate |
| 6942 |
elements. There exists an equivalence relation on elements, whose definition is |
| 6943 |
different for hashed sets and ordered sets. A set never contains two or more |
| 6944 |
equivalent elements. The @i{length} of a set is the number of elements it |
| 6945 |
contains.@Defn2{Term={length},Sec={of a set}}]} |
| 6946 |
|
| 6947 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6948 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[first element],Sec=[of a set]} |
| 6949 |
@Defn2{Term=[last element],Sec=[of a set]} |
| 6950 |
@Defn2{Term=[successor element],Sec=[of a set]} |
| 6951 |
Each nonempty set has two particular elements called the @i{first element} and |
| 6952 |
the @i{last element} (which may be the same). Each element except for the last |
| 6953 |
element has a @i{successor element}. If there are no other intervening |
| 6954 |
operations, starting with the first element and repeatedly going to the |
| 6955 |
successor element will visit each element in the set exactly once until the |
| 6956 |
last element is reached. The exact definition of these terms is different for |
| 6957 |
hashed sets and ordered sets.]} |
| 6958 |
|
| 6959 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6960 |
@ChgAdded{Version=[2],Text=[@Redundant[Some operations of these generic packages |
| 6961 |
have access-to-subprogram parameters. To ensure such operations are |
| 6962 |
well-defined, they guard against certain actions by the designated |
| 6963 |
subprogram. In particular, some operations check for @lquotes@;tampering with |
| 6964 |
cursors@rquotes of a container because they depend on the set of elements of |
| 6965 |
the container remaining constant, and others check for @lquotes@;tampering with |
| 6966 |
elements@rquotes of a container because they depend on elements of the |
| 6967 |
container not being replaced.]]} |
| 6968 |
|
| 6969 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 6970 |
@ChgAdded{Version=[2],Type=[Leading],Text=[@Defn2{Term=[tamper with cursors],Sec=[of a set]} |
| 6971 |
A subprogram is said to @i{tamper with cursors} of a set object @i{S} if:]} |
| 6972 |
|
| 6973 |
@begin{Itemize} |
| 6974 |
|
| 6975 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6976 |
@ChgAdded{Version=[2],Text=[it inserts or deletes elements of @i{S}, that is, |
| 6977 |
it calls the Insert, Include, Clear, Delete, Exclude, or Replace_Element |
| 6978 |
procedures with @i{S} as a parameter; or]} |
| 6979 |
|
| 6980 |
@begin{Honest} |
| 6981 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6982 |
@ChgAdded{Version=[2],Text=[Operations which are defined to be equivalent to |
| 6983 |
a call on one of these operations also are included. Similarly, operations |
| 6984 |
which call one of these as part of their definition are included.]} |
| 6985 |
@end{Honest} |
| 6986 |
|
| 6987 |
@begin{Discussion} |
| 6988 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6989 |
@ChgAdded{Version=[2],Text=[We have to include Replace_Element here because |
| 6990 |
it might delete and reinsert the element if it moves in the set. That could |
| 6991 |
change the order of iteration, which is what this check is designed to |
| 6992 |
prevent. Replace is also included, as it is defined in terms of |
| 6993 |
Replace_Element.]} |
| 6994 |
@end{Discussion} |
| 6995 |
|
| 6996 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 6997 |
@ChgAdded{Version=[2],Text=[it finalizes @i<S>; or]} |
| 6998 |
|
| 6999 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 7000 |
@ChgAdded{Version=[3],Text=[it calls the Assign procedure with @i<S> as the Target parameter; |
| 7001 |
or]} |
| 7002 |
|
| 7003 |
@begin{Ramification} |
| 7004 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 7005 |
@ChgAdded{Version=[3],Text=[We don't need to explicitly mention |
| 7006 |
@nt{assignment_statement}, because that finalizes the target object |
| 7007 |
as part of the operation, and finalization of an object is already defined |
| 7008 |
as tampering with cursors.]} |
| 7009 |
@end{Ramification} |
| 7010 |
|
| 7011 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7012 |
@ChgAdded{Version=[2],Text=[it calls the Move procedure with @i<S> as a |
| 7013 |
parameter; or]} |
| 7014 |
|
| 7015 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7016 |
@ChgAdded{Version=[2],Text=[it calls one of the operations defined to tamper with cursors of @i<S>.]} |
| 7017 |
|
| 7018 |
@end{Itemize} |
| 7019 |
|
| 7020 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7021 |
@ChgAdded{Version=[2],Type=[Leading],Text=[@Defn2{Term=[tamper with elements],Sec=[of a set]} |
| 7022 |
A subprogram is said to @i{tamper with elements} of a set |
| 7023 |
object @i<S> if:]} |
| 7024 |
|
| 7025 |
@begin{Itemize} |
| 7026 |
|
| 7027 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7028 |
@ChgAdded{Version=[2],Text=[it tampers with cursors of @i<S>.]} |
| 7029 |
|
| 7030 |
@begin{Reason} |
| 7031 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7032 |
@ChgAdded{Version=[2],Text=[Complete replacement of an element can cause its |
| 7033 |
memory to be deallocated while another operation is holding onto a reference |
| 7034 |
to it. That can't be allowed. However, a simple modification of (part of) an |
| 7035 |
element is not a problem, so Update_@!Element_@!Preserving_@!Key does not cause a |
| 7036 |
problem.]} |
| 7037 |
|
| 7038 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7039 |
@ChgAdded{Version=[2],Text=[We don't need to list Replace and Replace_Element |
| 7040 |
here because they are covered by @lquotes@;tamper with cursors@rquotes. |
| 7041 |
For Set, @lquotes@;tamper with cursors@rquotes@; |
| 7042 |
and @lquotes@;tamper with elements@rquotes are the same. We leave both |
| 7043 |
terms so that the rules for routines like Iterate and |
| 7044 |
Query_Element are consistent across all containers.]} |
| 7045 |
@end{Reason} |
| 7046 |
|
| 7047 |
@end{Itemize} |
| 7048 |
|
| 7049 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0265-1]} |
| 7050 |
@ChgRef{Version=[4],Kind=[RevisedAdded],ARef=[AI12-0110-1]} |
| 7051 |
@ChgAdded{Version=[3],Text=[@Defn2{Term=[prohibited],Sec=[tampering with a set]} |
| 7052 |
@Defn2{Term=[tampering],Sec=[prohibited for a set]} |
| 7053 |
When tampering with cursors is @i<prohibited> for a particular set object |
| 7054 |
@i<S>, Program_Error is propagated by a call of any language-defined subprogram |
| 7055 |
that is defined to tamper with the cursors of @i<S>, leaving @i<S> unmodified. |
| 7056 |
Similarly, when tampering with elements is @i<prohibited> for a particular set |
| 7057 |
object @i<S>, Program_Error is propagated by a call of any language-defined |
| 7058 |
subprogram that is defined to tamper with the elements of @i<S> @Redundant[(or |
| 7059 |
tamper with the cursors of @i<S>)], leaving @i<S> |
| 7060 |
unmodified.@Chg{Version=[4],New=[ These checks are made before any other |
| 7061 |
defined behavior of the body of the language-defined subprogram.],Old=[]}]} |
| 7062 |
@begin{TheProof} |
| 7063 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 7064 |
@ChgAdded{Version=[3],Text=[Tampering with elements includes tampering with |
| 7065 |
cursors, so we mention it only from completeness in the second sentence.]} |
| 7066 |
@end{TheProof} |
| 7067 |
|
| 7068 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7069 |
@ChgAdded{Version=[2],Text=[Empty_Set represents the empty Set object. It has a |
| 7070 |
length of 0. If an object of type Set is not otherwise initialized, it is |
| 7071 |
initialized to the same value as Empty_Set.]} |
| 7072 |
|
| 7073 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7074 |
@ChgAdded{Version=[2],Text=[No_Element represents a cursor that designates no |
| 7075 |
element. If an object of type Cursor is not otherwise initialized, it is |
| 7076 |
initialized to the same value as No_Element.]} |
| 7077 |
|
| 7078 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7079 |
@ChgAdded{Version=[2],Text=[The predefined "=" operator for type Cursor returns |
| 7080 |
True if both cursors are No_Element, or designate the same element in the same |
| 7081 |
container.]} |
| 7082 |
|
| 7083 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7084 |
@ChgAdded{Version=[2],Text=[Execution of the default implementation of the |
| 7085 |
Input, Output, Read, or Write attribute of type Cursor raises Program_Error.]} |
| 7086 |
|
| 7087 |
@begin{Reason} |
| 7088 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7089 |
@ChgAdded{Version=[2],Text=[A cursor will probably be implemented in terms |
| 7090 |
of one or more access values, and the effects of streaming access values is |
| 7091 |
unspecified. Rather than letting the user stream junk by accident, we mandate |
| 7092 |
that streaming of cursors raise Program_Error by default. The attributes |
| 7093 |
can always be specified if there is a need to support streaming.]} |
| 7094 |
@end{Reason} |
| 7095 |
|
| 7096 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]} |
| 7097 |
@ChgAdded{Version=[3],Text=[Set'Write for a Set object @i<S> writes |
| 7098 |
Length(@i<S>) elements of the set to the stream. It also may write |
| 7099 |
additional information about the set.]} |
| 7100 |
|
| 7101 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]} |
| 7102 |
@ChgAdded{Version=[3],Text=[Set'Read reads the representation of a set |
| 7103 |
from the stream, and assigns to @i<Item> a set with the same length and |
| 7104 |
elements as was written by Set'Write.]} |
| 7105 |
|
| 7106 |
@begin{Ramification} |
| 7107 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 7108 |
@ChgAdded{Version=[3],Text=[Streaming more elements than the container |
| 7109 |
length is wrong. For implementation implications of this rule, see the Implementation Note in |
| 7110 |
@RefSecNum{The Generic Package Containers.Vectors}.]} |
| 7111 |
@end{Ramification} |
| 7112 |
|
| 7113 |
@begin{DescribeCode} |
| 7114 |
|
| 7115 |
@begin{Example} |
| 7116 |
@ChgRef{Version=[3],Kind=[Added]} |
| 7117 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean;]} |
| 7118 |
@end{Example} |
| 7119 |
|
| 7120 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 7121 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns True if Position designates |
| 7122 |
an element, and returns False otherwise.]} |
| 7123 |
|
| 7124 |
@begin{Honest} |
| 7125 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1],ARef=[AI05-0212-1]} |
| 7126 |
@ChgAdded{Version=[3],Text=[This function might not detect cursors that |
| 7127 |
designate deleted elements; such cursors are invalid (see below) and the |
| 7128 |
result of calling Has_Element with an invalid cursor is unspecified (but |
| 7129 |
not erroneous).]} |
| 7130 |
@end{Honest} |
| 7131 |
|
| 7132 |
@begin{Example} |
| 7133 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7134 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "=" (Left, Right : Set) @key{return} Boolean;]} |
| 7135 |
@end{Example} |
| 7136 |
|
| 7137 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7138 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Left and Right denote the same |
| 7139 |
set object, then the function returns True. If Left and Right have different |
| 7140 |
lengths, then the function returns False. Otherwise, for each element @i<E> in |
| 7141 |
Left, the function returns False if an element equal to @i<E> (using |
| 7142 |
the generic formal equality operator) is not present in Right. If the function |
| 7143 |
has not returned a result after checking all of the elements, it returns True. |
| 7144 |
Any exception raised during evaluation of element equality is propagated.]} |
| 7145 |
@begin{ImplNote} |
| 7146 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7147 |
@ChgAdded{Version=[2],Text=[This wording describes the canonical semantics. |
| 7148 |
However, the order and number of calls on the formal equality function is |
| 7149 |
unspecified for all of the operations that use it in this package, so an |
| 7150 |
implementation can call it as many or as few times as it needs to get the |
| 7151 |
correct answer. Specifically, there is no requirement to call the formal |
| 7152 |
equality additional times once the answer has been determined.]} |
| 7153 |
@end{ImplNote} |
| 7154 |
|
| 7155 |
@begin{Example} |
| 7156 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7157 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Sets (Left, Right : Set) @key{return} Boolean;]} |
| 7158 |
@end{Example} |
| 7159 |
|
| 7160 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7161 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Left and Right denote the same |
| 7162 |
set object, then the function returns True. If Left and Right have different |
| 7163 |
lengths, then the function returns False. Otherwise, for each element @i<E> in |
| 7164 |
Left, the function returns False if an element equivalent to @i<E> is not |
| 7165 |
present in Right. If the function has not returned a result after checking all |
| 7166 |
of the elements, it returns True. Any exception raised during evaluation of |
| 7167 |
element equivalence is propagated.]} |
| 7168 |
|
| 7169 |
@begin{Example} |
| 7170 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7171 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} To_Set (New_Item : Element_Type) @key{return} Set;]} |
| 7172 |
@end{Example} |
| 7173 |
|
| 7174 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7175 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a set containing the single element New_Item.]} |
| 7176 |
|
| 7177 |
@begin{Example} |
| 7178 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7179 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Length (Container : Set) @key{return} Count_Type;]} |
| 7180 |
@end{Example} |
| 7181 |
|
| 7182 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7183 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the number of elements in |
| 7184 |
Container.]} |
| 7185 |
|
| 7186 |
@begin{Example} |
| 7187 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7188 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Is_Empty (Container : Set) @key{return} Boolean;]} |
| 7189 |
@end{Example} |
| 7190 |
|
| 7191 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7192 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Length (Container) = 0.]} |
| 7193 |
|
| 7194 |
@begin{Example} |
| 7195 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7196 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Clear (Container : @key{in out} Set);]} |
| 7197 |
@end{Example} |
| 7198 |
|
| 7199 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7200 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Removes all the elements from |
| 7201 |
Container.]} |
| 7202 |
|
| 7203 |
@begin{Example} |
| 7204 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7205 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Element (Position : Cursor) @key{return} Element_Type;]} |
| 7206 |
@end{Example} |
| 7207 |
|
| 7208 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7209 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 7210 |
Constraint_Error is propagated. Otherwise, Element returns the element |
| 7211 |
designated by Position.]} |
| 7212 |
|
| 7213 |
@begin{Example} |
| 7214 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7215 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace_Element (Container : @key{in out} Set; |
| 7216 |
Position : @key{in} Cursor; |
| 7217 |
New_Item : @key{in} Element_Type);]} |
| 7218 |
@end{Example} |
| 7219 |
|
| 7220 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7221 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 7222 |
Constraint_Error is propagated; if Position does not designate an element in |
| 7223 |
Container, then Program_Error is propagated. |
| 7224 |
If an element equivalent to New_Item is already present in Container at a |
| 7225 |
position other than Position, Program_Error is propagated. Otherwise, |
| 7226 |
Replace_Element assigns New_Item to the element designated by Position. Any |
| 7227 |
exception raised by the assignment is propagated.]} |
| 7228 |
|
| 7229 |
@begin{ImplNote} |
| 7230 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7231 |
@ChgAdded{Version=[2],Text=[The final assignment may require that the node of |
| 7232 |
the element be moved in the Set's data structures. That could mean that |
| 7233 |
implementing this operation exactly as worded above could require the |
| 7234 |
overhead of searching twice. Implementations are encouraged to avoid this |
| 7235 |
extra overhead when possible, by prechecking if the old element is equivalent |
| 7236 |
to the new one, by inserting a placeholder node while checking for an |
| 7237 |
equivalent element, and similar optimizations.]} |
| 7238 |
|
| 7239 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7240 |
@ChgAdded{Version=[2],Text=[The cursor still designates the same element |
| 7241 |
after this operation; only the value of that element has changed. Cursors |
| 7242 |
cannot include information about the relative position of an element in a |
| 7243 |
Set (as they must survive insertions and deletions of other elements), so |
| 7244 |
this should not pose an implementation hardship.]} |
| 7245 |
@end{ImplNote} |
| 7246 |
|
| 7247 |
@begin{Example} |
| 7248 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7249 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Query_Element |
| 7250 |
(Position : @key{in} Cursor; |
| 7251 |
Process : @key{not null access procedure} (Element : @key{in} Element_Type));]} |
| 7252 |
@end{Example} |
| 7253 |
|
| 7254 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7255 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1],ARef=[AI05-0265-1]} |
| 7256 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 7257 |
Constraint_Error is propagated. Otherwise, Query_Element calls |
| 7258 |
Process.@key{all} with the element designated by Position as the argument. |
| 7259 |
@Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 7260 |
is propagated if Process.@key{all} tampers]} |
| 7261 |
with the elements of @Chg{Version=[3],New=[the set that contains the |
| 7262 |
element designated by Position is prohibited during the |
| 7263 |
execution of the call on Process.@key{all}],Old=[Container]}. Any exception |
| 7264 |
raised by Process.@key{all} is propagated.]} |
| 7265 |
|
| 7266 |
@begin{Example} |
| 7267 |
@ChgRef{Version=[3],Kind=[Added]} |
| 7268 |
@ChgAdded{Version=[3],Text=[@key[type] Constant_Reference_Type |
| 7269 |
(Element : @key[not null access constant] Element_Type) @key[is private] |
| 7270 |
@key[with] Implicit_Dereference => Element;]} |
| 7271 |
@end{Example} |
| 7272 |
|
| 7273 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 7274 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[The type Constant_Reference_Type |
| 7275 |
needs finalization.@PDefn2{Term=<needs finalization>, |
| 7276 |
Sec=<language-defined type>}]} |
| 7277 |
|
| 7278 |
@ChgRef{Version=[3],Kind=[Added]} |
| 7279 |
@ChgAdded{Version=[3],Text=[The default initialization of an object of type |
| 7280 |
Constant_Reference_Type propagates Program_Error.]} |
| 7281 |
|
| 7282 |
@begin{Reason} |
| 7283 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 7284 |
@ChgAdded{Version=[3],Text=[It is expected that |
| 7285 |
Constant_Reference_Type will be a controlled type, for which finalization |
| 7286 |
will have some action to terminate the tampering check for the associated |
| 7287 |
container. If the object is created by default, however, there is no |
| 7288 |
associated container. Since this is useless, and supporting this case would |
| 7289 |
take extra work, we define it to raise an exception.]} |
| 7290 |
@end{Reason} |
| 7291 |
|
| 7292 |
@begin{Example} |
| 7293 |
@ChgRef{Version=[3],Kind=[Added]} |
| 7294 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] Set; |
| 7295 |
Position : @key[in] Cursor) |
| 7296 |
@key[return] Constant_Reference_Type;]} |
| 7297 |
@end{Example} |
| 7298 |
|
| 7299 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 7300 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 7301 |
Constant_Indexing and Implicit_Dereference aspects) provides a convenient way to |
| 7302 |
gain read access to an individual element of a set given a cursor.]} |
| 7303 |
|
| 7304 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]} |
| 7305 |
@ChgAdded{Version=[3],Text=[If Position equals No_Element, then Constraint_Error |
| 7306 |
is propagated; if Position does not designate an element in Container, then |
| 7307 |
Program_Error is propagated. Otherwise, Constant_Reference returns an object |
| 7308 |
whose discriminant is an access value that designates the element designated by |
| 7309 |
Position. Tampering with the elements of Container is prohibited while the |
| 7310 |
object returned by Constant_Reference exists and has not been finalized.]} |
| 7311 |
|
| 7312 |
@begin{Example} |
| 7313 |
@ChgRef{Version=[3],Kind=[Added]} |
| 7314 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key{procedure} Assign (Target : @key{in out} Set; Source : @key{in} Set);]} |
| 7315 |
@end{Example} |
| 7316 |
|
| 7317 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0248-1]} |
| 7318 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[If Target denotes the same object as Source, the operation has no |
| 7319 |
effect. Otherwise, the elements of Source are copied to Target as |
| 7320 |
for an @nt{assignment_statement} assigning Source to Target.]} |
| 7321 |
@begin{Discussion} |
| 7322 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1]} |
| 7323 |
@ChgAdded{Version=[3],Text=[This routine exists for compatibility with the |
| 7324 |
bounded set containers. For an unbounded set, @exam{Assign(A, B)} and |
| 7325 |
@exam{A := B} behave identically. For a bounded set, := will raise an |
| 7326 |
exception if the container capacities are different, while Assign will |
| 7327 |
not raise an exception if there is enough room in the target.]} |
| 7328 |
@end{Discussion} |
| 7329 |
|
| 7330 |
@begin{Example} |
| 7331 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7332 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Move (Target : @key{in out} Set; |
| 7333 |
Source : @key{in out} Set);]} |
| 7334 |
@end{Example} |
| 7335 |
|
| 7336 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7337 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0262-1]} |
| 7338 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Target denotes the same object |
| 7339 |
as Source, then @Chg{Version=[3],New=[the operation],Old=[Move]} |
| 7340 |
has no effect. Otherwise, @Chg{Version=[3],New=[the operation is equivalent |
| 7341 |
to Assign (Target, Source) followed by Clear (Source)],Old=[Move first clears |
| 7342 |
Target. Then, each element from Source is removed from Source and inserted into |
| 7343 |
Target. The length of Source is 0 after a successful call to Move]}.]} |
| 7344 |
|
| 7345 |
@begin{Example} |
| 7346 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7347 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Set; |
| 7348 |
New_Item : @key{in} Element_Type; |
| 7349 |
Position : @key{out} Cursor; |
| 7350 |
Inserted : @key{out} Boolean);]} |
| 7351 |
@end{Example} |
| 7352 |
|
| 7353 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7354 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Insert checks if an element |
| 7355 |
equivalent to New_Item is already present in Container. If a match is found, |
| 7356 |
Inserted is set to False and Position designates the matching element. |
| 7357 |
Otherwise, Insert adds New_Item to Container; Inserted is set to True and |
| 7358 |
Position designates the newly-inserted element. Any exception raised during |
| 7359 |
allocation is propagated and Container is not modified.]} |
| 7360 |
|
| 7361 |
@begin{Example} |
| 7362 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7363 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Set; |
| 7364 |
New_Item : @key{in} Element_Type);]} |
| 7365 |
@end{Example} |
| 7366 |
|
| 7367 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7368 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Insert inserts New_Item into |
| 7369 |
Container as per the four-parameter Insert, with the difference that if an |
| 7370 |
element equivalent to New_Item is already in the set, then Constraint_Error is |
| 7371 |
propagated.]} |
| 7372 |
|
| 7373 |
@begin{Discussion} |
| 7374 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7375 |
@ChgAdded{Version=[2],Type=[Leading],Text=[This is equivalent to:]} |
| 7376 |
@begin{Example} |
| 7377 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7378 |
@ChgAdded{Version=[2],Text=[@key{declare} |
| 7379 |
Inserted : Boolean; C : Cursor; |
| 7380 |
@key{begin} |
| 7381 |
Insert (Container, New_Item, C, Inserted); |
| 7382 |
@key{if not} Inserted @key{then} |
| 7383 |
@key{raise} Constraint_Error; |
| 7384 |
@key{end if}; |
| 7385 |
@key{end};]} |
| 7386 |
@end{Example} |
| 7387 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7388 |
@ChgAdded{Version=[2],Text=[but doesn't require the hassle of @key{out} |
| 7389 |
parameters.]} |
| 7390 |
@end{Discussion} |
| 7391 |
|
| 7392 |
@begin{Example} |
| 7393 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7394 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Include (Container : @key{in out} Set; |
| 7395 |
New_Item : @key{in} Element_Type);]} |
| 7396 |
@end{Example} |
| 7397 |
|
| 7398 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7399 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Include inserts New_Item into |
| 7400 |
Container as per the four-parameter Insert, with the difference that if an |
| 7401 |
element equivalent to New_Item is already in the set, then it is replaced. Any |
| 7402 |
exception raised during assignment is propagated.]} |
| 7403 |
|
| 7404 |
@begin{Example} |
| 7405 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7406 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace (Container : @key{in out} Set; |
| 7407 |
New_Item : @key{in} Element_Type);]} |
| 7408 |
@end{Example} |
| 7409 |
|
| 7410 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7411 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Replace checks if an element |
| 7412 |
equivalent to New_Item is already in the set. If a match is found, that element |
| 7413 |
is replaced with New_Item; otherwise, Constraint_Error is propagated.]} |
| 7414 |
|
| 7415 |
@begin{Example} |
| 7416 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7417 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Exclude (Container : @key{in out} Set; |
| 7418 |
Item : @key{in} Element_Type);]} |
| 7419 |
@end{Example} |
| 7420 |
|
| 7421 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7422 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Exclude checks if an element |
| 7423 |
equivalent to Item is present in Container. If a match is found, Exclude |
| 7424 |
removes the element from the set.]} |
| 7425 |
|
| 7426 |
@begin{Example} |
| 7427 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7428 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Set; |
| 7429 |
Item : @key{in} Element_Type);]} |
| 7430 |
@end{Example} |
| 7431 |
|
| 7432 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7433 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Delete checks if an element |
| 7434 |
equivalent to Item is present in Container. If a match is found, Delete removes |
| 7435 |
the element from the set; otherwise, Constraint_Error is propagated.]} |
| 7436 |
|
| 7437 |
@begin{Example} |
| 7438 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7439 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Set; |
| 7440 |
Position : @key{in out} Cursor);]} |
| 7441 |
@end{Example} |
| 7442 |
|
| 7443 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7444 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, |
| 7445 |
then Constraint_Error is propagated. If Position does not designate an element |
| 7446 |
in Container, then Program_Error is propagated. Otherwise, Delete removes the |
| 7447 |
element designated by Position from the set. Position is set to No_Element on |
| 7448 |
return.]} |
| 7449 |
|
| 7450 |
@begin{Ramification} |
| 7451 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7452 |
@ChgAdded{Version=[2],Text=[The check on Position checks that the cursor does |
| 7453 |
not belong to some other set. This check implies that a reference to the set |
| 7454 |
is included in the cursor value. This wording is not meant to require |
| 7455 |
detection of dangling cursors; such cursors are defined to be invalid, which |
| 7456 |
means that execution is erroneous, and any result is allowed (including not |
| 7457 |
raising an exception).]} |
| 7458 |
@end{Ramification} |
| 7459 |
|
| 7460 |
@begin{Example} |
| 7461 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7462 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Union (Target : @key{in out} Set; |
| 7463 |
Source : @key{in} Set);]} |
| 7464 |
@end{Example} |
| 7465 |
|
| 7466 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7467 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Union inserts into Target the |
| 7468 |
elements of Source that are not equivalent to some element already in Target.]} |
| 7469 |
|
| 7470 |
@begin{ImplNote} |
| 7471 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7472 |
@ChgAdded{Version=[2],Text=[If the objects are the same, the result is the |
| 7473 |
same as the original object. The implementation needs to take care so that |
| 7474 |
aliasing effects do not make the result trash; Union (S, S); must work.]} |
| 7475 |
@end{ImplNote} |
| 7476 |
|
| 7477 |
|
| 7478 |
@begin{Example} |
| 7479 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7480 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Union (Left, Right : Set) @key{return} Set;]} |
| 7481 |
@end{Example} |
| 7482 |
|
| 7483 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7484 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a set comprising all of the |
| 7485 |
elements of Left, and the elements of Right that are not equivalent to some |
| 7486 |
element of Left.]} |
| 7487 |
|
| 7488 |
@begin{Example} |
| 7489 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7490 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Intersection (Target : @key{in out} Set; |
| 7491 |
Source : @key{in} Set);]} |
| 7492 |
@end{Example} |
| 7493 |
|
| 7494 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7495 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0004-1]} |
| 7496 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[Intersection],Old=[Union]} deletes from Target the |
| 7497 |
elements of Target that are not equivalent to some element of Source.]} |
| 7498 |
|
| 7499 |
@begin{ImplNote} |
| 7500 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7501 |
@ChgAdded{Version=[2],Text=[If the objects are the same, the result is the |
| 7502 |
same as the original object. The implementation needs to take care so that |
| 7503 |
aliasing effects do not make the result trash; Intersection (S, S); must |
| 7504 |
work.]} |
| 7505 |
@end{ImplNote} |
| 7506 |
|
| 7507 |
@begin{Example} |
| 7508 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7509 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Intersection (Left, Right : Set) @key{return} Set;]} |
| 7510 |
@end{Example} |
| 7511 |
|
| 7512 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7513 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a set comprising all the |
| 7514 |
elements of Left that are equivalent to the some element of Right.]} |
| 7515 |
|
| 7516 |
@begin{Example} |
| 7517 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7518 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Difference (Target : @key{in out} Set; |
| 7519 |
Source : @key{in} Set);]} |
| 7520 |
@end{Example} |
| 7521 |
|
| 7522 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7523 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Target denotes the same object |
| 7524 |
as Source, then Difference clears Target. Otherwise, it deletes from Target the |
| 7525 |
elements that are equivalent to some element of Source.]} |
| 7526 |
|
| 7527 |
@begin{Example} |
| 7528 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7529 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Difference (Left, Right : Set) @key{return} Set;]} |
| 7530 |
@end{Example} |
| 7531 |
|
| 7532 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7533 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a set comprising the |
| 7534 |
elements of Left that are not equivalent to some element of Right.]} |
| 7535 |
|
| 7536 |
@begin{Example} |
| 7537 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7538 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Symmetric_Difference (Target : @key{in out} Set; |
| 7539 |
Source : @key{in} Set);]} |
| 7540 |
@end{Example} |
| 7541 |
|
| 7542 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7543 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Target denotes the same object |
| 7544 |
as Source, then Symmetric_Difference clears Target. Otherwise, it deletes from |
| 7545 |
Target the elements that are equivalent to some element of Source, and inserts |
| 7546 |
into Target the elements of Source that are not equivalent to some element of |
| 7547 |
Target.]} |
| 7548 |
|
| 7549 |
@begin{Example} |
| 7550 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7551 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Symmetric_Difference (Left, Right : Set) @key{return} Set;]} |
| 7552 |
@end{Example} |
| 7553 |
|
| 7554 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7555 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a set comprising the |
| 7556 |
elements of Left that are not equivalent to some element of Right, and the |
| 7557 |
elements of Right that are not equivalent to some element of Left.]} |
| 7558 |
|
| 7559 |
@begin{Example} |
| 7560 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7561 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Overlap (Left, Right : Set) @key{return} Boolean;]} |
| 7562 |
@end{Example} |
| 7563 |
|
| 7564 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7565 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 7566 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If an element of Left is equivalent |
| 7567 |
to some element of Right, then Overlap returns True. |
| 7568 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} it returns False.]} |
| 7569 |
|
| 7570 |
@begin{Discussion} |
| 7571 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7572 |
@ChgAdded{Version=[2],Text=[This operation is commutative. If Overlap returns |
| 7573 |
False, the two sets are disjoint.]} |
| 7574 |
@end{Discussion} |
| 7575 |
|
| 7576 |
@begin{Example} |
| 7577 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7578 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Is_Subset (Subset : Set; |
| 7579 |
Of_Set : Set) @key{return} Boolean;]} |
| 7580 |
@end{Example} |
| 7581 |
|
| 7582 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7583 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 7584 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If an element of Subset is not |
| 7585 |
equivalent to some element of Of_Set, then Is_Subset returns False. |
| 7586 |
Otherwise@Chg{Version=[3],New=[,],Old=[]} it returns True.]} |
| 7587 |
|
| 7588 |
@begin{Discussion} |
| 7589 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7590 |
@ChgAdded{Version=[2],Text=[This operation is not commutative, so we use |
| 7591 |
parameter names that make it clear in named notation which set is which.]} |
| 7592 |
@end{Discussion} |
| 7593 |
|
| 7594 |
@begin{Example} |
| 7595 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7596 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First (Container : Set) @key{return} Cursor;]} |
| 7597 |
@end{Example} |
| 7598 |
|
| 7599 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7600 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Length (Container) = 0, then |
| 7601 |
First returns No_Element. Otherwise, First returns a cursor that designates the |
| 7602 |
first element in Container.]} |
| 7603 |
|
| 7604 |
@begin{Example} |
| 7605 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7606 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Next (Position : Cursor) @key{return} Cursor;]} |
| 7607 |
@end{Example} |
| 7608 |
|
| 7609 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7610 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a cursor that designates the successor of the element |
| 7611 |
designated by Position. If Position designates the last element, then |
| 7612 |
No_Element is returned. If Position equals No_Element, then No_Element is |
| 7613 |
returned.]} |
| 7614 |
|
| 7615 |
@begin{Example} |
| 7616 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7617 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Next (Position : @key{in out} Cursor);]} |
| 7618 |
@end{Example} |
| 7619 |
|
| 7620 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7621 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Next (Position).]} |
| 7622 |
|
| 7623 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7624 |
@ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0004-1]} |
| 7625 |
@ChgDeleted{Version=[3],Type=[Trailing],Text=[@Chg{Version=[2],New=[Equivalent to Find (Container, Item) /= No_Element.],Old=[]}]} |
| 7626 |
|
| 7627 |
@begin{Example} |
| 7628 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7629 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Find (Container : Set; |
| 7630 |
Item : Element_Type) @key{return} Cursor;]} |
| 7631 |
@end{Example} |
| 7632 |
|
| 7633 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7634 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Length (Container) equals 0, |
| 7635 |
then Find returns No_Element. Otherwise, Find checks if an element equivalent |
| 7636 |
to Item is present in Container. If a match is found, a cursor designating the |
| 7637 |
matching element is returned; otherwise, No_Element is returned.]} |
| 7638 |
|
| 7639 |
@begin{Example} |
| 7640 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7641 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Contains (Container : Set; |
| 7642 |
Item : Element_Type) @key{return} Boolean;]} |
| 7643 |
@end{Example} |
| 7644 |
|
| 7645 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0004-1]} |
| 7646 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Equivalent to Find (Container, Item) /= No_Element.]} |
| 7647 |
|
| 7648 |
@begin{Example} |
| 7649 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7650 |
@ChgRef{Version=[3],Kind=[DeletedNoDelMsg]} |
| 7651 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@Chg{Version=[3],New=[],Old=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean;]}]} |
| 7652 |
@end{Example} |
| 7653 |
|
| 7654 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7655 |
@ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]} |
| 7656 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[],Old=[Returns True if Position designates |
| 7657 |
an element, and returns False otherwise.]}]} |
| 7658 |
|
| 7659 |
@begin{Honest} |
| 7660 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7661 |
@ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]} |
| 7662 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[This function may not detect cursors that |
| 7663 |
designate deleted elements; such cursors are invalid (see below) and the |
| 7664 |
result of calling Has_Element with an invalid cursor is unspecified (but |
| 7665 |
not erroneous).]}]} |
| 7666 |
@end{Honest} |
| 7667 |
@begin{NotIso} |
| 7668 |
@ChgAdded{Version=[3],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 83 and 84 |
| 7669 |
were moved above.>}]}@Comment{This message should be |
| 7670 |
deleted if the paragraphs are ever renumbered.} |
| 7671 |
@end{NotIso} |
| 7672 |
|
| 7673 |
@begin{Example} |
| 7674 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7675 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Iterate |
| 7676 |
(Container : @key{in} Set; |
| 7677 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 7678 |
@end{Example} |
| 7679 |
|
| 7680 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7681 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]} |
| 7682 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Iterate calls Process.@key{all} |
| 7683 |
with a cursor that designates each element in Container, starting with the |
| 7684 |
first element and moving the cursor according to the successor relation. |
| 7685 |
@Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 7686 |
is propagated if Process.@key{all} tampers]} |
| 7687 |
with the cursors of Container@Chg{Version=[3],New=[ is prohibited during the |
| 7688 |
execution of a call on Process.@key{all}],Old=[]}. Any exception raised by |
| 7689 |
Process.@key{all} is propagated.]} |
| 7690 |
|
| 7691 |
@begin{ImplNote} |
| 7692 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7693 |
@ChgAdded{Version=[2],Text=[The @lquotes@;tamper with cursors@rquotes@; |
| 7694 |
check takes place when the operations that insert or delete elements, and |
| 7695 |
so on are called.]} |
| 7696 |
|
| 7697 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7698 |
@ChgAdded{Version=[2],Text=[See Iterate for vectors |
| 7699 |
(@RefSecNum{The Generic Package Containers.Vectors}) for a suggested |
| 7700 |
implementation of the check.]} |
| 7701 |
@end{ImplNote} |
| 7702 |
|
| 7703 |
@end{DescribeCode} |
| 7704 |
|
| 7705 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7706 |
@ChgAdded{Version=[2],Text=[Both Containers.Hashed_Set and |
| 7707 |
Containers.Ordered_Set declare a nested generic package Generic_Keys, which |
| 7708 |
provides operations that allow set manipulation in terms of a key (typically, a |
| 7709 |
portion of an element) instead of a complete element. The formal function Key |
| 7710 |
of Generic_Keys extracts a key value from an element. It is expected to return |
| 7711 |
the same value each time it is called with a particular element. The behavior |
| 7712 |
of Generic_Keys is unspecified if Key behaves in some other |
| 7713 |
manner.@PDefn{unspecified}]} |
| 7714 |
|
| 7715 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7716 |
@ChgAdded{Version=[2],Text=[A key is expected to unambiguously determine a |
| 7717 |
single equivalence class for elements. The behavior of Generic_Keys is |
| 7718 |
unspecified if the formal parameters of this package behave in some other |
| 7719 |
manner.@PDefn{unspecified}]} |
| 7720 |
|
| 7721 |
@begin{DescribeCode} |
| 7722 |
@begin{Example} |
| 7723 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7724 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Key (Position : Cursor) @key{return} Key_Type;]} |
| 7725 |
@end{Example} |
| 7726 |
|
| 7727 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7728 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (Element (Position)).]} |
| 7729 |
@end{DescribeCode} |
| 7730 |
|
| 7731 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7732 |
@ChgAdded{Version=[2],Text=[The subprograms in package Generic_Keys named |
| 7733 |
Contains, Find, Element, Delete, and Exclude, are equivalent to the |
| 7734 |
corresponding subprograms in the parent package, with the difference that the |
| 7735 |
Key parameter is used to locate an element in the set.]} |
| 7736 |
|
| 7737 |
@begin{DescribeCode} |
| 7738 |
@begin{Example} |
| 7739 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7740 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace (Container : @key{in out} Set; |
| 7741 |
Key : @key{in} Key_Type; |
| 7742 |
New_Item : @key{in} Element_Type);]} |
| 7743 |
@end{Example} |
| 7744 |
|
| 7745 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7746 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Replace_Element (Container, Find (Container, Key), New_Item).]} |
| 7747 |
|
| 7748 |
@begin{Example} |
| 7749 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7750 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Update_Element_Preserving_Key |
| 7751 |
(Container : @key{in out} Set; |
| 7752 |
Position : @key{in} Cursor; |
| 7753 |
Process : @key{not null access procedure} |
| 7754 |
(Element : @key{in out} Element_Type));]} |
| 7755 |
@end{Example} |
| 7756 |
|
| 7757 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7758 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]} |
| 7759 |
@ChgAdded{Version=[2],Text=[If Position equals No_Element, then |
| 7760 |
Constraint_Error is propagated; if Position does not designate an element in |
| 7761 |
Container, then Program_Error is propagated. Otherwise, |
| 7762 |
Update_@!Element_@!Preserving_Key uses Key to save the key value @i<K> of the |
| 7763 |
element designated by Position. Update_@!Element_@!Preserving_Key then calls |
| 7764 |
Process.@key{all} with that element as the argument. |
| 7765 |
@Chg{Version=[3],New=[Tampering],Old=[Program_Error |
| 7766 |
is propagated if Process.@key{all} tampers]} |
| 7767 |
with the elements of Container@Chg{Version=[3],New=[ is prohibited during the |
| 7768 |
execution of the call on Process.@key{all}],Old=[]}. Any |
| 7769 |
exception raised by Process.@key{all} is propagated. After Process.@key{all} |
| 7770 |
returns, Update_@!Element_@!Preserving_Key checks if @i<K> determines the same |
| 7771 |
equivalence class as that for the new element; if not, the element is removed |
| 7772 |
from the set and Program_Error is propagated.]} |
| 7773 |
|
| 7774 |
@begin{Reason} |
| 7775 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7776 |
@ChgAdded{Version=[2],Text=[The key check ensures that the invariants of |
| 7777 |
the set are preserved by the modification. The @lquotes@;tampers with |
| 7778 |
the elements@rquotes@; check prevents data loss (if Element_Type is by-copy) |
| 7779 |
or erroneous execution (if element type is unconstrained and indefinite).]} |
| 7780 |
@end{Reason} |
| 7781 |
|
| 7782 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7783 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Element_Type is unconstrained |
| 7784 |
and definite, then the actual Element parameter of Process.@key{all} shall be |
| 7785 |
unconstrained.]} |
| 7786 |
|
| 7787 |
@begin{Ramification} |
| 7788 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7789 |
@ChgAdded{Version=[2],Text=[This means that the elements cannot be |
| 7790 |
directly allocated from the heap; it must be possible to change the |
| 7791 |
discriminants of the element in place.]} |
| 7792 |
@end{Ramification} |
| 7793 |
|
| 7794 |
@begin{Example} |
| 7795 |
@ChgRef{Version=[3],Kind=[Added]} |
| 7796 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[type] Reference_Type (Element : @key[not null access] Element_Type) @key[is private] |
| 7797 |
@key[with] Implicit_Dereference => Element;]} |
| 7798 |
@end{Example} |
| 7799 |
|
| 7800 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 7801 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[The type Reference_Type needs |
| 7802 |
finalization.@PDefn2{Term=<needs finalization>, |
| 7803 |
Sec=<language-defined type>}]} |
| 7804 |
|
| 7805 |
@ChgRef{Version=[3],Kind=[Added]} |
| 7806 |
@ChgAdded{Version=[3],Text=[The default initialization of an object of type |
| 7807 |
Reference_Type propagates Program_Error.]} |
| 7808 |
|
| 7809 |
@begin{Example} |
| 7810 |
@ChgRef{Version=[3],Kind=[Added]} |
| 7811 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference_Preserving_Key (Container : @key[aliased in out] Set; |
| 7812 |
Position : @key[in] Cursor) |
| 7813 |
@key[return] Reference_Type;]} |
| 7814 |
@end{Example} |
| 7815 |
|
| 7816 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 7817 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 7818 |
Implicit_Dereference aspect) provides a convenient way to |
| 7819 |
gain read and write access to an individual element of a set given a cursor.]} |
| 7820 |
|
| 7821 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]} |
| 7822 |
@ChgAdded{Version=[3],Text=[If Position equals No_Element, then Constraint_Error |
| 7823 |
is propagated; if Position does not designate an element in Container, then |
| 7824 |
Program_Error is propagated. Otherwise, Reference_Preserving_Key uses Key to |
| 7825 |
save the key value @i<K>; then returns an object whose discriminant is an access |
| 7826 |
value that designates the element designated by |
| 7827 |
Position. Tampering with the elements of Container is prohibited while the |
| 7828 |
object returned by Reference_Preserving_Key exists and has not been finalized. |
| 7829 |
When the object returned by Reference_Preserving_Key is finalized, a check is |
| 7830 |
made if @i<K> determines the same equivalence class as that for the new element; |
| 7831 |
if not, the element is removed from the set and Program_Error is propagated.]} |
| 7832 |
|
| 7833 |
@begin{Example} |
| 7834 |
@ChgRef{Version=[3],Kind=[Added]} |
| 7835 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] Set; |
| 7836 |
Key : @key[in] Key_Type) |
| 7837 |
@key[return] Constant_Reference_Type;]} |
| 7838 |
@end{Example} |
| 7839 |
|
| 7840 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 7841 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 7842 |
Implicit_Dereference aspect) provides a convenient way to |
| 7843 |
gain read access to an individual element of a set given a key value.]} |
| 7844 |
|
| 7845 |
@ChgRef{Version=[3],Kind=[Added]} |
| 7846 |
@ChgAdded{Version=[3],Text=[Equivalent to |
| 7847 |
Constant_Reference (Container, Find (Container, Key)).]} |
| 7848 |
|
| 7849 |
@begin{Example} |
| 7850 |
@ChgRef{Version=[3],Kind=[Added]} |
| 7851 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference_Preserving_Key (Container : @key[aliased in out] Set; |
| 7852 |
Key : @key[in] Key_Type) |
| 7853 |
@key[return] Reference_Type;]} |
| 7854 |
@end{Example} |
| 7855 |
|
| 7856 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]} |
| 7857 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the |
| 7858 |
Implicit_Dereference aspect) provides a convenient way to gain |
| 7859 |
read and write access to an individual element of a set given a key value.]} |
| 7860 |
|
| 7861 |
@ChgRef{Version=[3],Kind=[Added]} |
| 7862 |
@ChgAdded{Version=[3],Text=[Equivalent to Reference_Preserving_Key (Container, Find (Container, Key)).]} |
| 7863 |
@end{DescribeCode} |
| 7864 |
|
| 7865 |
@end{StaticSem} |
| 7866 |
|
| 7867 |
@begin{Bounded} |
| 7868 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0022-1],ARef=[AI05-0248-1]} |
| 7869 |
@ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)} |
| 7870 |
It is a bounded error for the actual function |
| 7871 |
associated with a generic formal subprogram, when called as part of an |
| 7872 |
operation of a set package, to tamper with elements of any set parameter of |
| 7873 |
the operation. Either Program_Error is raised, or the operation works as |
| 7874 |
defined on the value of the set either prior to, or subsequent to, some or |
| 7875 |
all of the modifications to the set.]} |
| 7876 |
|
| 7877 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0027-1]} |
| 7878 |
@ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)} |
| 7879 |
It is a bounded error to call any subprogram |
| 7880 |
declared in the visible part of a set package |
| 7881 |
when the associated container has been finalized. If the operation takes |
| 7882 |
Container as an @key[in out] parameter, then it raises Constraint_Error or |
| 7883 |
Program_Error. Otherwise, the operation either proceeds as it would |
| 7884 |
for an empty container, or it raises Constraint_Error or Program_Error.]} |
| 7885 |
@end{Bounded} |
| 7886 |
|
| 7887 |
@begin{Erron} |
| 7888 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7889 |
@ChgAdded{Version=[2],Type=[Leading],Text=[ |
| 7890 |
A Cursor value is @i<invalid> if any of the following have occurred since it was |
| 7891 |
created:@Defn2{Term=[invalid cursor],Sec=[of a set]} |
| 7892 |
@PDefn2{Term=[cursor],Sec=[invalid]}]} |
| 7893 |
|
| 7894 |
@begin{Itemize} |
| 7895 |
|
| 7896 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7897 |
@ChgAdded{Version=[2],Text=[The set that contains the element it designates |
| 7898 |
has been finalized;]} |
| 7899 |
|
| 7900 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0160-1]} |
| 7901 |
@ChgAdded{Version=[3],Text=[The set that contains the element it designates has been used as the Target of |
| 7902 |
a call to Assign, or as the target of an @nt{assignment_statement};]} |
| 7903 |
|
| 7904 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7905 |
@ChgAdded{Version=[2],Text=[The set that contains the element it designates |
| 7906 |
has been used as the Source or Target of a call to Move; or]} |
| 7907 |
|
| 7908 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7909 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0160-1],ARef=[AI05-0262-1]} |
| 7910 |
@ChgAdded{Version=[2],Text=[The element it designates has been |
| 7911 |
@Chg{Version=[3],New=[removed],Old=[deleted]} from the |
| 7912 |
set@Chg{Version=[3],New=[ that previously contained the element],Old=[]}.]} |
| 7913 |
@begin{Ramification} |
| 7914 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]} |
| 7915 |
@ChgAdded{Version=[3],Text=[This can happen directly via calls to Clear, |
| 7916 |
Exclude, Delete, and Update_Element_Preserving_Key, and indirectly via calls |
| 7917 |
to procedures Intersection, Difference, and Symmetric_Difference.]} |
| 7918 |
@end{Ramification} |
| 7919 |
|
| 7920 |
@end{Itemize} |
| 7921 |
|
| 7922 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7923 |
@ChgAdded{Version=[2],Text=[The result of "=" or Has_Element is |
| 7924 |
unspecified if these functions are called with an invalid cursor |
| 7925 |
parameter.@PDefn{unspecified} Execution is erroneous if any other subprogram |
| 7926 |
declared in Containers.Hashed_Sets or Containers.Ordered_Sets is called with an |
| 7927 |
invalid cursor parameter.@PDefn2{Term=(erroneous execution),Sec=(cause)}]} |
| 7928 |
|
| 7929 |
@begin{Discussion} |
| 7930 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7931 |
@ChgAdded{Version=[2],Text=[The list above is intended to be |
| 7932 |
exhaustive. In other cases, a cursor value continues to designate its |
| 7933 |
original element. For instance, cursor values survive the insertion and |
| 7934 |
deletion of other elements.]} |
| 7935 |
|
| 7936 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7937 |
@ChgAdded{Version=[2],Text=[While it is possible to check for these cases, in |
| 7938 |
many cases the overhead necessary to make the check is substantial in time or |
| 7939 |
space. Implementations are encouraged to check for as many of these cases as |
| 7940 |
possible and raise Program_Error if detected.]} |
| 7941 |
@end{Discussion} |
| 7942 |
|
| 7943 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 7944 |
@ChgAdded{Version=[3],Text=[Execution is erroneous if the set associated with |
| 7945 |
the result of a call to Reference or Constant_Reference is finalized before the |
| 7946 |
result object returned by the call to Reference or Constant_Reference is |
| 7947 |
finalized.]} |
| 7948 |
@begin{Reason} |
| 7949 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 7950 |
@ChgAdded{Version=[3],Text=[Each object of Reference_Type and |
| 7951 |
Constant_Reference_Type probably contains some reference to the originating |
| 7952 |
container. If that container is prematurely finalized (which is only possible |
| 7953 |
via Unchecked_Deallocation, as accessibility checks prevent passing a |
| 7954 |
container to Reference that will not live as long as the result), the |
| 7955 |
finalization of the object of Reference_Type will try to access a nonexistent |
| 7956 |
object. This is a normal case of a dangling pointer created by |
| 7957 |
Unchecked_Deallocation; we have to explicitly mention it here as the pointer |
| 7958 |
in question is not visible in the specification of the type. (This is the same |
| 7959 |
reason we have to say this for invalid cursors.)]} |
| 7960 |
@end{Reason} |
| 7961 |
@end{Erron} |
| 7962 |
|
| 7963 |
@begin{ImplReq} |
| 7964 |
|
| 7965 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7966 |
@ChgAdded{Version=[2],Text=[No storage associated with a Set object shall be |
| 7967 |
lost upon assignment or scope exit.]} |
| 7968 |
|
| 7969 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7970 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]} |
| 7971 |
@ChgAdded{Version=[2],Text=[The execution of an @nt{assignment_statement} for |
| 7972 |
a set shall have the effect of copying the elements from the source set |
| 7973 |
object to the target set object@Chg{Version=[3],New=[ and changing the length |
| 7974 |
of the target object to that of the source object],Old=[]}.]} |
| 7975 |
|
| 7976 |
@begin{ImplNote} |
| 7977 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 7978 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0298-1]} |
| 7979 |
@ChgAdded{Version=[2],Text=[An assignment of a Set is a @lquotes@;deep@rquotes |
| 7980 |
copy; that is the elements are copied as well as the data structures. |
| 7981 |
We say @lquotes@;effect of@rquotes in order to allow the implementation to |
| 7982 |
avoid copying elements immediately if it wishes. For instance, an |
| 7983 |
implementation that avoided copying until one of the containers is modified |
| 7984 |
would be allowed.@Chg{Version=[3],New=[ (Note that this implementation would |
| 7985 |
require care, see @RefSecNum{The Generic Package Containers.Vectors} for more.)],Old=[]}]} |
| 7986 |
@end{ImplNote} |
| 7987 |
|
| 7988 |
@end{ImplReq} |
| 7989 |
|
| 7990 |
@begin{ImplAdvice} |
| 7991 |
|
| 7992 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 7993 |
@ChgAdded{Version=[2],Text=[Move should not copy elements, and should minimize |
| 7994 |
copying of internal data structures.]} |
| 7995 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 7996 |
Text=[Move for sets should not copy elements, and should minimize |
| 7997 |
copying of internal data structures.]}]} |
| 7998 |
|
| 7999 |
@begin{ImplNote} |
| 8000 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8001 |
@ChgAdded{Version=[2],Text=[Usually that can be accomplished simply by |
| 8002 |
moving the pointer(s) to the internal data structures from the Source |
| 8003 |
container to the Target container.]} |
| 8004 |
@end{ImplNote} |
| 8005 |
|
| 8006 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8007 |
@ChgAdded{Version=[2],Text=[If an exception is propagated from a set |
| 8008 |
operation, no storage should be lost, nor any elements removed from a set |
| 8009 |
unless specified by the operation.]} |
| 8010 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 8011 |
Text=[If an exception is propagated from a set |
| 8012 |
operation, no storage should be lost, nor any elements removed from a set |
| 8013 |
unless specified by the operation.]}]} |
| 8014 |
|
| 8015 |
@begin{Reason} |
| 8016 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8017 |
@ChgAdded{Version=[2],Text=[This is important so that programs can recover |
| 8018 |
from errors. But we don't want to require heroic efforts, so we just require |
| 8019 |
documentation of cases where this can't be accomplished.]} |
| 8020 |
@end{Reason} |
| 8021 |
|
| 8022 |
@end{ImplAdvice} |
| 8023 |
|
| 8024 |
@begin{DiffWord95} |
| 8025 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8026 |
@ChgAdded{Version=[2],Text=[This description of sets is new; the |
| 8027 |
extensions are documented with the specific packages.]} |
| 8028 |
@end{DiffWord95} |
| 8029 |
|
| 8030 |
@begin{Extend2005} |
| 8031 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]} |
| 8032 |
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005} |
| 8033 |
Added reference support to make set containers more |
| 8034 |
convenient to use.]} |
| 8035 |
@end{Extend2005} |
| 8036 |
|
| 8037 |
@begin{DiffWord2005} |
| 8038 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 8039 |
@ChgAdded{Version=[3],Text=[Added procedure Assign; |
| 8040 |
the extension and incompatibility is documented with the specific packages.]} |
| 8041 |
|
| 8042 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 8043 |
@ChgAdded{Version=[3],Text=[Generalized the definition |
| 8044 |
of Move. Specified which elements are read/written by stream attributes.]} |
| 8045 |
|
| 8046 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0022-1]} |
| 8047 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName |
| 8048 |
to cover tampering by generic actual subprograms.]} |
| 8049 |
|
| 8050 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0027-1]} |
| 8051 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName |
| 8052 |
to cover access to finalized set containers.]} |
| 8053 |
|
| 8054 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]} |
| 8055 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Revised the definition |
| 8056 |
of invalid cursors to cover missing (and new) cases.]} |
| 8057 |
|
| 8058 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0265-1]} |
| 8059 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Defined when a container |
| 8060 |
prohibits tampering in order to more clearly define where the check is |
| 8061 |
made and the exception raised.]} |
| 8062 |
@end{DiffWord2005} |
| 8063 |
|
| 8064 |
@begin{DiffWord2012} |
| 8065 |
@ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0110-1]} |
| 8066 |
@ChgAdded{Version=[4],Text=[@b<Corrigendum:> Clarified that tampering checks |
| 8067 |
precede all other checks made by a subprogram (but come after those associated |
| 8068 |
with the call).]} |
| 8069 |
@end{DiffWord2012} |
| 8070 |
|
| 8071 |
|
| 8072 |
@LabeledAddedSubclause{Version=[2],Name=[The Generic Package Containers.Hashed_Sets]} |
| 8073 |
|
| 8074 |
@begin{StaticSem} |
| 8075 |
|
| 8076 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8077 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library |
| 8078 |
package Containers.Hashed_Sets has the following declaration:]} |
| 8079 |
@begin{Example} |
| 8080 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8081 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0084-1],ARef=[AI05-0212-1]} |
| 8082 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[@key[with] Ada.Iterator_Interfaces; |
| 8083 |
],Old=[]}@key{generic} |
| 8084 |
@key{type} Element_Type @key{is private}; |
| 8085 |
@key{with function} Hash (Element : Element_Type) @key{return} Hash_Type; |
| 8086 |
@key{with function} Equivalent_Elements (Left, Right : Element_Type) |
| 8087 |
@key{return} Boolean; |
| 8088 |
@key{with function} "=" (Left, Right : Element_Type) @key{return} Boolean @key{is} <>; |
| 8089 |
@key{package} Ada.Containers.Hashed_Sets @key{is}@ChildUnit{Parent=[Ada.Containers],Child=[Hashed_Sets]} |
| 8090 |
@key{pragma} Preelaborate(Hashed_Sets);@Chg{Version=[3],New=[ |
| 8091 |
@key{pragma} Remote_Types(Hashed_Sets);],Old=[]}]} |
| 8092 |
|
| 8093 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8094 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]} |
| 8095 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Set} @key{is tagged private}@Chg{Version=[3],New=[ |
| 8096 |
@key[with] Constant_Indexing => Constant_Reference, |
| 8097 |
Default_Iterator => Iterate, |
| 8098 |
Iterator_Element => Element_Type],Old=[]}; |
| 8099 |
@key{pragma} Preelaborable_Initialization(Set);]} |
| 8100 |
|
| 8101 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8102 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private}; |
| 8103 |
@key{pragma} Preelaborable_Initialization(Cursor);]} |
| 8104 |
|
| 8105 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8106 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{Empty_Set} : @key{constant} Set;]} |
| 8107 |
|
| 8108 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8109 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]} |
| 8110 |
|
| 8111 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8112 |
@ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]} |
| 8113 |
|
| 8114 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8115 |
@ChgAdded{Version=[3],Text=[ @key[package] @AdaPackDefn{Set_Iterator_Interfaces} @key[is new] |
| 8116 |
Ada.Iterator_Interfaces (Cursor, Has_Element);]} |
| 8117 |
|
| 8118 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8119 |
@ChgAdded{Version=[2],Text=[ @key{function} "=" (Left, Right : Set) @key{return} Boolean;]} |
| 8120 |
|
| 8121 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8122 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Sets} (Left, Right : Set) @key{return} Boolean;]} |
| 8123 |
|
| 8124 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8125 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{To_Set} (New_Item : Element_Type) @key{return} Set;]} |
| 8126 |
|
| 8127 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8128 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Capacity} (Container : Set) @key{return} Count_Type;]} |
| 8129 |
|
| 8130 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8131 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reserve_Capacity} (Container : @key{in out} Set; |
| 8132 |
Capacity : @key{in} Count_Type);]} |
| 8133 |
|
| 8134 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8135 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Length} (Container : Set) @key{return} Count_Type;]} |
| 8136 |
|
| 8137 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8138 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Empty} (Container : Set) @key{return} Boolean;]} |
| 8139 |
|
| 8140 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8141 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Clear} (Container : @key{in out} Set);]} |
| 8142 |
|
| 8143 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8144 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Position : Cursor) @key{return} Element_Type;]} |
| 8145 |
|
| 8146 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8147 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} Set; |
| 8148 |
Position : @key{in} Cursor; |
| 8149 |
New_Item : @key{in} Element_Type);]} |
| 8150 |
|
| 8151 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8152 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element} |
| 8153 |
(Position : @key{in} Cursor; |
| 8154 |
Process : @key{not null access procedure} (Element : @key{in} Element_Type));]} |
| 8155 |
|
| 8156 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8157 |
@ChgAdded{Version=[3],Text=[ @key[type] Constant_Reference_Type |
| 8158 |
(Element : @key[not null access constant] Element_Type) @key[is private] |
| 8159 |
@key[with] Implicit_Dereference => Element;]} |
| 8160 |
|
| 8161 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8162 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Set; |
| 8163 |
Position : @key[in] Cursor) |
| 8164 |
@key[return] Constant_Reference_Type;]} |
| 8165 |
|
| 8166 |
@ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]} |
| 8167 |
@ChgAdded{Version=[3],Text=[ @key[procedure] @AdaSubDefn{Assign} (Target : @key[in out] Set; Source : @key[in] Set);]} |
| 8168 |
|
| 8169 |
@ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]} |
| 8170 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Copy} (Source : Set; Capacity : Count_Type := 0) @key[return] Set;]} |
| 8171 |
|
| 8172 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8173 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Move} (Target : @key{in out} Set; |
| 8174 |
Source : @key{in out} Set);]} |
| 8175 |
|
| 8176 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8177 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Set; |
| 8178 |
New_Item : @key{in} Element_Type; |
| 8179 |
Position : @key{out} Cursor; |
| 8180 |
Inserted : @key{out} Boolean);]} |
| 8181 |
|
| 8182 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8183 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Set; |
| 8184 |
New_Item : @key{in} Element_Type);]} |
| 8185 |
|
| 8186 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8187 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Include} (Container : @key{in out} Set; |
| 8188 |
New_Item : @key{in} Element_Type);]} |
| 8189 |
|
| 8190 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8191 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace} (Container : @key{in out} Set; |
| 8192 |
New_Item : @key{in} Element_Type);]} |
| 8193 |
|
| 8194 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8195 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Exclude} (Container : @key{in out} Set; |
| 8196 |
Item : @key{in} Element_Type);]} |
| 8197 |
|
| 8198 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8199 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Set; |
| 8200 |
Item : @key{in} Element_Type);]} |
| 8201 |
|
| 8202 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8203 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Set; |
| 8204 |
Position : @key{in out} Cursor);]} |
| 8205 |
|
| 8206 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8207 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Union} (Target : @key{in out} Set; |
| 8208 |
Source : @key{in} Set);]} |
| 8209 |
|
| 8210 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8211 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Union} (Left, Right : Set) @key{return} Set;]} |
| 8212 |
|
| 8213 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8214 |
@ChgAdded{Version=[2],Text=[ @key{function} "@key{or}" (Left, Right : Set) @key{return} Set @key{renames} Union;]} |
| 8215 |
|
| 8216 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8217 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Intersection} (Target : @key{in out} Set; |
| 8218 |
Source : @key{in} Set);]} |
| 8219 |
|
| 8220 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8221 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Intersection} (Left, Right : Set) @key{return} Set;]} |
| 8222 |
|
| 8223 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8224 |
@ChgAdded{Version=[2],Text=[ @key{function} "@key{and}" (Left, Right : Set) @key{return} Set @key{renames} Intersection;]} |
| 8225 |
|
| 8226 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8227 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Difference} (Target : @key{in out} Set; |
| 8228 |
Source : @key{in} Set);]} |
| 8229 |
|
| 8230 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8231 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Difference} (Left, Right : Set) @key{return} Set;]} |
| 8232 |
|
| 8233 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8234 |
@ChgAdded{Version=[2],Text=[ @key{function} "-" (Left, Right : Set) @key{return} Set @key{renames} Difference;]} |
| 8235 |
|
| 8236 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8237 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Symmetric_Difference} (Target : @key{in out} Set; |
| 8238 |
Source : @key{in} Set);]} |
| 8239 |
|
| 8240 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8241 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Symmetric_Difference} (Left, Right : Set) @key{return} Set;]} |
| 8242 |
|
| 8243 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8244 |
@ChgAdded{Version=[2],Text=[ @key{function} "@key{xor}" (Left, Right : Set) @key{return} Set |
| 8245 |
@key{renames} Symmetric_Difference;]} |
| 8246 |
|
| 8247 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8248 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Overlap} (Left, Right : Set) @key{return} Boolean;]} |
| 8249 |
|
| 8250 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8251 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Subset} (Subset : Set; |
| 8252 |
Of_Set : Set) @key{return} Boolean;]} |
| 8253 |
|
| 8254 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8255 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First} (Container : Set) @key{return} Cursor;]} |
| 8256 |
|
| 8257 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8258 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Next} (Position : Cursor) @key{return} Cursor;]} |
| 8259 |
|
| 8260 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8261 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Next} (Position : @key{in out} Cursor);]} |
| 8262 |
|
| 8263 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8264 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Set; |
| 8265 |
Item : Element_Type) @key{return} Cursor;]} |
| 8266 |
|
| 8267 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8268 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Set; |
| 8269 |
Item : Element_Type) @key{return} Boolean;]} |
| 8270 |
|
| 8271 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8272 |
@ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0212-1]} |
| 8273 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]}]} |
| 8274 |
|
| 8275 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8276 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Elements} (Left, Right : Cursor) |
| 8277 |
@key{return} Boolean;]} |
| 8278 |
|
| 8279 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8280 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Elements} (Left : Cursor; |
| 8281 |
Right : Element_Type) |
| 8282 |
@key{return} Boolean;]} |
| 8283 |
|
| 8284 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8285 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Elements} (Left : Element_Type; |
| 8286 |
Right : Cursor) |
| 8287 |
@key{return} Boolean;]} |
| 8288 |
|
| 8289 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8290 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Iterate} |
| 8291 |
(Container : @key{in} Set; |
| 8292 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 8293 |
|
| 8294 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8295 |
@ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] Set) |
| 8296 |
@key[return] Set_Iterator_Interfaces.Forward_Iterator'Class;]} |
| 8297 |
|
| 8298 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8299 |
@ChgAdded{Version=[2],Text=[ @key{generic} |
| 8300 |
@key{type} Key_Type (<>) @key{is private}; |
| 8301 |
@key{with function} Key (Element : Element_Type) @key{return} Key_Type; |
| 8302 |
@key{with function} Hash (Key : Key_Type) @key{return} Hash_Type; |
| 8303 |
@key{with function} Equivalent_Keys (Left, Right : Key_Type) |
| 8304 |
@key{return} Boolean; |
| 8305 |
@key{package} @AdaPackDefn{Generic_Keys} @key{is}]} |
| 8306 |
|
| 8307 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8308 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Key} (Position : Cursor) @key{return} Key_Type;]} |
| 8309 |
|
| 8310 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8311 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Container : Set; |
| 8312 |
Key : Key_Type) |
| 8313 |
@key{return} Element_Type;]} |
| 8314 |
|
| 8315 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8316 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace} (Container : @key{in out} Set; |
| 8317 |
Key : @key{in} Key_Type; |
| 8318 |
New_Item : @key{in} Element_Type);]} |
| 8319 |
|
| 8320 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8321 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Exclude} (Container : @key{in out} Set; |
| 8322 |
Key : @key{in} Key_Type);]} |
| 8323 |
|
| 8324 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8325 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Set; |
| 8326 |
Key : @key{in} Key_Type);]} |
| 8327 |
|
| 8328 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8329 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Set; |
| 8330 |
Key : Key_Type) |
| 8331 |
@key{return} Cursor;]} |
| 8332 |
|
| 8333 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8334 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Set; |
| 8335 |
Key : Key_Type) |
| 8336 |
@key{return} Boolean;]} |
| 8337 |
|
| 8338 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8339 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element_Preserving_Key} |
| 8340 |
(Container : @key{in out} Set; |
| 8341 |
Position : @key{in} Cursor; |
| 8342 |
Process : @key{not null access procedure} |
| 8343 |
(Element : @key{in out} Element_Type));]} |
| 8344 |
|
| 8345 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8346 |
@ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Reference_Type} |
| 8347 |
(Element : @key[not null access] Element_Type) @key[is private] |
| 8348 |
@key[with] Implicit_Dereference => Element;]} |
| 8349 |
|
| 8350 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8351 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference_Preserving_Key} (Container : @key[aliased in out] Set; |
| 8352 |
Position : @key[in] Cursor) |
| 8353 |
@key[return] Reference_Type;]} |
| 8354 |
|
| 8355 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8356 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Set; |
| 8357 |
Key : @key[in] Key_Type) |
| 8358 |
@key[return] Constant_Reference_Type;]} |
| 8359 |
|
| 8360 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8361 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference_Preserving_Key} (Container : @key[aliased in out] Set; |
| 8362 |
Key : @key[in] Key_Type) |
| 8363 |
@key[return] Reference_Type;]} |
| 8364 |
|
| 8365 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8366 |
@ChgAdded{Version=[2],Text=[ @key{end} Generic_Keys;]} |
| 8367 |
|
| 8368 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8369 |
@ChgAdded{Version=[2],Text=[@key{private}]} |
| 8370 |
|
| 8371 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8372 |
@ChgAdded{Version=[2],Text=[ ... -- @RI[not specified by the language]]} |
| 8373 |
|
| 8374 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8375 |
@ChgAdded{Version=[2],Text=[@key{end} Ada.Containers.Hashed_Sets;]} |
| 8376 |
|
| 8377 |
@end{Example} |
| 8378 |
|
| 8379 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8380 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[capacity],Sec=[of a hashed set]} |
| 8381 |
An object of type Set contains an expandable hash |
| 8382 |
table, which is used to provide direct access to elements. The @i<capacity> of |
| 8383 |
an object of type Set is the maximum number of elements that can be inserted |
| 8384 |
into the hash table prior to it being automatically expanded.]} |
| 8385 |
|
| 8386 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8387 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[equivalent element],Sec=[of a hashed set]} |
| 8388 |
Two elements @i<E1> and @i<E2> are defined to be @i<equivalent> if |
| 8389 |
Equivalent_Elements (@i<E1>, @i<E2>) returns True.]} |
| 8390 |
|
| 8391 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8392 |
@ChgAdded{Version=[2],Text=[The actual function for the generic formal function |
| 8393 |
Hash is expected to return the same value each time it is called with a |
| 8394 |
particular element value. For any two equivalent elements, the actual for Hash |
| 8395 |
is expected to return the same value. If the actual for Hash behaves in some |
| 8396 |
other manner, the behavior of this package is unspecified. Which subprograms of |
| 8397 |
this package call Hash, and how many times they call it, is |
| 8398 |
unspecified.@PDefn{unspecified}]} |
| 8399 |
|
| 8400 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8401 |
@ChgAdded{Version=[2],Text=[The actual function for the generic formal function |
| 8402 |
Equivalent_Elements is expected to return the same value each time it is called |
| 8403 |
with a particular pair of Element values. It should define an equivalence |
| 8404 |
relationship, that is, be reflexive, symmetric, and transitive. If the actual |
| 8405 |
for Equivalent_Elements behaves in some other manner, the behavior of this |
| 8406 |
package is unspecified. Which subprograms of this package call |
| 8407 |
Equivalent_Elements, and how many times they call it, is |
| 8408 |
unspecified.@PDefn{unspecified}]} |
| 8409 |
|
| 8410 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0044-1]} |
| 8411 |
@ChgAdded{Version=[3],Text=[If the actual function for the generic formal |
| 8412 |
function "=" returns True for any pair of nonequivalent elements, then the |
| 8413 |
behavior of the container function "=" is unspecified.@PDefn{unspecified}]} |
| 8414 |
|
| 8415 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8416 |
@ChgAdded{Version=[2],Text=[If the value of an element stored in a set is |
| 8417 |
changed other than by an operation in this package such that at least one of |
| 8418 |
Hash or Equivalent_Elements give different results, the behavior of this |
| 8419 |
package is unspecified.@PDefn{unspecified}]} |
| 8420 |
|
| 8421 |
@begin{Discussion} |
| 8422 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8423 |
@ChgAdded{Version=[2],Text=[See @RefSec{The Generic Package Containers.Hashed_Maps} |
| 8424 |
for a suggested implementation, and for justification of the restrictions |
| 8425 |
regarding Hash and Equivalent_Elements. Note that sets only need to store |
| 8426 |
elements, not key/element pairs.]} |
| 8427 |
@end{Discussion} |
| 8428 |
|
| 8429 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8430 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[first element],Sec=[of a hashed set]} |
| 8431 |
@Defn2{Term=[last element],Sec=[of a hashed set]} |
| 8432 |
@Defn2{Term=[successor element],Sec=[of a hashed set]} |
| 8433 |
Which elements are the first element and the last |
| 8434 |
element of a set, and which element is the successor of a given element, are |
| 8435 |
unspecified, other than the general semantics described in |
| 8436 |
@RefSecNum{Sets}.@PDefn{unspecified}]} |
| 8437 |
|
| 8438 |
@begin{DescribeCode} |
| 8439 |
|
| 8440 |
@begin{Example} |
| 8441 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8442 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Capacity (Container : Set) @key{return} Count_Type;]} |
| 8443 |
@end{Example} |
| 8444 |
|
| 8445 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8446 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the capacity of Container.]} |
| 8447 |
|
| 8448 |
@begin{Example} |
| 8449 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8450 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reserve_Capacity (Container : @key{in out} Set; |
| 8451 |
Capacity : @key{in} Count_Type);]} |
| 8452 |
@end{Example} |
| 8453 |
|
| 8454 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8455 |
@ChgAdded{Version=[2],Text=[Reserve_Capacity allocates a new hash table such |
| 8456 |
that the length of the resulting set can become at least the value Capacity |
| 8457 |
without requiring an additional call to Reserve_Capacity, and is large enough |
| 8458 |
to hold the current length of Container. Reserve_Capacity then rehashes the |
| 8459 |
elements in Container onto the new hash table. It replaces the old hash table |
| 8460 |
with the new hash table, and then deallocates the old hash table. Any exception |
| 8461 |
raised during allocation is propagated and Container is not modified.]} |
| 8462 |
|
| 8463 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8464 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Reserve_Capacity tampers with the |
| 8465 |
cursors of Container.]} |
| 8466 |
|
| 8467 |
@begin{Reason} |
| 8468 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8469 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Reserve_Capacity tampers with the |
| 8470 |
cursors, as rehashing probably will change the relationships of the elements |
| 8471 |
in Container.]} |
| 8472 |
@end{Reason} |
| 8473 |
|
| 8474 |
@begin{Example} |
| 8475 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8476 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Clear (Container : @key{in out} Set);]} |
| 8477 |
@end{Example} |
| 8478 |
|
| 8479 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8480 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[In addition to the semantics |
| 8481 |
described in @RefSecNum{Sets}, Clear does not affect the capacity of |
| 8482 |
Container.]} |
| 8483 |
|
| 8484 |
@begin{Example} |
| 8485 |
@ChgRef{Version=[3],Kind=[Added]} |
| 8486 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[procedure] Assign (Target : @key[in out] Set; Source : @key[in] Set);]} |
| 8487 |
@end{Example} |
| 8488 |
|
| 8489 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0248-1]} |
| 8490 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[In addition to the semantics |
| 8491 |
described in @RefSecNum{Sets}, if the length of Source is greater than the |
| 8492 |
capacity of Target, Reserve_Capacity (Target, Length (Source)) is called |
| 8493 |
before assigning any elements.]} |
| 8494 |
|
| 8495 |
@begin{Example} |
| 8496 |
@ChgRef{Version=[3],Kind=[Added]} |
| 8497 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Copy (Source : Set; Capacity : Count_Type := 0) @key[return] Set;]} |
| 8498 |
@end{Example} |
| 8499 |
|
| 8500 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 8501 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns a set whose elements are |
| 8502 |
initialized from the elements of Source. If Capacity is 0, then the set capacity |
| 8503 |
is the length of Source; if Capacity is equal to or greater than the length of |
| 8504 |
Source, the set capacity is at least the specified value. Otherwise, the |
| 8505 |
operation propagates Capacity_Error.]} |
| 8506 |
|
| 8507 |
@begin{Example} |
| 8508 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8509 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Set; |
| 8510 |
New_Item : @key{in} Element_Type; |
| 8511 |
Position : @key{out} Cursor; |
| 8512 |
Inserted : @key{out} Boolean);]} |
| 8513 |
@end{Example} |
| 8514 |
|
| 8515 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8516 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[In addition to the semantics |
| 8517 |
described in @RefSecNum{Sets}, if Length (Container) equals Capacity |
| 8518 |
(Container), then Insert first calls Reserve_Capacity to increase the capacity |
| 8519 |
of Container to some larger value.]} |
| 8520 |
|
| 8521 |
@begin{Example} |
| 8522 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8523 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First (Container : Set) @key{return} Cursor;]} |
| 8524 |
@end{Example} |
| 8525 |
|
| 8526 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8527 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Length (Container) = 0, then |
| 8528 |
First returns No_Element. Otherwise, First returns a cursor that designates the |
| 8529 |
first hashed element in Container.]} |
| 8530 |
|
| 8531 |
@begin{Example} |
| 8532 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8533 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Elements (Left, Right : Cursor) |
| 8534 |
@key{return} Boolean;]} |
| 8535 |
@end{Example} |
| 8536 |
|
| 8537 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8538 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Equivalent_Elements |
| 8539 |
(Element (Left), Element (Right)).]} |
| 8540 |
|
| 8541 |
@begin{Example} |
| 8542 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8543 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Elements (Left : Cursor; |
| 8544 |
Right : Element_Type) @key{return} Boolean;]} |
| 8545 |
@end{Example} |
| 8546 |
|
| 8547 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8548 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Equivalent_Elements |
| 8549 |
(Element (Left), Right).]} |
| 8550 |
|
| 8551 |
@begin{Example} |
| 8552 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8553 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Elements (Left : Element_Type; |
| 8554 |
Right : Cursor) @key{return} Boolean;]} |
| 8555 |
@end{Example} |
| 8556 |
|
| 8557 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8558 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Equivalent_Elements (Left, Element (Right)).]} |
| 8559 |
|
| 8560 |
@begin{Example} |
| 8561 |
@ChgRef{Version=[3],Kind=[Added]} |
| 8562 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Set) |
| 8563 |
@key[return] Set_Iterator_Interfaces.Forward_Iterator'Class;]} |
| 8564 |
@end{Example} |
| 8565 |
|
| 8566 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]} |
| 8567 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Iterate returns an |
| 8568 |
iterator object (see @RefSecNum{User-Defined Iterator Types}) that |
| 8569 |
will generate a value for a loop parameter |
| 8570 |
(see @RefSecNum{Generalized Loop Iteration}) designating |
| 8571 |
each element in Container, starting with the first element and moving the cursor |
| 8572 |
according to the successor relation. |
| 8573 |
Tampering with the cursors of Container is prohibited while |
| 8574 |
the iterator object exists (in particular, in |
| 8575 |
the @nt{sequence_of_statements} of the @nt{loop_statement} whose |
| 8576 |
@nt{iterator_specification} denotes this object). The iterator object needs |
| 8577 |
finalization.]} |
| 8578 |
|
| 8579 |
@end{DescribeCode} |
| 8580 |
|
| 8581 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8582 |
@ChgAdded{Version=[2],Text=[For any element @i{E}, the actual function for the |
| 8583 |
generic formal function Generic_Keys.Hash is expected to be such that Hash |
| 8584 |
(@i{E}) = Generic_Keys.Hash (Key (@i{E})). If the actuals for Key or |
| 8585 |
Generic_Keys.Hash behave in some other manner, the behavior of Generic_Keys is |
| 8586 |
unspecified. Which subprograms of Generic_Keys call Generic_Keys.Hash, and how |
| 8587 |
many times they call it, is unspecified.@PDefn{unspecified}]} |
| 8588 |
|
| 8589 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8590 |
@ChgAdded{Version=[2],Text=[For any two elements @i{E1} and @i{E2}, the boolean |
| 8591 |
values Equivalent_Elements (@i{E1}, @i{E2}) and Equivalent_Keys (Key (@i{E1}), |
| 8592 |
Key (@i{E2})) are expected to be equal. If the actuals for Key or |
| 8593 |
Equivalent_Keys behave in some other manner, the behavior of Generic_Keys is |
| 8594 |
unspecified. Which subprograms of Generic_Keys call Equivalent_Keys, and how |
| 8595 |
many times they call it, is unspecified.@PDefn{unspecified}]} |
| 8596 |
|
| 8597 |
@end{StaticSem} |
| 8598 |
|
| 8599 |
@begin{ImplAdvice} |
| 8600 |
|
| 8601 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8602 |
@ChgAdded{Version=[2],Text=[If @i<N> is the length of a set, the |
| 8603 |
average time complexity of the subprograms |
| 8604 |
Insert, Include, Replace, Delete, Exclude and Find that take an element |
| 8605 |
parameter should be @i{O}(log @i<N>). The average time complexity of the |
| 8606 |
subprograms that take a cursor parameter should be @i{O}(1). The average time |
| 8607 |
complexity of Reserve_Capacity should be @i{O}(@i<N>).]} |
| 8608 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 8609 |
Text=[The average time complexity of the Insert, Include, Replace, Delete, Exclude and |
| 8610 |
Find operations of Containers.Hashed_Sets that take an element parameter |
| 8611 |
should be @i{O}(log @i<N>). The average time complexity of the subprograms |
| 8612 |
of Containers.Hashed_Sets that take a cursor parameter should be @i{O}(1). The |
| 8613 |
average time complexity of Containers.@!Hashed_Sets.@!Reserve_Capacity should be |
| 8614 |
@i{O}(@i<N>).]}]} |
| 8615 |
@end{ImplAdvice} |
| 8616 |
|
| 8617 |
@begin{ImplNote} |
| 8618 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8619 |
@ChgAdded{Version=[2],Text=[See @RefSec{The Generic Package Containers.Hashed_Maps} |
| 8620 |
for implementation notes regarding some of the operations of this package.]} |
| 8621 |
@end{ImplNote} |
| 8622 |
|
| 8623 |
@begin{Extend95} |
| 8624 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8625 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 8626 |
The generic package Containers.Hashed_Sets is new.]} |
| 8627 |
@end{Extend95} |
| 8628 |
|
| 8629 |
@begin{Incompatible2005} |
| 8630 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 8631 |
@ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Subprograms Assign and Copy |
| 8632 |
are added to Containers.Hashed_Sets. If an instance of Containers.Hashed_Sets |
| 8633 |
is referenced in a @nt{use_clause}, and an entity @i<E> with the same |
| 8634 |
@nt{defining_identifier} as a new entity in Containers.Hashed_Sets is |
| 8635 |
defined in a package that is also referenced in a @nt{use_clause}, the |
| 8636 |
entity @i<E> may no longer be use-visible, resulting in errors. This should |
| 8637 |
be rare and is easily fixed if it does occur.]} |
| 8638 |
@end{Incompatible2005} |
| 8639 |
|
| 8640 |
@begin{Extend2005} |
| 8641 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]} |
| 8642 |
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005} |
| 8643 |
Added iterator and indexing support to make hashed set containers more |
| 8644 |
convenient to use.]} |
| 8645 |
@end{Extend2005} |
| 8646 |
|
| 8647 |
@begin{DiffWord2005} |
| 8648 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]} |
| 8649 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added wording to require |
| 8650 |
the formal function be such that equal elements are also equivalent.]} |
| 8651 |
|
| 8652 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0084-1]} |
| 8653 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a pragma |
| 8654 |
Remote_Types so that containers can be used in distributed programs.]} |
| 8655 |
@end{DiffWord2005} |
| 8656 |
|
| 8657 |
|
| 8658 |
@LabeledAddedSubclause{Version=[2],Name=[The Generic Package Containers.Ordered_Sets]} |
| 8659 |
|
| 8660 |
@begin{StaticSem} |
| 8661 |
|
| 8662 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 8663 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library |
| 8664 |
package Containers.Ordered_Sets has the following declaration:]} |
| 8665 |
@begin{Example} |
| 8666 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8667 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0084-1],ARef=[AI05-0212-1]} |
| 8668 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[@key[with] Ada.Iterator_Interfaces; |
| 8669 |
],Old=[]}@key{generic} |
| 8670 |
@key{type} Element_Type @key{is private}; |
| 8671 |
@key{with function} "<" (Left, Right : Element_Type) @key{return} Boolean @key{is} <>; |
| 8672 |
@key{with function} "=" (Left, Right : Element_Type) @key{return} Boolean @key{is} <>; |
| 8673 |
@key{package} Ada.Containers.Ordered_Sets @key{is}@ChildUnit{Parent=[Ada.Containers],Child=[Ordered_Sets]} |
| 8674 |
@key{pragma} Preelaborate(Ordered_Sets);@Chg{Version=[3],New=[ |
| 8675 |
@key{pragma} Remote_Types(Ordered_Sets);],Old=[]}]} |
| 8676 |
|
| 8677 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8678 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Elements} (Left, Right : Element_Type) @key{return} Boolean;]} |
| 8679 |
|
| 8680 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8681 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]} |
| 8682 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Set} @key{is tagged private}@Chg{Version=[3],New=[ |
| 8683 |
@key[with] Constant_Indexing => Constant_Reference, |
| 8684 |
Default_Iterator => Iterate, |
| 8685 |
Iterator_Element => Element_Type],Old=[]}; |
| 8686 |
@key{pragma} Preelaborable_Initialization(Set);]} |
| 8687 |
|
| 8688 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8689 |
@ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private}; |
| 8690 |
@key{pragma} Preelaborable_Initialization(Cursor);]} |
| 8691 |
|
| 8692 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8693 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{Empty_Set} : @key{constant} Set;]} |
| 8694 |
|
| 8695 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8696 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]} |
| 8697 |
|
| 8698 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8699 |
@ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]} |
| 8700 |
|
| 8701 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8702 |
@ChgAdded{Version=[3],Text=[ @key[package] @AdaPackDefn{Set_Iterator_Interfaces} @key[is new] |
| 8703 |
Ada.Iterator_Interfaces (Cursor, Has_Element);]} |
| 8704 |
|
| 8705 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8706 |
@ChgAdded{Version=[2],Text=[ @key{function} "=" (Left, Right : Set) @key{return} Boolean;]} |
| 8707 |
|
| 8708 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8709 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Sets} (Left, Right : Set) @key{return} Boolean;]} |
| 8710 |
|
| 8711 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8712 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{To_Set} (New_Item : Element_Type) @key{return} Set;]} |
| 8713 |
|
| 8714 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8715 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Length} (Container : Set) @key{return} Count_Type;]} |
| 8716 |
|
| 8717 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8718 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Empty} (Container : Set) @key{return} Boolean;]} |
| 8719 |
|
| 8720 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8721 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Clear} (Container : @key{in out} Set);]} |
| 8722 |
|
| 8723 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8724 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Position : Cursor) @key{return} Element_Type;]} |
| 8725 |
|
| 8726 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8727 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} Set; |
| 8728 |
Position : @key{in} Cursor; |
| 8729 |
New_Item : @key{in} Element_Type);]} |
| 8730 |
|
| 8731 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8732 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element} |
| 8733 |
(Position : @key{in} Cursor; |
| 8734 |
Process : @key{not null access procedure} (Element : @key{in} Element_Type));]} |
| 8735 |
|
| 8736 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8737 |
@ChgAdded{Version=[3],Text=[ @key[type] Constant_Reference_Type |
| 8738 |
(Element : @key[not null access constant] Element_Type) @key[is private] |
| 8739 |
@key[with] Implicit_Dereference => Element;]} |
| 8740 |
|
| 8741 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8742 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Set; |
| 8743 |
Position : @key[in] Cursor) |
| 8744 |
@key[return] Constant_Reference_Type;]} |
| 8745 |
|
| 8746 |
@ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]} |
| 8747 |
@ChgAdded{Version=[3],Text=[ @key[procedure] @AdaSubDefn{Assign} (Target : @key[in out] Set; Source : @key[in] Set);]} |
| 8748 |
|
| 8749 |
@ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]} |
| 8750 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Copy} (Source : Set) @key[return] Set;]} |
| 8751 |
|
| 8752 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8753 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Move} (Target : @key{in out} Set; |
| 8754 |
Source : @key{in out} Set);]} |
| 8755 |
|
| 8756 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8757 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Set; |
| 8758 |
New_Item : @key{in} Element_Type; |
| 8759 |
Position : @key{out} Cursor; |
| 8760 |
Inserted : @key{out} Boolean);]} |
| 8761 |
|
| 8762 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8763 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Set; |
| 8764 |
New_Item : @key{in} Element_Type);]} |
| 8765 |
|
| 8766 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8767 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Include} (Container : @key{in out} Set; |
| 8768 |
New_Item : @key{in} Element_Type);]} |
| 8769 |
|
| 8770 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8771 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace} (Container : @key{in out} Set; |
| 8772 |
New_Item : @key{in} Element_Type);]} |
| 8773 |
|
| 8774 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8775 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Exclude} (Container : @key{in out} Set; |
| 8776 |
Item : @key{in} Element_Type);]} |
| 8777 |
|
| 8778 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8779 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Set; |
| 8780 |
Item : @key{in} Element_Type);]} |
| 8781 |
|
| 8782 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8783 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Set; |
| 8784 |
Position : @key{in out} Cursor);]} |
| 8785 |
|
| 8786 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8787 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_First} (Container : @key{in out} Set);]} |
| 8788 |
|
| 8789 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8790 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_Last} (Container : @key{in out} Set);]} |
| 8791 |
|
| 8792 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8793 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Union} (Target : @key{in out} Set; |
| 8794 |
Source : @key{in} Set);]} |
| 8795 |
|
| 8796 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8797 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Union} (Left, Right : Set) @key{return} Set;]} |
| 8798 |
|
| 8799 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8800 |
@ChgAdded{Version=[2],Text=[ @key{function} "@key{or}" (Left, Right : Set) @key{return} Set @key{renames} Union;]} |
| 8801 |
|
| 8802 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8803 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Intersection} (Target : @key{in out} Set; |
| 8804 |
Source : @key{in} Set);]} |
| 8805 |
|
| 8806 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8807 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Intersection} (Left, Right : Set) @key{return} Set;]} |
| 8808 |
|
| 8809 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8810 |
@ChgAdded{Version=[2],Text=[ @key{function} "@key{and}" (Left, Right : Set) @key{return} Set @key{renames} Intersection;]} |
| 8811 |
|
| 8812 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8813 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Difference} (Target : @key{in out} Set; |
| 8814 |
Source : @key{in} Set);]} |
| 8815 |
|
| 8816 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8817 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Difference} (Left, Right : Set) @key{return} Set;]} |
| 8818 |
|
| 8819 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8820 |
@ChgAdded{Version=[2],Text=[ @key{function} "-" (Left, Right : Set) @key{return} Set @key{renames} Difference;]} |
| 8821 |
|
| 8822 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8823 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Symmetric_Difference} (Target : @key{in out} Set; |
| 8824 |
Source : @key{in} Set);]} |
| 8825 |
|
| 8826 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8827 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Symmetric_Difference} (Left, Right : Set) @key{return} Set;]} |
| 8828 |
|
| 8829 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8830 |
@ChgAdded{Version=[2],Text=[ @key{function} "@key{xor}" (Left, Right : Set) @key{return} Set @key{renames} |
| 8831 |
Symmetric_Difference;]} |
| 8832 |
|
| 8833 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8834 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Overlap} (Left, Right : Set) @key{return} Boolean;]} |
| 8835 |
|
| 8836 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8837 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Subset} (Subset : Set; |
| 8838 |
Of_Set : Set) @key{return} Boolean;]} |
| 8839 |
|
| 8840 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8841 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First} (Container : Set) @key{return} Cursor;]} |
| 8842 |
|
| 8843 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8844 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First_Element} (Container : Set) @key{return} Element_Type;]} |
| 8845 |
|
| 8846 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8847 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last} (Container : Set) @key{return} Cursor;]} |
| 8848 |
|
| 8849 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8850 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last_Element} (Container : Set) @key{return} Element_Type;]} |
| 8851 |
|
| 8852 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8853 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Next} (Position : Cursor) @key{return} Cursor;]} |
| 8854 |
|
| 8855 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8856 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Next} (Position : @key{in out} Cursor);]} |
| 8857 |
|
| 8858 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8859 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Previous} (Position : Cursor) @key{return} Cursor;]} |
| 8860 |
|
| 8861 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8862 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Previous} (Position : @key{in out} Cursor);]} |
| 8863 |
|
| 8864 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8865 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Set; |
| 8866 |
Item : Element_Type) |
| 8867 |
@key{return} Cursor;]} |
| 8868 |
|
| 8869 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8870 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Floor} (Container : Set; |
| 8871 |
Item : Element_Type) |
| 8872 |
@key{return} Cursor;]} |
| 8873 |
|
| 8874 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8875 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Ceiling} (Container : Set; |
| 8876 |
Item : Element_Type) |
| 8877 |
@key{return} Cursor;]} |
| 8878 |
|
| 8879 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8880 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Set; |
| 8881 |
Item : Element_Type) @key{return} Boolean;]} |
| 8882 |
|
| 8883 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8884 |
@ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0212-1]} |
| 8885 |
@ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]}]} |
| 8886 |
|
| 8887 |
|
| 8888 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8889 |
@ChgAdded{Version=[2],Text=[ @key{function} "<" (Left, Right : Cursor) @key{return} Boolean;]} |
| 8890 |
|
| 8891 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8892 |
@ChgAdded{Version=[2],Text=[ @key{function} ">" (Left, Right : Cursor) @key{return} Boolean;]} |
| 8893 |
|
| 8894 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8895 |
@ChgAdded{Version=[2],Text=[ @key{function} "<" (Left : Cursor; Right : Element_Type) |
| 8896 |
@key{return} Boolean;]} |
| 8897 |
|
| 8898 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8899 |
@ChgAdded{Version=[2],Text=[ @key{function} ">" (Left : Cursor; Right : Element_Type) |
| 8900 |
@key{return} Boolean;]} |
| 8901 |
|
| 8902 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8903 |
@ChgAdded{Version=[2],Text=[ @key{function} "<" (Left : Element_Type; Right : Cursor) |
| 8904 |
@key{return} Boolean;]} |
| 8905 |
|
| 8906 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8907 |
@ChgAdded{Version=[2],Text=[ @key{function} ">" (Left : Element_Type; Right : Cursor) |
| 8908 |
@key{return} Boolean;]} |
| 8909 |
|
| 8910 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8911 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Iterate} |
| 8912 |
(Container : @key{in} Set; |
| 8913 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 8914 |
|
| 8915 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8916 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reverse_Iterate} |
| 8917 |
(Container : @key{in} Set; |
| 8918 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 8919 |
|
| 8920 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8921 |
@ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] Set) |
| 8922 |
@key[return] Set_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 8923 |
|
| 8924 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0262-1]} |
| 8925 |
@ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] Set; Start : @key[in] Cursor) |
| 8926 |
@key[return] Set_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 8927 |
|
| 8928 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8929 |
@ChgAdded{Version=[2],Text=[ @key{generic} |
| 8930 |
@key{type} Key_Type (<>) @key{is private}; |
| 8931 |
@key{with function} Key (Element : Element_Type) @key{return} Key_Type; |
| 8932 |
@key{with function} "<" (Left, Right : Key_Type) |
| 8933 |
@key{return} Boolean @key{is} <>; |
| 8934 |
@key{package} @AdaPackDefn{Generic_Keys} @key{is}]} |
| 8935 |
|
| 8936 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8937 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Keys} (Left, Right : Key_Type) |
| 8938 |
@key{return} Boolean;]} |
| 8939 |
|
| 8940 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8941 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Key} (Position : Cursor) @key{return} Key_Type;]} |
| 8942 |
|
| 8943 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8944 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Container : Set; |
| 8945 |
Key : Key_Type) |
| 8946 |
@key{return} Element_Type;]} |
| 8947 |
|
| 8948 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8949 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace} (Container : @key{in out} Set; |
| 8950 |
Key : @key{in} Key_Type; |
| 8951 |
New_Item : @key{in} Element_Type);]} |
| 8952 |
|
| 8953 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8954 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Exclude} (Container : @key{in out} Set; |
| 8955 |
Key : @key{in} Key_Type);]} |
| 8956 |
|
| 8957 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8958 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Set; |
| 8959 |
Key : @key{in} Key_Type);]} |
| 8960 |
|
| 8961 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8962 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Set; |
| 8963 |
Key : Key_Type) |
| 8964 |
@key{return} Cursor;]} |
| 8965 |
|
| 8966 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8967 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Floor} (Container : Set; |
| 8968 |
Key : Key_Type) |
| 8969 |
@key{return} Cursor;]} |
| 8970 |
|
| 8971 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8972 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Ceiling} (Container : Set; |
| 8973 |
Key : Key_Type) |
| 8974 |
@key{return} Cursor;]} |
| 8975 |
|
| 8976 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8977 |
@ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Set; |
| 8978 |
Key : Key_Type) @key{return} Boolean;]} |
| 8979 |
|
| 8980 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 8981 |
@ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element_Preserving_Key} |
| 8982 |
(Container : @key{in out} Set; |
| 8983 |
Position : @key{in} Cursor; |
| 8984 |
Process : @key{not null access procedure} |
| 8985 |
(Element : @key{in out} Element_Type));]} |
| 8986 |
|
| 8987 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8988 |
@ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Reference_Type} |
| 8989 |
(Element : @key[not null access] Element_Type) @key[is private] |
| 8990 |
@key[with] Implicit_Dereference => Element;]} |
| 8991 |
|
| 8992 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8993 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference_Preserving_Key} (Container : @key[aliased in out] Set; |
| 8994 |
Position : @key[in] Cursor) |
| 8995 |
@key[return] Reference_Type;]} |
| 8996 |
|
| 8997 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 8998 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Set; |
| 8999 |
Key : @key[in] Key_Type) |
| 9000 |
@key[return] Constant_Reference_Type;]} |
| 9001 |
|
| 9002 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]} |
| 9003 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference_Preserving_Key} (Container : @key[aliased in out] Set; |
| 9004 |
Key : @key[in] Key_Type) |
| 9005 |
@key[return] Reference_Type;]} |
| 9006 |
|
| 9007 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9008 |
@ChgAdded{Version=[2],Text=[ @key{end} Generic_Keys;]} |
| 9009 |
|
| 9010 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9011 |
@ChgAdded{Version=[2],Text=[@key{private}]} |
| 9012 |
|
| 9013 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9014 |
@ChgAdded{Version=[2],Text=[ ... -- @RI[not specified by the language]]} |
| 9015 |
|
| 9016 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9017 |
@ChgAdded{Version=[2],Text=[@key{end} Ada.Containers.Ordered_Sets;]} |
| 9018 |
@end{Example} |
| 9019 |
|
| 9020 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9021 |
@ChgAdded{Version=[2],Text=[Two elements @i<E1> and @i<E2> are @i<equivalent> |
| 9022 |
if both @i<E1> < @i<E2> and @i<E2> < @i<E1> return False, using the generic |
| 9023 |
formal "<" operator for elements.@Defn2{Term=[equivalent element],Sec=[of an ordered set]} |
| 9024 |
Function Equivalent_Elements returns True if Left and Right are equivalent, |
| 9025 |
and False otherwise.]} |
| 9026 |
|
| 9027 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9028 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0044-1]} |
| 9029 |
@ChgAdded{Version=[2],Text=[The actual function for the generic formal function |
| 9030 |
"<" on Element_Type values is expected to return the same value each time it is |
| 9031 |
called with a particular pair of key values. It should define a strict |
| 9032 |
@Chg{Version=[3],New=[weak ],Old=[]}ordering relationship@Chg{Version=[3], |
| 9033 |
New=[ (see @RefSecNum{Containers})],Old=[, that is, be irreflexive, asymmetric, |
| 9034 |
and transitive]}. If the |
| 9035 |
actual for "<" behaves in some other manner, the behavior of this package is |
| 9036 |
unspecified. Which subprograms of this package call "<" and how many times they |
| 9037 |
call it, is unspecified.@PDefn{unspecified}]} |
| 9038 |
|
| 9039 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0044-1]} |
| 9040 |
@ChgAdded{Version=[3],Text=[If the actual function for the generic formal |
| 9041 |
function "=" returns True for any pair of nonequivalent elements, then the |
| 9042 |
behavior of the container function "=" is unspecified.@PDefn{unspecified}]} |
| 9043 |
|
| 9044 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9045 |
@ChgAdded{Version=[2],Text=[If the value of an element stored in a set is changed |
| 9046 |
other than by an operation in this package such that at least one of |
| 9047 |
"<" or "=" give different |
| 9048 |
results, the behavior of this package is unspecified.@PDefn{unspecified}]} |
| 9049 |
|
| 9050 |
@begin{Discussion} |
| 9051 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9052 |
@ChgAdded{Version=[2],Text=[See @RefSec{The Generic Package Containers.Ordered_Maps} |
| 9053 |
for a suggested implementation, and for justification of the restrictions |
| 9054 |
regarding "<" and "=". Note that sets only need to store elements, not |
| 9055 |
key/element pairs.]} |
| 9056 |
@end{Discussion} |
| 9057 |
|
| 9058 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9059 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]} |
| 9060 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[first element],Sec=[of an ordered set]} |
| 9061 |
@Defn2{Term=[last element],Sec=[of an ordered set]} |
| 9062 |
@Defn2{Term=[successor element],Sec=[of an ordered set]}@Chg{Version=[3],New=[ |
| 9063 |
@Defn2{Term=[predecessor element],Sec=[of an ordered set]}],Old=[]} |
| 9064 |
The @Chg{Version=[3],New=[@i<first element>],Old=[first element]} |
| 9065 |
of a nonempty set is the one |
| 9066 |
which is less than all the other elements in the set. |
| 9067 |
The @Chg{Version=[3],New=[@i<last element>],Old=[last element]} of a |
| 9068 |
nonempty set is the one which is greater than all the other elements in the |
| 9069 |
set. The @Chg{Version=[3],New=[@i<successor>],Old=[successor]} |
| 9070 |
of an element is the smallest element that is larger than |
| 9071 |
the given element. The @Chg{Version=[3],New=[@i<predecessor>],Old=[predecessor]} |
| 9072 |
of an element is the largest element that is |
| 9073 |
smaller than the given element. All comparisons are done using the generic |
| 9074 |
formal "<" operator for elements.]} |
| 9075 |
|
| 9076 |
@begin{DescribeCode} |
| 9077 |
|
| 9078 |
@begin{Example} |
| 9079 |
@ChgRef{Version=[3],Kind=[Added]} |
| 9080 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Copy (Source : Set) @key[return] Set;]} |
| 9081 |
@end{Example} |
| 9082 |
|
| 9083 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]} |
| 9084 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns a set whose |
| 9085 |
elements are initialized from the corresponding elements of Source.]} |
| 9086 |
|
| 9087 |
@begin{Example} |
| 9088 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9089 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_First (Container : @key{in out} Set);]} |
| 9090 |
@end{Example} |
| 9091 |
|
| 9092 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9093 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 9094 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Delete_First |
| 9095 |
has no effect. Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 9096 |
the element designated by First (Container) is removed |
| 9097 |
from Container. Delete_First tampers with the cursors of Container.]} |
| 9098 |
|
| 9099 |
@begin{Example} |
| 9100 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9101 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_Last (Container : @key{in out} Set);]} |
| 9102 |
@end{Example} |
| 9103 |
|
| 9104 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9105 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 9106 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Delete_Last |
| 9107 |
has no effect. Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 9108 |
the element designated by Last (Container) is removed |
| 9109 |
from Container. Delete_Last tampers with the cursors of Container.]} |
| 9110 |
|
| 9111 |
@begin{Example} |
| 9112 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9113 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First_Element (Container : Set) @key{return} Element_Type;]} |
| 9114 |
@end{Example} |
| 9115 |
|
| 9116 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9117 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to |
| 9118 |
Element (First (Container)).]} |
| 9119 |
|
| 9120 |
@begin{Example} |
| 9121 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9122 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last (Container : Set) @key{return} Cursor;]} |
| 9123 |
@end{Example} |
| 9124 |
|
| 9125 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9126 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a cursor that designates |
| 9127 |
the last element in Container. If Container is empty, returns No_Element.]} |
| 9128 |
|
| 9129 |
@begin{Example} |
| 9130 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9131 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last_Element (Container : Set) @key{return} Element_Type;]} |
| 9132 |
@end{Example} |
| 9133 |
|
| 9134 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9135 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to |
| 9136 |
Element (Last (Container)).]} |
| 9137 |
|
| 9138 |
@begin{Example} |
| 9139 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9140 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Previous (Position : Cursor) @key{return} Cursor;]} |
| 9141 |
@end{Example} |
| 9142 |
|
| 9143 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9144 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]} |
| 9145 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then |
| 9146 |
Previous returns No_Element. Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 9147 |
Previous returns a cursor designating |
| 9148 |
the @Chg{Version=[3],New=[predecessor ],Old=[]}element |
| 9149 |
@Chg{Version=[3],New=[of],Old=[that precedes]} the one designated by Position. |
| 9150 |
If Position designates the first element, then Previous returns No_Element.]} |
| 9151 |
|
| 9152 |
@begin{Example} |
| 9153 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9154 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Previous (Position : @key{in out} Cursor);]} |
| 9155 |
@end{Example} |
| 9156 |
|
| 9157 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9158 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Previous (Position).]} |
| 9159 |
|
| 9160 |
@begin{Example} |
| 9161 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9162 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Floor (Container : Set; |
| 9163 |
Item : Element_Type) @key{return} Cursor;]} |
| 9164 |
@end{Example} |
| 9165 |
|
| 9166 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9167 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 9168 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Floor searches for the last element |
| 9169 |
which is not greater than Item. If such an element is found, a cursor that |
| 9170 |
designates it is returned. Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 9171 |
No_Element is returned.]} |
| 9172 |
|
| 9173 |
@begin{Example} |
| 9174 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9175 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Ceiling (Container : Set; |
| 9176 |
Item : Element_Type) @key{return} Cursor;]} |
| 9177 |
@end{Example} |
| 9178 |
|
| 9179 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9180 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 9181 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Ceiling searches for the first |
| 9182 |
element which is not less than Item. If such an element is found, a cursor that |
| 9183 |
designates it is returned. Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 9184 |
No_Element is returned.]} |
| 9185 |
|
| 9186 |
@begin{Example} |
| 9187 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9188 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "<" (Left, Right : Cursor) @key{return} Boolean;]} |
| 9189 |
@end{Example} |
| 9190 |
|
| 9191 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9192 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Left) < Element (Right).]} |
| 9193 |
|
| 9194 |
@begin{Example} |
| 9195 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9196 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} ">" (Left, Right : Cursor) @key{return} Boolean;]} |
| 9197 |
@end{Example} |
| 9198 |
|
| 9199 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9200 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Right) < Element (Left).]} |
| 9201 |
|
| 9202 |
@begin{Example} |
| 9203 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9204 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "<" (Left : Cursor; Right : Element_Type) @key{return} Boolean;]} |
| 9205 |
@end{Example} |
| 9206 |
|
| 9207 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9208 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Left) < Right.]} |
| 9209 |
|
| 9210 |
@begin{Example} |
| 9211 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9212 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} ">" (Left : Cursor; Right : Element_Type) @key{return} Boolean;]} |
| 9213 |
@end{Example} |
| 9214 |
|
| 9215 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9216 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Right < Element (Left).]} |
| 9217 |
|
| 9218 |
@begin{Example} |
| 9219 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9220 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "<" (Left : Element_Type; Right : Cursor) @key{return} Boolean;]} |
| 9221 |
@end{Example} |
| 9222 |
|
| 9223 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9224 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Left < Element (Right).]} |
| 9225 |
|
| 9226 |
@begin{Example} |
| 9227 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9228 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} ">" (Left : Element_Type; Right : Cursor) @key{return} Boolean;]} |
| 9229 |
@end{Example} |
| 9230 |
|
| 9231 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9232 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Right) < Left.]} |
| 9233 |
|
| 9234 |
@begin{Example} |
| 9235 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 9236 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reverse_Iterate |
| 9237 |
(Container : @key{in} Set; |
| 9238 |
Process : @key{not null access procedure} (Position : @key{in} Cursor));]} |
| 9239 |
@end{Example} |
| 9240 |
|
| 9241 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9242 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]} |
| 9243 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Iterates over the elements in |
| 9244 |
Container as per @Chg{Version=[3],New=[procedure ],Old=[]}Iterate, |
| 9245 |
with the difference that the elements are traversed |
| 9246 |
in predecessor order, starting with the last element.]} |
| 9247 |
|
| 9248 |
@begin{Example} |
| 9249 |
@ChgRef{Version=[3],Kind=[Added]} |
| 9250 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Set) |
| 9251 |
@key[return] Set_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 9252 |
@end{Example} |
| 9253 |
|
| 9254 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]} |
| 9255 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[Iterate returns a reversible |
| 9256 |
iterator object (see @RefSecNum{User-Defined Iterator Types}) that |
| 9257 |
will generate a value for a loop parameter |
| 9258 |
(see @RefSecNum{Generalized Loop Iteration}) designating |
| 9259 |
each element in Container, starting with the first element and moving the cursor |
| 9260 |
according to the successor relation when used as a forward iterator, and |
| 9261 |
starting with the last element and moving the cursor according to the |
| 9262 |
predecessor relation when used as a reverse iterator. |
| 9263 |
Tampering with the cursors of Container is prohibited while |
| 9264 |
the iterator object exists (in particular, in |
| 9265 |
the @nt{sequence_of_statements} of the @nt{loop_statement} whose |
| 9266 |
@nt{iterator_specification} denotes this object). The iterator object needs |
| 9267 |
finalization.]} |
| 9268 |
|
| 9269 |
@begin{Example} |
| 9270 |
@ChgRef{Version=[3],Kind=[Added]} |
| 9271 |
@ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Set; Start : @key[in] Cursor) |
| 9272 |
@key[return] Set_Iterator_Interfaces.Reversible_Iterator'Class;]} |
| 9273 |
@end{Example} |
| 9274 |
|
| 9275 |
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0262-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]} |
| 9276 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[If Start is not No_Element and does |
| 9277 |
not designate an item in Container, then Program_Error is propagated. If Start |
| 9278 |
is No_Element, then Constraint_Error is propagated. Otherwise, Iterate returns |
| 9279 |
a reversible iterator object (see @RefSecNum{User-Defined Iterator Types}) that |
| 9280 |
will generate a value for a loop parameter |
| 9281 |
(see @RefSecNum{Generalized Loop Iteration}) designating |
| 9282 |
each element in Container, starting with the element designated by Start and |
| 9283 |
moving the cursor according to the successor relation when used as a forward |
| 9284 |
iterator, or moving the cursor according to the predecessor relation when used |
| 9285 |
as a reverse iterator. Tampering with the cursors of Container is prohibited |
| 9286 |
while the iterator object exists (in particular, in the |
| 9287 |
@nt{sequence_of_statements} of the @nt{loop_statement} whose |
| 9288 |
@nt{iterator_specification} denotes this object). The iterator object needs |
| 9289 |
finalization.]} |
| 9290 |
|
| 9291 |
@begin{Discussion} |
| 9292 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 9293 |
@ChgAdded{Version=[3],Type=[Leading],Text=[Exits are allowed from the loops |
| 9294 |
created using the iterator objects. In particular, to stop the iteration at a |
| 9295 |
particular cursor, just add]} |
| 9296 |
@begin{Example} |
| 9297 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 9298 |
@ChgAdded{Version=[3],Text=[@key[exit when] Cur = Stop;]} |
| 9299 |
@end{Example} |
| 9300 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 9301 |
@ChgAdded{Version=[3],Type=[Trailing],Text=[in the body of the loop (assuming |
| 9302 |
that @exam{Cur} is the loop parameter and @exam{Stop} is the cursor that you |
| 9303 |
want to stop at).]} |
| 9304 |
@end{Discussion} |
| 9305 |
@end{DescribeCode} |
| 9306 |
|
| 9307 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9308 |
@ChgAdded{Version=[2],Text=[For any two elements @i<E1> and @i<E2>, the |
| 9309 |
boolean values (@i<E1> < @i<E2>) and (Key(@i<E1>) < Key(@i<E2>)) are expected |
| 9310 |
to be equal. If the actuals for Key or Generic_Keys."<" behave in some other |
| 9311 |
manner, the behavior of this package is unspecified. Which subprograms of this |
| 9312 |
package call Key and Generic_Keys."<", and how many times the functions are |
| 9313 |
called, is unspecified.@PDefn{unspecified}]} |
| 9314 |
|
| 9315 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9316 |
@ChgAdded{Version=[2],Text=[In addition to the semantics described in |
| 9317 |
@RefSecNum{Sets}, the subprograms in package Generic_Keys named |
| 9318 |
Floor and Ceiling, are equivalent to the corresponding subprograms in the |
| 9319 |
parent package, with the difference that the |
| 9320 |
Key subprogram parameter is compared to elements in the container using the |
| 9321 |
Key and "<" generic formal functions. The function named Equivalent_Keys |
| 9322 |
in package Generic_Keys returns True if both Left < Right and Right < Left |
| 9323 |
return False using the generic formal "<" operator, and returns True otherwise.]} |
| 9324 |
|
| 9325 |
@end{StaticSem} |
| 9326 |
|
| 9327 |
@begin{ImplAdvice} |
| 9328 |
|
| 9329 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9330 |
@ChgAdded{Version=[2],Text=[If @i<N> is the length of a set, then the |
| 9331 |
worst-case time complexity of the Insert, Include, Replace, Delete, Exclude and |
| 9332 |
Find operations that take an element parameter should be @i{O}((log @i<N>)**2) or |
| 9333 |
better. The worst-case time complexity of the subprograms that take a cursor |
| 9334 |
parameter should be @i{O}(1).]} |
| 9335 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 9336 |
Text=[The worst-case time complexity of the Insert, Include, Replace, Delete, Exclude and |
| 9337 |
Find operations of Containers.Ordered_Sets that take an element parameter |
| 9338 |
should be @i{O}((log @i<N>)**2). The worst-case time complexity of the subprograms |
| 9339 |
of Containers.Ordered_Sets that take a cursor parameter should be @i{O}(1).]}]} |
| 9340 |
@end{ImplAdvice} |
| 9341 |
|
| 9342 |
@begin{ImplNote} |
| 9343 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9344 |
@ChgAdded{Version=[2],Text=[See @RefSec{The Generic Package Containers.Ordered_Maps} |
| 9345 |
for implementation notes regarding some of the operations of this package.]} |
| 9346 |
@end{ImplNote} |
| 9347 |
|
| 9348 |
@begin{Extend95} |
| 9349 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 9350 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 9351 |
The generic package Containers.Ordered_Sets is new.]} |
| 9352 |
@end{Extend95} |
| 9353 |
|
| 9354 |
@begin{Incompatible2005} |
| 9355 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]} |
| 9356 |
@ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Subprograms Assign and Copy |
| 9357 |
are added to Containers.Ordered_Sets. If an instance of Containers.Ordered_Sets |
| 9358 |
is referenced in a @nt{use_clause}, and an entity @i<E> with the same |
| 9359 |
@nt{defining_identifier} as a new entity in Containers.Ordered_Sets is |
| 9360 |
defined in a package that is also referenced in a @nt{use_clause}, the |
| 9361 |
entity @i<E> may no longer be use-visible, resulting in errors. This should |
| 9362 |
be rare and is easily fixed if it does occur.]} |
| 9363 |
@end{Incompatible2005} |
| 9364 |
|
| 9365 |
@begin{Extend2005} |
| 9366 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]} |
| 9367 |
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005} |
| 9368 |
Added iterator and indexing support to make ordered set containers more |
| 9369 |
convenient to use.]} |
| 9370 |
@end{Extend2005} |
| 9371 |
|
| 9372 |
@begin{DiffWord2005} |
| 9373 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]} |
| 9374 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added wording to |
| 9375 |
require the formal function be such that equal elements are also |
| 9376 |
equivalent.]} |
| 9377 |
|
| 9378 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]} |
| 9379 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Redefined "<" actuals |
| 9380 |
to require a strict weak ordering; the old definition allowed |
| 9381 |
indeterminant comparisons that would not have worked in a container.]} |
| 9382 |
|
| 9383 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0084-1]} |
| 9384 |
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a pragma |
| 9385 |
Remote_Types so that containers can be used in distributed programs.]} |
| 9386 |
@end{DiffWord2005} |
| 9387 |
|
| 9388 |
|
| 9389 |
|