Debian Codegraph @

source_2020/pre_con1.mss

raw
1 @Part(precontainers-1, Root="ada.mss")
2 @comment{ $Source: e:\\cvsroot/ARM/Source/pre_con1.mss,v $ }
3 @comment{ $Revision: 1.10 $ $Date: 2020/06/03 00:09:01 $ $Author: randy $ }
4
5 @LabeledAddedSubclause{Version=[2],Name=[Maps]}
6
7 @begin{Intro}
8 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
9 @ChgAdded{Version=[2],Text=[The language-defined generic packages
10 Containers.Hashed_Maps and Containers.Ordered_Maps provide private types Map
11 and Cursor, and a set of operations for each type. A map container allows an
12 arbitrary type to be used as a key to find the element associated with that
13 key. A hashed map uses a hash function to organize the keys, while an ordered
14 map orders the keys per a specified relation.
15 @Defn{map container}@Defn2{Term=[container],Sec=[map]}]}
16
17 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
18 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
19 @ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[subclause],Old=[section]}
20 describes the declarations that are
21 common to both kinds of maps. See @RefSecNum{The Generic Package Containers.Hashed_Maps}
22 for a description of the semantics specific to
23 Containers.Hashed_Maps and @RefSecNum{The Generic Package Containers.Ordered_Maps} for
24 a description of the semantics specific to Containers.Ordered_Maps.]}
25 @end{Intro}
26
27 @begin{StaticSem}
28
29 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
30 @ChgAdded{Version=[2],Text=[The actual function for the generic formal function
31 "=" on Element_Type values is expected to define a reflexive and symmetric
32 relationship and return the same result value each time it is called with a
33 particular pair of values. If it behaves in some other manner, the function
34 "=" on map values returns an unspecified value. The
35 exact arguments and number of calls of this generic formal function by the
36 function "=" on map values are unspecified.@PDefn{unspecified}]}
37
38 @begin{Ramification}
39 @ChgRef{Version=[2],Kind=[AddedNormal]}
40 @ChgAdded{Version=[2],Text=[If the actual function for "=" is not symmetric
41 and consistent, the result returned by "=" for Map objects cannot be predicted.
42 The implementation is not required to protect
43 against "=" raising an exception, or returning random results, or any
44 other @lquotes@;bad@rquotes behavior. And it can call "=" in whatever
45 manner makes sense. But note that only the result of "=" for Map objects
46 is unspecified; other subprograms are not allowed to break if "="
47 is bad (they aren't expected to use "=").]}
48 @end{Ramification}
49
50 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
51 @ChgAdded{Version=[2],Text=[The type Map is used to represent maps. The type
52 Map needs finalization@PDefn2{Term=<needs finalization>,Sec=<language-defined type>}
53 (see @RefSecNum{Assignment and Finalization}).]}
54
55 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
56 @ChgAdded{Version=[2],Text=[@Defn2{Term=[node],Sec=[of a map]}A map contains
57 pairs of keys and elements, called @i{nodes}. Map cursors designate nodes, but
58 also can be thought of as designating an element (the element contained in the
59 node) for consistency with the other containers. There exists an equivalence
60 relation on keys, whose definition is different for hashed maps and ordered
61 maps. A map never contains two or more nodes with equivalent keys. The
62 @i{length} of a map is the number of nodes it
63 contains.@Defn2{Term=[length],Sec=[of a map]}]}
64
65 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
66 @ChgAdded{Version=[2],Text=[@Defn2{Term=[first node],Sec=[of a map]}
67 @Defn2{Term=[last node],Sec=[of a map]}
68 @Defn2{Term=[successor node],Sec=[of a map]}Each nonempty map has two
69 particular nodes called the @i{first node} and the @i{last node} (which may be
70 the same). Each node except for the last node has a @i{successor node}. If
71 there are no other intervening operations, starting with the first node and
72 repeatedly going to the successor node will visit each node in the map exactly
73 once until the last node is reached. The exact definition of these terms is
74 different for hashed maps and ordered maps.]}
75
76 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
77 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
78 @ChgAdded{Version=[2],Text=[@Redundant[Some
79 operations @Chg{Version=[5],New=[@Defn2{Term=[tamper with cursors],Sec=[of a map]}@Defn2{Term=[tamper with elements],Sec=[of a map]}],Old=[of
80 these generic packages
81 have access-to-subprogram parameters. To ensure such operations are
82 well-defined, they guard against certain actions by the designated
83 subprogram. In particular, some operations]} check for @lquotes@;tampering with
84 cursors@rquotes of a container because they depend on the set of elements of
85 the container remaining constant, and others check for @lquotes@;tampering with
86 elements@rquotes of a container because they depend on elements of the
87 container not being replaced.]@Chg{Version=[5],New=[ When
88 tampering with cursors is @i<prohibited>@Defn2{Term=[prohibited],Sec=[tampering with a map]}
89 @Defn2{Term=[tampering],Sec=[prohibited for a map]}for a particular
90 map object @i<M>, Program_Error is propagated by the finalization
91 of @i<M>@Redundant[, as well as by a call that passes @i<M> to
92 certain of the operations of this package, as indicated by the precondition
93 of such an operation]. Similarly, when tampering with elements is @i<prohibited>
94 for @i<M>, Program_Error is propagated by a call that passes @i<M> to
95 certain of other operations of this package, as indicated by the precondition
96 of such an operation.],Old=[]}]}
97
98 @begin{NotIso}
99 @ChgAdded{Version=[5],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 8 through 15
100 are removed as preconditions now describe these rules.>}]}@Comment{This message should be
101 deleted if the paragraphs are ever renumbered.}
102 @end{NotIso}
103
104 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
105 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
106 @ChgDeleted{Version=[5],Type=[Leading],Text=[@Chg{Version=[2],New=[@Defn2{Term=[tamper with cursors],Sec=[of a map]}
107 A subprogram is said to @i{tamper with cursors} of a map object @i<M>
108 if:],Old=[]}]}
109
110 @begin{Itemize}
111
112 @ChgRef{Version=[2],Kind=[AddedNormal]}
113 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
114 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
115 inserts or deletes elements of @i<M>, that is,
116 it calls the Insert, Include, Clear, Delete, or Exclude procedures with @i<M>
117 as a parameter; or]}]}
118
119 @begin{Honest}
120 @ChgRef{Version=[2],Kind=[AddedNormal]}
121 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
122 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[Operations which
123 are defined to be equivalent to
124 a call on one of these operations also are included. Similarly, operations
125 which call one of these as part of their definition are included.]}]}
126 @end{Honest}
127
128 @ChgRef{Version=[2],Kind=[AddedNormal]}
129 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
130 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
131 finalizes @i<M>; or]}]}
132
133 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
134 @ChgRef{Version=[5],Kind=[DeletedAddedNoDelMsg]}
135 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[it
136 calls the Assign procedure with @i<M> as the Target parameter; or]}]}
137
138 @begin{Ramification}
139 @ChgRef{Version=[3],Kind=[AddedNormal]}
140 @ChgAdded{Version=[3],Text=[We don't need to explicitly mention
141 @nt{assignment_statement}, because that finalizes the target object
142 as part of the operation, and finalization of an object is already defined
143 as tampering with cursors.]}
144 @end{Ramification}
145
146 @ChgRef{Version=[2],Kind=[AddedNormal]}
147 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
148 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
149 calls the Move procedure with @i<M> as a parameter; or]}]}
150
151 @ChgRef{Version=[2],Kind=[AddedNormal]}
152 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
153 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
154 calls one of the operations defined to tamper with the cursors of @i<M>.]}]}
155
156 @end{Itemize}
157
158 @begin{Ramification}
159 @ChgRef{Version=[2],Kind=[AddedNormal]}
160 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
161 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[Replace only
162 modifies a key and element rather than rehashing, so it does not
163 tamper with cursors.]}]}
164 @end{Ramification}
165
166 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
167 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
168 @ChgDeleted{Version=[5],Type=[Leading],Text=[@Chg{Version=[2],New=[@Defn2{Term=[tamper with elements],Sec=[of a list]}
169 A subprogram is said to @i{tamper with elements} of a map
170 object @i<M> if:],Old=[]}]}
171
172 @begin{Itemize}
173
174 @ChgRef{Version=[2],Kind=[AddedNormal]}
175 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
176 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
177 tampers with cursors of @i<M>; or]}]}
178
179 @ChgRef{Version=[2],Kind=[AddedNormal]}
180 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
181 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
182 replaces one or more elements of @i<M>, that is,
183 it calls the Replace or Replace_Element procedures with @i<M>
184 as a parameter.]}]}
185
186 @begin{Reason}
187 @ChgRef{Version=[2],Kind=[AddedNormal]}
188 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
189 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[Complete
190 replacement of an element can cause its
191 memory to be deallocated while another operation is holding onto a reference
192 to it. That can't be allowed. However, a simple modification of (part of) an
193 element is not a problem, so Update_Element does not cause a problem.]}]}
194 @end{Reason}
195
196 @end{Itemize}
197
198 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0265-1]}
199 @ChgRef{Version=[4],Kind=[RevisedAdded],ARef=[AI12-0110-1]}
200 @ChgRef{Version=[5],Kind=[DeletedAddedNoDelMsg],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
201 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[@Defn2{Term=[prohibited],Sec=[tampering with a map]}
202 @Defn2{Term=[tampering],Sec=[prohibited for a map]}
203 When tampering with cursors is @i<prohibited> for a particular map object
204 @i<M>, Program_Error is propagated by a call of any language-defined subprogram
205 that is defined to tamper with the cursors of @i<M>, leaving @i<M> unmodified.
206 Similarly, when tampering with elements is @i<prohibited> for a particular map
207 object @i<M>, Program_Error is propagated by a call of any language-defined
208 subprogram that is defined to tamper with the elements of @i<M> @Redundant[(or
209 tamper with the cursors of @i<M>)], leaving @i<M>
210 unmodified.@Chg{Version=[4],New=[ These checks are made before any other
211 defined behavior of the body of the language-defined subprogram.],Old=[]}]}]}
212 @begin{TheProof}
213 @ChgRef{Version=[3],Kind=[AddedNormal]}
214 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
215 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[Tampering
216 with elements includes tampering with
217 cursors, so we mention it only from completeness in the second sentence.]}]}
218 @end{TheProof}
219
220 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
221 @ChgAdded{Version=[2],Text=[Empty_Map represents the empty Map object. It has a
222 length of 0. If an object of type Map is not otherwise initialized, it is
223 initialized to the same value as Empty_Map.]}
224
225 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
226 @ChgAdded{Version=[2],Text=[No_Element represents a cursor that designates no
227 node. If an object of type Cursor is not otherwise initialized, it is
228 initialized to the same value as No_Element.]}
229
230 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
231 @ChgAdded{Version=[2],Text=[The predefined "=" operator for type Cursor returns
232 True if both cursors are No_Element, or designate the same element in the same
233 container.]}
234
235 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
236 @ChgAdded{Version=[2],Text=[Execution of the default implementation of the
237 Input, Output, Read, or Write attribute of type Cursor raises Program_Error.]}
238
239 @begin{Reason}
240 @ChgRef{Version=[2],Kind=[AddedNormal]}
241 @ChgAdded{Version=[2],Text=[A cursor will probably be implemented in terms
242 of one or more access values, and the effects of streaming access values is
243 unspecified. Rather than letting the user stream junk by accident, we mandate
244 that streaming of cursors raise Program_Error by default. The attributes
245 can always be specified if there is a need to support streaming.]}
246 @end{Reason}
247
248 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]}
249 @ChgAdded{Version=[3],Text=[Map'Write for a Map object @i<M> writes
250 Length(@i<M>) elements of the map to the stream. It also may write
251 additional information about the map.]}
252
253 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]}
254 @ChgAdded{Version=[3],Text=[Map'Read reads the representation of a map
255 from the stream, and assigns to @i<Item> a map with the same length and
256 elements as was written by Map'Write.]}
257
258 @begin{Ramification}
259 @ChgRef{Version=[3],Kind=[AddedNormal]}
260 @ChgAdded{Version=[3],Text=[Streaming more elements than the container
261 length is wrong. For implementation implications of this rule, see the Implementation Note in
262 @RefSecNum{The Generic Package Containers.Vectors}.]}
263 @end{Ramification}
264
265
266 @begin{DescribeCode}
267
268 @begin{Example}
269 @ChgRef{Version=[3],Kind=[Added]}
270 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
271 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
272 @key[with] Nonblocking, Global => (@key[in all], @key[use null])],Old=[]};]}
273 @end{Example}
274
275 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
276 @ChgAdded{Version=[3],Type=[Trailing],Text=[Returns True if Position designates
277 an element, and returns False otherwise.]}
278
279 @begin{Honest}
280 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1],ARef=[AI05-0212-1]}
281 @ChgAdded{Version=[3],Text=[This function might not detect cursors that
282 designate deleted elements; such cursors are invalid (see below) and the
283 result of calling Has_Element with an invalid cursor is unspecified (but
284 not erroneous).]}
285 @end{Honest}
286
287 @begin{Example}
288 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
289 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Has_Element (Container : Map; Position : Cursor)
290 @key{return} Boolean
291 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
292 @end{Example}
293
294 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
295 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns True if Position designates
296 an element in Container, and returns False otherwise.]}
297
298 @begin{Ramification}
299 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
300 @ChgAdded{Version=[5],Text=[If Position is No_element, Has_Element returns
301 False.]}
302 @end{Ramification}
303 @begin{Example}
304 @ChgRef{Version=[2],Kind=[AddedNormal]}
305 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "=" (Left, Right : Map) @key{return} Boolean;]}
306 @end{Example}
307
308 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
309 @ChgAdded{Version=[2],Type=[Leading],Text=[If Left and Right denote the same
310 map object, then the function returns True. If Left and Right have different
311 lengths, then the function returns False. Otherwise, for each key @i<K> in
312 Left, the function returns False if:]}
313
314 @begin{Itemize}
315 @ChgRef{Version=[2],Kind=[AddedNormal]}
316 @ChgAdded{Version=[2],Text=[a key equivalent to @i<K> is not present
317 in Right; or]}
318
319 @ChgRef{Version=[2],Kind=[AddedNormal]}
320 @ChgAdded{Version=[2],Text=[the element associated with @i<K>
321 in Left is not equal to the element associated with @i<K> in Right (using the
322 generic formal equality operator for elements).]}
323 @end{Itemize}
324
325 @ChgRef{Version=[2],Kind=[AddedNormal]}
326 @ChgAdded{Version=[2],Type=[Trailing],Text=[If the function has not returned a
327 result after checking all of the keys, it returns True. Any exception raised
328 during evaluation of key equivalence or element equality is propagated.]}
329 @begin{ImplNote}
330 @ChgRef{Version=[2],Kind=[AddedNormal]}
331 @ChgAdded{Version=[2],Text=[This wording describes the canonical semantics.
332 However, the order and number of calls on the formal equality function is
333 unspecified for all of the operations that use it in this package, so an
334 implementation can call it as many or as few times as it needs to get the
335 correct answer. Specifically, there is no requirement to call the formal
336 equality additional times once the answer has been determined.]}
337 @end{ImplNote}
338
339 @begin{Example}
340 @ChgRef{Version=[5],Kind=[Added]}
341 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Tampering_With_Cursors_Prohibited
342 (Container : Map) @key{return} Boolean
343 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
344 @end{Example}
345
346 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
347 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns True if tampering with
348 cursors or tampering with elements is currently prohibited for Container, and
349 returns False otherwise.]}
350
351 @begin{Reason}
352 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
353 @ChgAdded{Version=[5],Text=[Prohibiting tampering with elements also
354 needs to prohibit tampering with cursors, as deleting an element is similar
355 to replacing it.]}
356 @end{Reason}
357
358 @begin{ImplNote}
359 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
360 @ChgAdded{Version=[5],Text=[Various contracts elsewhere in this specification
361 require that this function is implemented with synchronized data. Moreover,
362 it is possible for tampering to be prohibited by multiple operations
363 (sequentiually or in parallel). Therefore, tampering needs to be
364 implemented with an atomic or protected counter. The counter is initialized
365 to zero, and is incremented when tampering is prohibited, and decremented
366 when leaving an area that prohibited tampering. Function
367 Tampering_With_Cursors_Prohibited returns True if the counter is nonzero.
368 (Note that any case where the result is not well-defined for one task
369 is incorrect use of shared variables and would be erroneous by the rules
370 of @RefSecNum{Shared Variables}, so no special protection is needed to
371 read the counter.)]}
372 @end{ImplNote}
373
374 @begin{Example}
375 @ChgRef{Version=[5],Kind=[Added]}
376 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Tampering_With_Elements_Prohibited
377 (Container : Map) @key{return} Boolean
378 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
379 @end{Example}
380
381 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
382 @ChgAdded{Version=[5],Type=[Trailing],Text=[Always returns False@Redundant[,
383 regardless of whether tampering with elements is prohibited].]}
384
385 @begin{Reason}
386 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1]}
387 @ChgAdded{Version=[5],Text=[A definite element cannot
388 change size, so we allow operations that tamper with elements even when
389 tampering with elements is prohibited. That's not true for the indefinite
390 containers, which is why this kind of tampering exists.]}
391 @end{Reason}
392
393 @begin{Example}
394 @ChgRef{Version=[2],Kind=[AddedNormal]}
395 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
396 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Length (Container : Map) @key{return} Count_Type@Chg{Version=[5],New=[
397 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
398 @end{Example}
399
400 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
401 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the number of nodes in Container.]}
402
403 @begin{Example}
404 @ChgRef{Version=[2],Kind=[AddedNormal]}
405 @ChgRef{Version=[5],Kind=[Revised]}
406 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Is_Empty (Container : Map) @key{return} Boolean@Chg{Version=[5],New=[
407 @key[with] Nonblocking, Global => (@key[null], @key[use null]),
408 Post => Is_Empty'Result = (Length (Container) = 0)],Old=[]};]}
409 @end{Example}
410
411 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
412 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
413 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[Returns True
414 if Container is empty],Old=[Equivalent to Length (Container) = 0]}.]}
415
416 @begin{Example}
417 @ChgRef{Version=[2],Kind=[AddedNormal]}
418 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
419 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Clear (Container : @key{in out} Map)@Chg{Version=[5],New=[
420 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
421 @key[or else raise] Program_Error,
422 Post => Length (Container) = 0],Old=[]};]}
423 @end{Example}
424
425 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
426 @ChgAdded{Version=[2],Type=[Trailing],Text=[Removes all the nodes from Container.]}
427
428 @begin{Example}
429 @ChgRef{Version=[2],Kind=[AddedNormal]}
430 @ChgRef{Version=[5],Kind=[Revised]}
431 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Key (Position : Cursor) @key{return} Key_Type@Chg{Version=[5],New=[
432 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
433 Nonblocking => Key_Type'Nonblocking,
434 Global => (@key{in all}, @key{use} Key_Type)],Old=[]};]}
435 @end{Example}
436
437 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
438 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
439 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
440 Position equals No_Element, then Constraint_Error is propagated.
441 Otherwise, ]}Key returns the key component of the node designated
442 by Position.]}
443
444 @begin{Example}
445 @ChgRef{Version=[5],Kind=[Added]}
446 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Key (Container : Map;
447 Position : Cursor) @key{return} Key_Type
448 @key{with} Pre => (Position /= No_Element
449 @key{or else raise} Constraint_Error) @key{and then}
450 (Has_Element (Container, Position)
451 @key{or else raise} Program_Error),
452 Nonblocking => Key_Type'Nonblocking,
453 Global => (@key{null}, @key{use} Key_Type);]}
454 @end{Example}
455
456 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
457 @ChgAdded{Version=[5],Type=[Trailing],Text=[Key returns the key component
458 of the node designated by Position.]}
459
460 @begin{Example}
461 @ChgRef{Version=[2],Kind=[AddedNormal]}
462 @ChgRef{Version=[5],Kind=[Revised]}
463 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Element (Position : Cursor) @key{return} Element_Type@Chg{Version=[5],New=[
464 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
465 Nonblocking => Element_Type'Nonblocking,
466 Global => (@key{in all}, @key{use} Element_Type)],Old=[]};]}
467 @end{Example}
468
469 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
470 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
471 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
472 Position equals No_Element, then Constraint_Error is propagated. Otherwise,
473 ]}Element returns the element component of the node designated by Position.]}
474
475 @begin{Example}
476 @ChgRef{Version=[5],Kind=[Added]}
477 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Element (Container : Map;
478 Position : Cursor) @key{return} Element_Type
479 @key{with} Pre => (Position /= No_Element
480 @key{or else raise} Constraint_Error) @key{and then}
481 (Has_Element (Container, Position)
482 @key{or else raise} Program_Error),
483 Nonblocking => Element_Type'Nonblocking,
484 Global => (@key{null}, @key{use} Element_Type);]}
485 @end{Example}
486
487 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
488 @ChgAdded{Version=[5],Type=[Trailing],Text=[Element returns the element
489 component of the node designated by Position.]}
490
491 @begin{Example}
492 @ChgRef{Version=[2],Kind=[AddedNormal]}
493 @ChgRef{Version=[5],Kind=[Revised]}
494 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace_Element (Container : @key{in out} Map;
495 Position : @key{in} Cursor;
496 New_item : @key{in} Element_Type)@Chg{Version=[5],New=[
497 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
498 @key{or else raise} Program_Error) @key{and then}
499 (Position /= No_Element
500 @key{or else raise} Constraint_Error) @key{and then}
501 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
502 @end{Example}
503
504 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
505 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
506 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1],ARef=[AI12-0196-1]}
507 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
508 Position equals No_Element,
509 then Constraint_Error is propagated; if Position does not designate an element
510 in Container, then Program_Error is propagated.
511 Otherwise@Chg{Version=[3],New=[,],Old=[]} ]}Replace_Element
512 assigns New_Item to the element of the node designated by
513 Position.@Chg{Version=[5],New=[ For the purposes of
514 determining whether the parameters overlap in a call to Replace_Element, the
515 Container parameter is not considered to overlap with any object
516 @Redundant[(including itself)].],Old=[]}]}
517
518 @begin{Example}
519 @ChgRef{Version=[2],Kind=[AddedNormal]}
520 @ChgRef{Version=[5],Kind=[Revised]}
521 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Query_Element
522 (Position : @key{in} Cursor;
523 Process : @key{not null access procedure} (Key : @key{in} Key_Type;
524 Element : @key{in} Element_Type))@Chg{Version=[5],New=[
525 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
526 Global => @key{in all}],Old=[]};]}
527 @end{Example}
528
529 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
530 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1],ARef=[AI05-0265-1]}
531 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
532 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
533 Position equals No_Element, then
534 Constraint_Error is propagated. Otherwise, ]}Query_Element calls
535 Process.@key{all} with the key and element from the node designated by Position
536 as the arguments.
537 @Chg{Version=[3],New=[Tampering],Old=[Program_Error
538 is propagated if Process.@key{all} tampers]}
539 with the elements of @Chg{Version=[3],New=[the map that contains the
540 element designated by Position is prohibited during the
541 execution of the call on Process.@key{all}],Old=[Container]}. Any exception raised by
542 Process.@key{all} is propagated.]}
543
544 @begin{Example}
545 @ChgRef{Version=[5],Kind=[Added]}
546 @ChgAdded{Version=[5],Text=[@key{procedure} Query_Element
547 (Container : @key{in} Map;
548 Position : @key{in} Cursor;
549 Process : @key{not null access procedure} (Key : @key{in} Key_Type;
550 Element : @key{in} Element_Type))
551 @key{with} Pre => (Position /= No_Element
552 @key{or else raise} Constraint_Error) @key{and then}
553 (Has_Element (Container, Position)
554 @key{or else raise} Program_Error);]}
555 @end{Example}
556
557 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
558 @ChgAdded{Version=[5],Type=[Trailing],Text=[Query_Element calls
559 Process.@key{all} with the key and element from the node designated by Position
560 as the arguments. Tampering with the elements of Container is prohibited during the execution of the call on
561 Process.@key{all}. Any exception raised by Process.@key{all} is propagated.]}
562
563
564 @begin{Example}
565 @ChgRef{Version=[2],Kind=[AddedNormal]}
566 @ChgRef{Version=[5],Kind=[Revised]}
567 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Update_Element
568 (Container : @key{in out} Map;
569 Position : @key{in} Cursor;
570 Process : @key{not null access procedure} (Key : @key{in} Key_Type;
571 Element : @key{in out} Element_Type))@Chg{Version=[5],New=[
572 @key{with} Pre => (Position /= No_Element @key{or else raise} Constraint_Error) @key{and then}
573 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
574 @end{Example}
575
576 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
577 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1],ARef=[AI05-0265-1]}
578 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
579 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[If
580 Position equals No_Element, then
581 Constraint_Error is propagated; if Position does not designate an element in
582 Container, then Program_Error is propagated.
583 Otherwise@Chg{Version=[3],New=[,],Old=[]} ]}Update_Element calls
584 Process.@key{all} with the key and element from the node designated by Position
585 as the arguments. @Chg{Version=[3],New=[Tampering],Old=[Program_Error
586 is propagated if Process.@key{all} tampers]}
587 with the elements of Container@Chg{Version=[3],New=[ is prohibited during the
588 execution of the call on Process.@key{all}],Old=[]}. Any exception raised by
589 Process.@key{all} is propagated.]}
590
591 @ChgRef{Version=[2],Kind=[AddedNormal]}
592 @ChgAdded{Version=[2],Type=[Trailing],Type=[Trailing],Text=[If Element_Type is
593 unconstrained and definite, then the actual Element parameter of Process.@key{all}
594 shall be unconstrained.]}
595
596 @begin{Ramification}
597 @ChgRef{Version=[2],Kind=[AddedNormal]}
598 @ChgAdded{Version=[2],Text=[This means that the elements cannot be directly
599 allocated from the heap; it must be possible to change the discriminants
600 of the element in place.]}
601 @end{Ramification}
602
603 @begin{Example}
604 @ChgRef{Version=[3],Kind=[Added]}
605 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
606 @ChgAdded{Version=[3],Text=[@key[type] Constant_Reference_Type
607 (Element : @key[not null access constant] Element_Type) @key[is private]
608 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
609 Nonblocking, Global =>@key[in out synchronized],
610 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
611
612 @ChgRef{Version=[3],Kind=[Added]}
613 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
614 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[type] Reference_Type (Element : @key[not null access] Element_Type) @key[is private]
615 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
616 Nonblocking, Global => @key[in out synchronized],
617 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
618 @end{Example}
619
620 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
621 @ChgAdded{Version=[3],Type=[Trailing],Text=[The types Constant_Reference_Type
622 and Reference_Type need finalization.@PDefn2{Term=<needs finalization>,
623 Sec=<language-defined type>}]}
624
625 @ChgRef{Version=[3],Kind=[Added]}
626 @ChgRef{Version=[5],Kind=[DeletedAdded],ARef=[AI12-0112-1]}
627 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[The default
628 initialization of an object of type
629 Constant_Reference_Type or Reference_Type propagates Program_Error.]}]}
630
631 @begin{Reason}
632 @ChgRef{Version=[3],Kind=[AddedNormal]}
633 @ChgAdded{Version=[3],Text=[It is expected that Reference_Type (and
634 Constant_Reference_Type) will be a controlled type, for which finalization
635 will have some action to terminate the tampering check for the associated
636 container. If the object is created by default, however, there is no
637 associated container. Since this is useless, and supporting this case would
638 take extra work, we define it to raise an exception.]}
639 @end{Reason}
640
641 @begin{Example}
642 @ChgRef{Version=[3],Kind=[Added]}
643 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
644 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] Map;
645 Position : @key[in] Cursor)
646 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
647 @key[with] Pre => (Position /= No_Element
648 @key[or else raise] Constraint_Error) @key[and then]
649 (Has_Element (Container, Position)
650 @key[or else raise] Program_Error),
651 Post => Tampering_With_Cursors_Prohibited (Container),
652 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
653 @end{Example}
654
655 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
656 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
657 Constant_Indexing and Implicit_Dereference aspects) provides a convenient way to
658 gain read access to an individual element of a Map given a
659 cursor.]}
660
661 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]}
662 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
663 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[If
664 Position equals No_Element, then Constraint_Error
665 is propagated; if Position does not designate an element in Container, then
666 Program_Error is propagated. Otherwise, ]}Constant_Reference returns an object
667 whose discriminant is an access value that designates the element designated by
668 Position. Tampering with the elements of Container is prohibited while the
669 object returned by Constant_Reference exists and has not been finalized.]}
670
671 @begin{Example}
672 @ChgRef{Version=[3],Kind=[Added]}
673 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
674 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference (Container : @key[aliased in out] Map;
675 Position : @key[in] Cursor)
676 @key[return] Reference_Type@Chg{Version=[5],New=[
677 @key[with] Pre => (Position /= No_Element
678 @key[or else raise] Constraint_Error) @key[and then]
679 (Has_Element (Container, Position)
680 @key[or else raise] Program_Error),
681 Post => Tampering_With_Cursors_Prohibited (Container),
682 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
683 @end{Example}
684
685 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
686 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
687 Variable_Indexing and Implicit_Dereference aspects) provides a convenient way to
688 gain read and write access to an individual element of a Map given
689 a cursor.]}
690
691 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]}
692 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
693 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[If
694 Position equals No_Element, then Constraint_Error
695 is propagated; if Position does not designate an element in Container, then
696 Program_Error is propagated. Otherwise, ]}Reference returns an object whose
697 discriminant is an access value that designates the element designated by
698 Position. Tampering with the elements of Container is prohibited while the
699 object returned by Reference exists and has not been finalized.]}
700
701 @begin{Example}
702 @ChgRef{Version=[3],Kind=[Added]}
703 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
704 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] Map;
705 Key : @key[in] Key_Type)
706 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
707 @key[with] Pre => Find (Container, Key) /= No_Element @key[or else raise] Constraint_Error,
708 Post => Tampering_With_Cursors_Prohibited (Container),
709 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
710 @end{Example}
711
712 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
713 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
714 Constant_Indexing and Implicit_Dereference aspects) provides a convenient way to
715 gain read access to an individual element of a map given a key value.]}
716
717 @ChgRef{Version=[3],Kind=[Added]}
718 @ChgAdded{Version=[3],Text=[Equivalent to
719 Constant_Reference (Container, Find (Container, Key)).]}
720
721 @begin{Example}
722 @ChgRef{Version=[3],Kind=[Added]}
723 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
724 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference (Container : @key[aliased in out] Map;
725 Key : @key[in] Key_Type)
726 @key[return] Reference_Type@Chg{Version=[5],New=[
727 @key[with] Pre => Find (Container, Key) /= No_Element @key[or else raise] Constraint_Error,
728 Post => Tampering_With_Cursors_Prohibited (Container),
729 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
730 @end{Example}
731
732 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
733 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
734 Variable_Indexing and Implicit_Dereference aspects) provides a convenient way to
735 gain read and write access to an individual element of a map given
736 a key value.]}
737
738 @ChgRef{Version=[3],Kind=[Added]}
739 @ChgAdded{Version=[3],Text=[Equivalent to Reference (Container, Find (Container, Key)).]}
740
741 @begin{Example}
742 @ChgRef{Version=[3],Kind=[Added]}
743 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
744 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key{procedure} Assign (Target : @key{in out} Map; Source : @key{in} Map)@Chg{Version=[5],New=[
745 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Target)
746 @key[or else raise] Program_Error,
747 Post => Length (Source) = Length (Target)],Old=[]};]}
748 @end{Example}
749
750 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0248-1]}
751 @ChgAdded{Version=[3],Type=[Trailing],Text=[If Target denotes the same object as
752 Source, the operation has no effect. Otherwise, the key/element pairs of Source
753 are copied to Target as for an @nt{assignment_statement} assigning Source to
754 Target.]}
755 @begin{Discussion}
756 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1]}
757 @ChgAdded{Version=[3],Text=[This routine exists for compatibility with the
758 bounded map containers. For an unbounded map, @exam{Assign(A, B)} and
759 @exam{A := B} behave identically. For a bounded map, := will raise an
760 exception if the container capacities are different, while Assign will
761 not raise an exception if there is enough room in the target.]}
762 @end{Discussion}
763
764 @begin{Example}
765 @ChgRef{Version=[2],Kind=[AddedNormal]}
766 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
767 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Move (Target : @key{in out} Map;
768 Source : @key{in out} Map)@Chg{Version=[5],New=[
769 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
770 @key{or else raise} Program_Error) @key{and then}
771 (@key{not} Tampering_With_Cursors_Prohibited (Source)
772 @key{or else raise} Program_Error),
773 Post => (@key{if} Target = Source @key{then} True
774 @key{else}
775 Length (Target) = Length (Source'Old) @key{and then}
776 Length (Source) = 0)],Old=[]};]}
777 @end{Example}
778
779 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
780 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0262-1]}
781 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Target denotes the same object
782 as Source, then @Chg{Version=[3],New=[the operation],Old=[Move]}
783 has no effect. Otherwise, @Chg{Version=[3],New=[the operation is equivalent
784 to Assign (Target, Source) followed by Clear (Source)],Old=[Move first calls
785 Clear (Target). Then, each node from Source is removed from Source and inserted
786 into Target. The length of Source is 0 after a successful call to Move]}.]}
787
788 @begin{Example}
789 @ChgRef{Version=[2],Kind=[AddedNormal]}
790 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
791 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Map;
792 Key : @key{in} Key_Type;
793 New_Item : @key{in} Element_Type;
794 Position : @key{out} Cursor;
795 Inserted : @key{out} Boolean)@Chg{Version=[5],New=[
796 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
797 @key{or else raise} Program_Error) @key{and then}
798 (Length (Container) <= Count_Type'Last - 1
799 @key{or else raise} Constraint_Error),
800 Post => (@key{declare}
801 Original_Length : @key{constant} Count_Type :=
802 Length (Container)'Old;
803 @key{begin}
804 Has_Element (Container, Position) @key{and then}
805 (@key{if} Inserted then
806 Length (Container) = Original_Length + 1
807 @key{else}
808 Length (Container) = Original_Length))],Old=[]};]}
809 @end{Example}
810
811 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
812 @ChgAdded{Version=[2],Type=[Trailing],Text=[Insert checks if a node with a key
813 equivalent to Key is already present in Container. If a match is found,
814 Inserted is set to False and Position designates the element with the matching
815 key. Otherwise, Insert allocates a new node, initializes it to Key and
816 New_Item, and adds it to Container; Inserted is set to True and Position
817 designates the newly-inserted node. Any exception raised during allocation is
818 propagated and Container is not modified.]}
819
820 @begin{Example}
821 @ChgRef{Version=[2],Kind=[AddedNormal]}
822 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
823 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Map;
824 Key : @key{in} Key_Type;
825 Position : @key{out} Cursor;
826 Inserted : @key{out} Boolean)@Chg{Version=[5],New=[
827 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
828 @key{or else raise} Program_Error) @key{and then}
829 (Length (Container) <= Count_Type'Last - 1
830 @key{or else raise} Constraint_Error),
831 Post => (@key{declare}
832 Original_Length : @key{constant} Count_Type :=
833 Length (Container)'Old;
834 @key{begin}
835 Has_Element (Container, Position) @key{and then}
836 (@key{if} Inserted then
837 Length (Container) = Original_Length + 1
838 @key{else}
839 Length (Container) = Original_Length))],Old=[]};]}
840 @end{Example}
841
842 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
843 @ChgAdded{Version=[2],Type=[Trailing],Text=[Insert inserts Key into Container
844 as per the five-parameter Insert, with the difference that an element
845 initialized by default (see @RefSecNum{Object Declarations}) is inserted.]}
846
847 @begin{Example}
848 @ChgRef{Version=[2],Kind=[AddedNormal]}
849 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
850 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Map;
851 Key : @key{in} Key_Type;
852 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
853 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
854 @key{or else raise} Program_Error) @key{and then}
855 (Length (Container) <= Count_Type'Last - 1
856 @key{or else raise} Constraint_Error),
857 Post => Length (Container) = Length (Container)'Old + 1],Old=[]};]}
858 @end{Example}
859
860 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
861 @ChgAdded{Version=[2],Type=[Trailing],Text=[Insert inserts Key and New_Item
862 into Container as per the five-parameter Insert, with the difference that if a
863 node with a key equivalent to Key is already in the map, then Constraint_Error
864 is propagated.]}
865
866 @begin{Ramification}
867 @ChgRef{Version=[2],Kind=[AddedNormal]}
868 @ChgAdded{Version=[2],Type=[Leading],Text=[This is equivalent to:]}
869 @begin{Example}
870 @ChgRef{Version=[2],Kind=[AddedNormal]}
871 @ChgAdded{Version=[2],Text=[@key{declare}
872 Inserted : Boolean; C : Cursor;
873 @key{begin}
874 Insert (Container, Key, New_Item, C, Inserted);
875 @key{if not} Inserted @key{then}
876 @key{raise} Constraint_Error;
877 @key{end if};
878 @key{end};]}
879 @end{Example}
880 @ChgRef{Version=[2],Kind=[AddedNormal]}
881 @ChgAdded{Version=[2],Text=[but doesn't require the hassle of
882 @key{out} parameters.]}
883 @end{Ramification}
884
885 @begin{Example}
886 @ChgRef{Version=[2],Kind=[AddedNormal]}
887 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
888 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Include (Container : @key{in out} Map;
889 Key : @key{in} Key_Type;
890 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
891 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
892 @key{or else raise} Program_Error) @key{and then}
893 (Length (Container) <= Count_Type'Last - 1
894 @key{or else raise} Constraint_Error),
895 Post => (@key{declare}
896 Original_Length : @key{constant} Count_Type :=
897 Length (Container)'Old;
898 @key{begin}
899 Length (Container)
900 @key{in} Original_Length | Original_Length + 1)],Old=[]};]}
901 @end{Example}
902
903 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
904 @ChgAdded{Version=[2],Type=[Trailing],Text=[Include inserts Key and New_Item
905 into Container as per the five-parameter Insert, with the difference that if a
906 node with a key equivalent to Key is already in the map, then this operation
907 assigns Key and New_Item to the matching node. Any exception raised during
908 assignment is propagated.]}
909
910 @begin{Ramification}
911 @ChgRef{Version=[2],Kind=[AddedNormal]}
912 @ChgAdded{Version=[2],Type=[Leading],Text=[This is equivalent to:]}
913 @begin{Example}
914 @ChgRef{Version=[2],Kind=[AddedNormal]}
915 @ChgAdded{Version=[2],Text=[@key{declare}
916 C : Cursor := Find (Container, Key);
917 @key{begin}
918 @key{if} C = No_Element @key{then}
919 Insert (Container, Key, New_Item);
920 @key{else}
921 Replace (Container, Key, New_Item);
922 @key{end if};
923 @key{end};]}
924 @end{Example}
925 @ChgRef{Version=[2],Kind=[AddedNormal]}
926 @ChgAdded{Version=[2],Text=[but this avoids doing the search twice.]}
927 @end{Ramification}
928
929 @begin{Example}
930 @ChgRef{Version=[2],Kind=[AddedNormal]}
931 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
932 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace (Container : @key{in out} Map;
933 Key : @key{in} Key_Type;
934 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
935 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
936 @key{or else raise} Program_Error,
937 Post => Length (Container) = Length (Container)'Old],Old=[]};]}
938 @end{Example}
939
940 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
941 @ChgAdded{Version=[2],Type=[Trailing],Text=[Replace checks if a node with a key
942 equivalent to Key is present in Container. If a match is found, Replace assigns
943 Key and New_Item to the matching node; otherwise, Constraint_Error is
944 propagated.]}
945
946 @begin{Discussion}
947 @ChgRef{Version=[2],Kind=[AddedNormal]}
948 @ChgAdded{Version=[2],Text=[We update the key as well as the
949 element, as the key might include additional information that does not
950 participate in equivalence. If only the element needs to be updated, use
951 Replace_Element (Find (Container, Key), New_Element).]}
952 @end{Discussion}
953
954 @begin{Example}
955 @ChgRef{Version=[2],Kind=[AddedNormal]}
956 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
957 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Exclude (Container : @key{in out} Map;
958 Key : @key{in} Key_Type)@Chg{Version=[5],New=[
959 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
960 @key{or else raise} Program_Error,
961 Post => (@key{declare}
962 Original_Length : @key{constant} Count_Type :=
963 Length (Container)'Old;
964 @key{begin}
965 Length (Container)
966 @key{in} Original_Length - 1 | Original_Length)],Old=[]};]}
967 @end{Example}
968
969 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
970 @ChgAdded{Version=[2],Type=[Trailing],Text=[Exclude checks if a node with a key
971 equivalent to Key is present in Container. If a match is found, Exclude removes
972 the node from the map.]}
973
974 @begin{Ramification}
975 @ChgRef{Version=[2],Kind=[AddedNormal]}
976 @ChgAdded{Version=[2],Text=[Exclude should work on an empty map; nothing
977 happens in that case.]}
978 @end{Ramification}
979
980 @begin{Example}
981 @ChgRef{Version=[2],Kind=[AddedNormal]}
982 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
983 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Map;
984 Key : @key{in} Key_Type)@Chg{Version=[5],New=[
985 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
986 @key{or else raise} Program_Error,
987 Post => Length (Container) = Length (Container)'Old - 1],Old=[]};]}
988 @end{Example}
989
990 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
991 @ChgAdded{Version=[2],Type=[Trailing],Text=[Delete checks if a node with a key
992 equivalent to Key is present in Container. If a match is found, Delete removes
993 the node from the map; otherwise, Constraint_Error is propagated.]}
994
995 @begin{Example}
996 @ChgRef{Version=[2],Kind=[AddedNormal]}
997 @ChgRef{Version=[5],Kind=[Revised]}
998 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Map;
999 Position : @key{in out} Cursor)@Chg{Version=[5],New=[
1000 @key{with} Pre => (@key{if} Tampering_With_Cursors_Prohibited (Container)
1001 @key{then raise} Program_Error) @key{and then}
1002 (Position /= No_Element
1003 @key{or else raise} Constraint_Error) @key{and then}
1004 (Has_Element (Container, Position)
1005 @key{or else raise} Program_Error),
1006 Post => Length (Container) = Length (Container)'Old - 1 @key{and then}
1007 Position = No_Element],Old=[]};]}
1008 @end{Example}
1009
1010 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1011 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1012 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
1013 Position equals No_Element, then Constraint_Error is propagated. If Position
1014 does not designate an element in Container, then Program_Error is propagated.
1015 Otherwise, ]}Delete removes the node designated by Position from the
1016 map.@Chg{Version=[5],New=[],Old=[ Position is set to No_Element on return.]}]}
1017
1018
1019 @begin{Ramification}
1020 @ChgRef{Version=[2],Kind=[AddedNormal]}
1021 @ChgAdded{Version=[2],Text=[The check on Position checks that the cursor does
1022 not belong to some other map. This check implies that a reference to the map
1023 is included in the cursor value. This wording is not meant to require
1024 detection of dangling cursors; such cursors are defined to be invalid, which
1025 means that execution is erroneous, and any result is allowed (including not
1026 raising an exception).]}
1027 @end{Ramification}
1028
1029 @begin{Example}
1030 @ChgRef{Version=[2],Kind=[AddedNormal]}
1031 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1032 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First (Container : Map) @key{return} Cursor@Chg{Version=[5],New=[
1033 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
1034 Post => (@key{if not} Is_Empty (Container)
1035 @key{then} Has_Element (Container, First'Result)
1036 @key{else} First'Result = No_Element)],Old=[]};]}
1037 @end{Example}
1038
1039 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1040 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Length (Container) = 0, then
1041 First returns No_Element. Otherwise, First returns a cursor that designates the
1042 first node in Container.]}
1043
1044 @begin{Example}
1045 @ChgRef{Version=[2],Kind=[AddedNormal]}
1046 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1047 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Next (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
1048 @key{with} Nonblocking, Global => (@key{in all}, @key{use null}),
1049 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
1050 @key{else} True)],Old=[]};]}
1051 @end{Example}
1052
1053 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1054 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a cursor that designates
1055 the successor of the node designated by Position. If Position designates the
1056 last node, then No_Element is returned. If Position equals No_Element, then
1057 No_Element is returned.]}
1058
1059 @begin{Example}
1060 @ChgRef{Version=[5],Kind=[Added]}
1061 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Next (Container : Map;
1062 Position : Cursor) @key{return} Cursor
1063 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
1064 Pre => Position = No_Element @key{or else}
1065 Has_Element (Container, Position)
1066 @key{or else raise} Program_Error,
1067 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
1068 @key{elsif} Next'Result = No_Element @key{then}
1069 Position = Last (Container)
1070 @key{else} Has_Element (Container, Next'Result));]}
1071 @end{Example}
1072
1073 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1074 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns a cursor designating the
1075 successor of the node designated by Position in Container.]}
1076
1077 @begin{Example}
1078 @ChgRef{Version=[2],Kind=[AddedNormal]}
1079 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1080 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Next (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
1081 @key{with} Nonblocking, Global => (@key{in all}, @key{use null})],Old=[]};]}
1082 @end{Example}
1083
1084 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1085 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Next (Position).]}
1086
1087 @begin{Example}
1088 @ChgRef{Version=[5],Kind=[Added]}
1089 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{procedure} Next (Container : @key{in} Map;
1090 Position : @key{in out} Cursor)
1091 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
1092 Pre => Position = No_Element @key{or else}
1093 Has_Element (Container, Position)
1094 @key{or else raise} Program_Error,
1095 Post => (@key{if} Position /= No_Element
1096 @key{then} Has_Element (Container, Position));]}
1097 @end{Example}
1098
1099 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1100 @ChgAdded{Version=[5],Type=[Trailing],Text=[Equivalent to Position := Next
1101 (Container, Position).]}
1102
1103 @begin{Example}
1104 @ChgRef{Version=[2],Kind=[AddedNormal]}
1105 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1106 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Find (Container : Map;
1107 Key : Key_Type) @key{return} Cursor@Chg{Version=[5],New=[
1108 @key{with} Post => (@key{if} Find'Result = No_Element @key{then} True
1109 @key{else} Has_Element (Container, Find'Result))],Old=[]};]}
1110 @end{Example}
1111
1112 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1113 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Length (Container) equals 0,
1114 then Find returns No_Element. Otherwise, Find checks if a node with a key
1115 equivalent to Key is present in Container. If a match is found, a cursor
1116 designating the matching node is returned; otherwise, No_Element is returned.]}
1117
1118 @begin{Example}
1119 @ChgRef{Version=[2],Kind=[AddedNormal]}
1120 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Element (Container : Map;
1121 Key : Key_Type) @key{return} Element_Type;]}
1122 @end{Example}
1123
1124 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1125 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Find (Container, Key)).]}
1126
1127 @begin{Example}
1128 @ChgRef{Version=[2],Kind=[AddedNormal]}
1129 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Contains (Container : Map;
1130 Key : Key_Type) @key{return} Boolean;]}
1131 @end{Example}
1132
1133 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1134 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Find (Container, Key) /= No_Element.]}
1135
1136 @begin{Example}
1137 @ChgRef{Version=[2],Kind=[AddedNormal]}
1138 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg]}
1139 @ChgAdded{Version=[2],KeepNext=[T],Text=[@Chg{Version=[3],New=[],Old=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean;]}]}
1140 @end{Example}
1141
1142 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1143 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]}
1144 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[],Old=[Returns True if Position designates
1145 an element, and returns False otherwise.]}]}
1146
1147 @begin{Honest}
1148 @ChgRef{Version=[2],Kind=[AddedNormal]}
1149 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]}
1150 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[This function may not detect cursors that
1151 designate deleted elements; such cursors are invalid (see below) and the
1152 result of calling Has_Element with an invalid cursor is unspecified (but
1153 not erroneous).]}]}
1154 @end{Honest}
1155 @begin{NotIso}
1156 @ChgAdded{Version=[3],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 72 and 73
1157 were moved above.>}]}@Comment{This message should be
1158 deleted if the paragraphs are ever renumbered.}
1159 @end{NotIso}
1160
1161 @begin{Example}
1162 @ChgRef{Version=[2],Kind=[AddedNormal]}
1163 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1164 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Iterate
1165 (Container : @key{in} Map;
1166 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
1167 @key{with} Allows_Exit],Old=[]};]}
1168 @end{Example}
1169
1170 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1171 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]}
1172 @ChgAdded{Version=[2],Type=[Trailing],Text=[Iterate calls Process.@key{all}
1173 with a cursor that designates each node in Container, starting with the first
1174 node and moving the cursor according to the successor relation.
1175 @Chg{Version=[3],New=[Tampering],Old=[Program_Error
1176 is propagated if Process.@key{all} tampers]}
1177 with the cursors of Container@Chg{Version=[3],New=[ is prohibited during the
1178 execution of a call on Process.@key{all}],Old=[]}. Any exception raised by
1179 Process.@key{all} is propagated.]}
1180
1181 @begin{ImplNote}
1182 @ChgRef{Version=[2],Kind=[AddedNormal]}
1183 @ChgAdded{Version=[2],Text=[The @lquotes@;tamper with cursors@rquotes@;
1184 check takes place when the operations that insert or delete elements, and
1185 so on, are called.]}
1186
1187 @ChgRef{Version=[2],Kind=[AddedNormal]}
1188 @ChgAdded{Version=[2],Text=[See Iterate for vectors
1189 (@RefSecNum{The Generic Package Containers.Vectors}) for a suggested
1190 implementation of the check.]}
1191 @end{ImplNote}
1192
1193 @end{DescribeCode}
1194
1195 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
1196 @ChgAdded{Version=[5],Text=[The nested package Stable
1197 provides a type Stable.Map that represents
1198 a @i<stable> map,@Defn2{Term=(stable),Sec=(map)} which is one that
1199 cannot grow and shrink. Such a list can be created by calling the
1200 Copy function, or by establishing a
1201 @i<stabilized view> of a regular map.@Defn2{Term=[stabilized view],Sec=[map]}]}
1202
1203 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
1204 @ChgAdded{Version=[5],Type=[Leading],Text=[The subprograms of the map package
1205 that have a parameter or result of type Map
1206 are included in the nested package Stable with the same specification, except
1207 that the following are omitted:]}
1208
1209 @begin{Indent}
1210 @ChgRef{Version=[5],Kind=[Added]}
1211 @ChgAdded{Version=[5],Text=[Tampering_With_Cursors_Prohibited,
1212 Tampering_With_Elements_Prohibited, Assign, Move,
1213 Insert, Include, Clear, Delete, Exclude, (for Ordered_Maps) Delete_First and
1214 Delete_Last, and (for Hashed_Maps) Reserve_Capacity]}
1215 @end{Indent}
1216
1217 @begin{Ramification}
1218 @ChgRef{Version=[5],Kind=[Added]}
1219 @ChgAdded{Version=[5],Text=[The names Map and Cursor mean the types
1220 declared in the nested package in these subprogram specifications.]}
1221 @end{Ramification}
1222 @begin{Reason}
1223 @ChgRef{Version=[5],Kind=[Added]}
1224 @ChgAdded{Version=[5],Text=[The omitted routines are those that tamper with
1225 cursors or elements (or test that state). The model is that it is
1226 impossible to tamper with cursors or elements of a stable view since no
1227 such operations are included. Thus tampering checks are not needed for
1228 a stable view, and we omit the operations associated with those checks.]}
1229 @end{Reason}
1230
1231 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
1232 @ChgAdded{Version=[5],Text=[The operations of this package are equivalent
1233 to those for regular maps, except that the calls to
1234 Tampering_With_Cursors_Prohibited and
1235 Tampering_With_Elements_Prohibited that occur in preconditions are replaced
1236 by False, and any that occur in postconditions are replaced by True.]}
1237
1238 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
1239 @ChgAdded{Version=[5],Text=[If a stable map is declared with the Base
1240 discriminant designating a pre-existing regular map, the stable map
1241 represents a stabilized view of the underlying regular map, and any operation
1242 on the stable map is reflected on the underlying regular map. While a
1243 stabilized view exists, any operation that tampers with elements performed on
1244 the underlying map is prohibited. The finalization of a stable map that
1245 provides such a view removes this restriction on the underlying regular map
1246 @Redundant[(though some other restriction might exist due to other concurrent
1247 iterations or stabilized views)].]}
1248
1249 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
1250 @ChgAdded{Version=[5],Text=[If a stable map is declared without specifying
1251 Base, the object must be initialized. The initializing expression of the stable
1252 map, @Redundant[typically a call on Copy], determines the Length
1253 of the map. The Length of a stable map never changes after
1254 initialization.]}
1255
1256 @end{StaticSem}
1257
1258 @begin{Bounded}
1259 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0022-1],ARef=[AI05-0248-1]}
1260 @ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}
1261 It is a bounded error for the actual function
1262 associated with a generic formal subprogram, when called as part of an
1263 operation of a map package, to tamper with elements of any map parameter of
1264 the operation. Either Program_Error is raised, or the operation works as
1265 defined on the value of the map either prior to, or subsequent to, some or
1266 all of the modifications to the
1267 map.@Defn2{Term=[Program_Error],Sec=(raised by detection of a bounded error)}]}
1268
1269 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0027-1]}
1270 @ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}
1271 It is a bounded error to call any subprogram
1272 declared in the visible part of a map package
1273 when the associated container has been finalized. If the operation takes
1274 Container as an @key[in out] parameter, then it raises Constraint_Error or
1275 Program_Error. Otherwise, the operation either proceeds as it would
1276 for an empty container, or it raises
1277 Constraint_Error@Defn2{Term=[Constraint_Error],Sec=(raised by detection of a bounded error)}
1278 or Program_Error.@Defn2{Term=[Program_Error],Sec=(raised by detection of a bounded error)}]}
1279 @end{Bounded}
1280
1281 @begin{Erron}
1282 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1283 @ChgAdded{Version=[2],Type=[Leading],Text=[
1284 A Cursor value is @i{invalid} if any of the following have occurred since it was
1285 created:@Defn2{Term=[invalid cursor],Sec=[of a map]}
1286 @PDefn2{Term=[cursor],Sec=[invalid]}]}
1287
1288 @begin{Itemize}
1289 @ChgRef{Version=[2],Kind=[AddedNormal]}
1290 @ChgAdded{Version=[2],Text=[The map that contains the node it designates has
1291 been finalized;]}
1292
1293 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0160-1]}
1294 @ChgAdded{Version=[3],Text=[The map that contains the node it designates has
1295 been used as the Target of a call to Assign, or as the target of an
1296 @nt{assignment_statement};]}
1297
1298 @ChgRef{Version=[2],Kind=[AddedNormal]}
1299 @ChgAdded{Version=[2],Text=[The map that contains the node it designates has
1300 been used as the Source or Target of a call to Move; or]}
1301
1302 @ChgRef{Version=[2],Kind=[AddedNormal]}
1303 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0160-1],ARef=[AI05-0262-1]}
1304 @ChgAdded{Version=[2],Text=[The node it designates has been
1305 @Chg{Version=[3],New=[removed],Old=[deleted]} from the map@Chg{Version=[3],New=[
1306 that previously contained the node],Old=[]}.]}
1307 @begin{Ramification}
1308 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]}
1309 @ChgAdded{Version=[3],Text=[This can happen directly via calls to Clear,
1310 Exclude, and Delete.]}
1311 @end{Ramification}
1312 @end{Itemize}
1313
1314 @ChgRef{Version=[2],Kind=[AddedNormal]}
1315 @ChgAdded{Version=[2],Text=[The result of "=" or Has_Element is unspecified if
1316 these functions are called with an invalid cursor parameter.@PDefn{unspecified}
1317 Execution is erroneous if any other subprogram declared in
1318 Containers.Hashed_Maps or Containers.Ordered_Maps is called with an invalid
1319 cursor parameter.@PDefn2{Term=(erroneous execution),Sec=(cause)}]}
1320
1321 @begin{Discussion}
1322 @ChgRef{Version=[2],Kind=[AddedNormal]}
1323 @ChgAdded{Version=[2],Text=[The list above is intended to be exhaustive. In
1324 other cases, a cursor value continues to designate its original element. For
1325 instance, cursor values survive the insertion and deletion of other nodes.]}
1326
1327 @ChgRef{Version=[2],Kind=[AddedNormal]}
1328 @ChgAdded{Version=[2],Text=[While it is possible to check for these cases, in
1329 many cases the overhead necessary to make the check is substantial in time or
1330 space. Implementations are encouraged to check for as many of these cases as
1331 possible and raise Program_Error if detected.]}
1332 @end{Discussion}
1333
1334 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1335 @ChgAdded{Version=[3],Text=[Execution is erroneous if the map associated with
1336 the result of a call to Reference or Constant_Reference is finalized before the
1337 result object returned by the call to Reference or Constant_Reference is
1338 finalized.]}
1339 @begin{Reason}
1340 @ChgRef{Version=[3],Kind=[AddedNormal]}
1341 @ChgAdded{Version=[3],Text=[Each object of Reference_Type and
1342 Constant_Reference_Type probably contains some reference to the originating
1343 container. If that container is prematurely finalized (which is only possible
1344 via Unchecked_Deallocation, as accessibility checks prevent passing a
1345 container to Reference that will not live as long as the result), the
1346 finalization of the object of Reference_Type will try to access a nonexistent
1347 object. This is a normal case of a dangling pointer created by
1348 Unchecked_Deallocation; we have to explicitly mention it here as the pointer
1349 in question is not visible in the specification of the type. (This is the same
1350 reason we have to say this for invalid cursors.)]}
1351 @end{Reason}
1352 @end{Erron}
1353
1354 @begin{ImplReq}
1355 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1356 @ChgAdded{Version=[2],Text=[No storage associated with a Map object shall be
1357 lost upon assignment or scope exit.]}
1358
1359 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1360 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]}
1361 @ChgAdded{Version=[2],Text=[The execution of an @nt{assignment_statement} for
1362 a map shall have the effect of copying the elements from the source map
1363 object to the target map object@Chg{Version=[3],New=[ and changing the length
1364 of the target object to that of the source object],Old=[]}.]}
1365
1366 @begin{ImplNote}
1367 @ChgRef{Version=[2],Kind=[AddedNormal]}
1368 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0298-1]}
1369 @ChgAdded{Version=[2],Text=[An assignment of a Map is a @lquotes@;deep@rquotes
1370 copy; that is the elements are copied as well as the data structures.
1371 We say @lquotes@;effect of@rquotes in order to allow the implementation to
1372 avoid copying elements immediately if it wishes. For instance, an
1373 implementation that avoided copying until one of the containers is modified
1374 would be allowed.@Chg{Version=[3],New=[ (Note that this implementation would
1375 require care, see @RefSecNum{The Generic Package Containers.Vectors} for more.)],Old=[]}]}
1376 @end{ImplNote}
1377 @end{ImplReq}
1378
1379 @begin{ImplAdvice}
1380 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1381 @ChgAdded{Version=[2],Text=[Move should not copy elements, and should minimize
1382 copying of internal data structures.]}
1383 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
1384 Text=[Move for a map should not copy elements, and should
1385 minimize copying of internal data structures.]}]}
1386
1387 @begin{ImplNote}
1388 @ChgRef{Version=[2],Kind=[AddedNormal]}
1389 @ChgAdded{Version=[2],Text=[Usually that can be accomplished simply by
1390 moving the pointer(s) to the internal data structures from the Source
1391 container to the Target container.]}
1392 @end{ImplNote}
1393
1394 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1395 @ChgAdded{Version=[2],Text=[If an exception is propagated from a map
1396 operation, no storage should be lost, nor any elements removed from a map
1397 unless specified by the operation.]}
1398 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
1399 Text=[If an exception is propagated from a map
1400 operation, no storage should be lost, nor any elements removed from a map
1401 unless specified by the operation.]}]}
1402
1403 @begin{Reason}
1404 @ChgRef{Version=[2],Kind=[AddedNormal]}
1405 @ChgAdded{Version=[2],Text=[This is important so that programs can recover
1406 from errors. But we don't want to require heroic efforts, so we just require
1407 documentation of cases where this can't be accomplished.]}
1408 @end{Reason}
1409
1410 @end{ImplAdvice}
1411
1412 @begin{DiffWord95}
1413 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1414 @ChgAdded{Version=[2],Text=[This description of maps is new; the
1415 extensions are documented with the specific packages.]}
1416 @end{DiffWord95}
1417
1418 @begin{Extend2005}
1419 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]}
1420 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
1421 Added reference support to make map containers more
1422 convenient to use.]}
1423 @end{Extend2005}
1424
1425 @begin{DiffWord2005}
1426 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
1427 @ChgAdded{Version=[3],Text=[Added procedure Assign;
1428 the extension and incompatibility is documented with the specific packages.]}
1429
1430 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
1431 @ChgAdded{Version=[3],Text=[Generalized the definition
1432 of Move. Specified which elements are read/written by stream attributes.]}
1433
1434 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0022-1]}
1435 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName
1436 to cover tampering by generic actual subprograms.]}
1437
1438 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0027-1]}
1439 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName
1440 to cover access to finalized map containers.]}
1441
1442 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]}
1443 @ChgAdded{Version=[3],Text=[@b<Correction:> Revised the definition
1444 of invalid cursors to cover missing (and new) cases.]}
1445
1446 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0265-1]}
1447 @ChgAdded{Version=[3],Text=[@b<Correction:> Defined when a container
1448 prohibits tampering in order to more clearly define where the check is
1449 made and the exception raised.]}
1450 @end{DiffWord2005}
1451
1452 @begin{Inconsistent2012}
1453 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1]}
1454 @ChgAdded{Version=[5],Text=[@Defn{inconsistencies with Ada 2012}@b<Corrigendum:>
1455 Tampering with elements is now defined to be equivalent to tampering with
1456 cursors for regular containers. If a program requires tampering detection
1457 to work, it might fail in Ada 202x. Needless to say, this shouldn't happen
1458 outside of test programs. See @Inconsistent2012Title in
1459 @RefSecNum{The Generic Package Containers.Vectors} for more details.]}
1460 @end{Inconsistent2012}
1461
1462 @begin{Extend2012}
1463 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0196-1]}
1464 @ChgAdded{Version=[5],Text=[@Defn{extensions to Ada 2012}@b{Correction:}
1465 Replace_Element is now defined such that it can be used
1466 concurrently so long as it operates on different elements. This allows
1467 some container operations to be used in parallel without separate
1468 synchronization.]}
1469 @end{Extend2012}
1470
1471 @begin{DiffWord2012}
1472 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0110-1]}
1473 @ChgAdded{Version=[4],Text=[@b<Corrigendum:> Clarified that tampering checks
1474 precede all other checks made by a subprogram (but come after those associated
1475 with the call).]}
1476
1477 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
1478 @ChgAdded{Version=[5],Text=[Added contracts to this container. This includes
1479 describing some of the semantics with pre- and postconditions, rather than
1480 English text. Note that the preconditions can be Suppressed (see
1481 @RefSecNum{Suppressing Checks}).]}
1482 @end{DiffWord2012}
1483
1484
1485 @LabeledAddedSubclause{Version=[2],Name=[The Generic Package Containers.Hashed_Maps]}
1486
1487 @begin{StaticSem}
1488
1489 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
1490 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library
1491 package Containers.Hashed_Maps has the following declaration:]}
1492 @begin{Example}
1493 @ChgRef{Version=[2],Kind=[AddedNormal]}
1494 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0084-1],ARef=[AI05-0212-1]}
1495 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1496 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[@key[with] Ada.Iterator_Interfaces;
1497 ],Old=[]}@key{generic}
1498 @key{type} Key_Type @key{is private};
1499 @key{type} Element_Type @key{is private};
1500 @key{with function} Hash (Key : Key_Type) @key{return} Hash_Type;
1501 @key{with function} Equivalent_Keys (Left, Right : Key_Type)
1502 @key{return} Boolean;
1503 @key{with function} "=" (Left, Right : Element_Type)
1504 @key{return} Boolean @Chg{Version=[3],New=[@b<is>],Old=[is]} <>;
1505 @key{package} Ada.Containers.Hashed_Maps@Chg{Version=[5],New=[],Old=[ @key{is}]}@ChildUnit{Parent=[Ada.Containers],Child=[Hashed_Maps]}@Chg{Version=[5],New=[
1506 @key[with] Preelaborate, Remote_Types,
1507 Nonblocking, Global => @key[null] @key[is]],Old=[
1508 @key{pragma} Preelaborate(Hashed_Maps);@Chg{Version=[3],New=[
1509 @key{pragma} Remote_Types(Hashed_Maps);],Old=[]}]}]}
1510
1511 @begin{Discussion}
1512 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
1513 @ChgAdded{Version=[5],Text=[For discussion on the reasons and meaning of
1514 the specifications of the Global and Nonblocking aspects in this generic
1515 package, see the notes on the equivalent operations in the specification
1516 of the Containers.Vectors package (see
1517 @RefSecNum{The Generic Package Containers.Vectors}).]}
1518 @end{Discussion}
1519
1520 @ChgRef{Version=[2],Kind=[AddedNormal]}
1521 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]}
1522 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0111-1],ARef=[AI12-0112-1],ARef=[AI12-0212-1],ARef=[AI12-0339-1]}
1523 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Map} @key{is tagged private}@Chg{Version=[3],New=[
1524 @key[with] Constant_Indexing => Constant_Reference,
1525 Variable_Indexing => Reference,
1526 Default_Iterator => Iterate,
1527 Iterator_Element => Element_Type],Old=[]}@Chg{Version=[5],New=[,
1528 Iterator_View => Stable.Map,
1529 Aggregate => (Empty => Empty,
1530 Add_Named => Insert),
1531 Stable_Properties => (Length,
1532 Tampering_With_Cursors_Prohibited,
1533 Tampering_With_Elements_Prohibited),
1534 Default_Initial_Condition =>
1535 Length (Map) = 0 @key{and then}
1536 (@key{not} Tampering_With_Cursors_Prohibited (Map)) @key{and then}
1537 (@key{not} Tampering_With_Elements_Prohibited (Map))],Old=[]};
1538 @key{pragma} Preelaborable_Initialization(Map);]}
1539
1540 @begin{Discussion}
1541 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
1542 @ChgAdded{Version=[5],Text=[Unlike a Vector, the Stable_Properties of a
1543 Hashed_Map do not include the Capacity. If we had included it, some of the
1544 otherwise shared definitions would need different postconditions for
1545 Hashed_Maps and Ordered_Maps. If we were starting these containers from
1546 scratch, we probably would have approached the sharing of definitions
1547 differently so that we could avoid issues like this, but a major
1548 reorganization of this existing material would be too much change.]}
1549 @end{Discussion}
1550
1551 @ChgRef{Version=[2],Kind=[AddedNormal]}
1552 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private};
1553 @key{pragma} Preelaborable_Initialization(Cursor);]}
1554
1555 @ChgRef{Version=[2],Kind=[AddedNormal]}
1556 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{Empty_Map} : @key{constant} Map;]}
1557
1558 @ChgRef{Version=[2],Kind=[AddedNormal]}
1559 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]}
1560
1561 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1562 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1563 @ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
1564 @key[with] Nonblocking, Global => (@key[in all], @key[use null])],Old=[]};]}
1565
1566 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1567 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Has_Element} (Container : Map; Position : Cursor)
1568 @key{return} Boolean
1569 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
1570
1571 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1572 @ChgRef{Version=[5],Kind=[RevisedAdded]}@ChgNote{Just a paragraph number change}
1573 @ChgAdded{Version=[3],Text=[ @key[package] @AdaPackDefn{Map_Iterator_Interfaces} @key[is new]
1574 Ada.Iterator_Interfaces (Cursor, Has_Element);]}
1575
1576 @ChgRef{Version=[2],Kind=[AddedNormal]}
1577 @ChgAdded{Version=[2],Text=[ @key{function} "=" (Left, Right : Map) @key{return} Boolean;]}
1578
1579 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1580 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Tampering_With_Cursors_Prohibited}
1581 (Container : Map) @key{return} Boolean
1582 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
1583
1584 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1585 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Tampering_With_Elements_Prohibited}
1586 (Container : Map) @key{return} Boolean
1587 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
1588
1589 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0339-1]}
1590 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Empty} (Capacity : Count_Type := @RI{implementation-defined})
1591 @key[return] Map
1592 @key[with] Post =>
1593 Capacity (Empty'Result) >= Capacity @key[and then]
1594 @key[not] Tampering_With_Elements_Prohibited (Empty'Result) @key[and then]
1595 @key[not] Tampering_With_Cursors_Prohibited (Empty'Result) @key[and then]
1596 Length (Empty'Result) = 0;]}
1597
1598 @ChgRef{Version=[2],Kind=[AddedNormal]}
1599 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1600 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Capacity} (Container : Map) @key{return} Count_Type@Chg{Version=[5],New=[
1601 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
1602
1603 @ChgRef{Version=[2],Kind=[AddedNormal]}
1604 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1605 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reserve_Capacity} (Container : @key{in out} Map;
1606 Capacity : @key{in} Count_Type)@Chg{Version=[5],New=[
1607 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
1608 @key[or else raise] Program_Error,
1609 Post => Container.Capacity >= Capacity],Old=[]};]}
1610
1611 @ChgRef{Version=[2],Kind=[AddedNormal]}
1612 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1613 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Length} (Container : Map) @key{return} Count_Type@Chg{Version=[5],New=[
1614 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
1615
1616 @ChgRef{Version=[2],Kind=[AddedNormal]}
1617 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1618 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Empty} (Container : Map) @key{return} Boolean@Chg{Version=[5],New=[
1619 @key[with] Nonblocking, Global => (@key[null], @key[use null]),
1620 Post => Is_Empty'Result = (Length (Container) = 0)],Old=[]};]}
1621
1622 @ChgRef{Version=[2],Kind=[AddedNormal]}
1623 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1624 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Clear} (Container : @key{in out} Map)@Chg{Version=[5],New=[
1625 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
1626 @key[or else raise] Program_Error,
1627 Post => Capacity (Container) = Capacity (Container)'Old @key{and then}
1628 Length (Container) = 0],Old=[]};]}
1629
1630 @ChgRef{Version=[2],Kind=[AddedNormal]}
1631 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1632 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Key} (Position : Cursor) @key{return} Key_Type@Chg{Version=[5],New=[
1633 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
1634 Nonblocking => Key_Type'Nonblocking,
1635 Global => (@key{in all}, @key{use} Key_Type)],Old=[]};]}
1636
1637 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1638 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Key} (Container : Map;
1639 Position : Cursor) @key{return} Key_Type
1640 @key{with} Pre => (Position /= No_Element
1641 @key{or else raise} Constraint_Error) @key{and then}
1642 (Has_Element (Container, Position)
1643 @key{or else raise} Program_Error),
1644 Nonblocking => Key_Type'Nonblocking,
1645 Global => (@key{null}, @key{use} Key_Type);]}
1646
1647 @ChgRef{Version=[2],Kind=[AddedNormal]}
1648 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1649 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Position : Cursor) @key{return} Element_Type@Chg{Version=[5],New=[
1650 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
1651 Nonblocking => Element_Type'Nonblocking,
1652 Global => (@key{in all}, @key{use} Element_Type)],Old=[]};]}
1653
1654 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1655 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Element} (Container : Map;
1656 Position : Cursor) @key{return} Element_Type
1657 @key{with} Pre => (Position /= No_Element
1658 @key{or else raise} Constraint_Error) @key{and then}
1659 (Has_Element (Container, Position)
1660 @key{or else raise} Program_Error),
1661 Nonblocking => Element_Type'Nonblocking,
1662 Global => (@key{null}, @key{use} Element_Type);]}
1663
1664 @ChgRef{Version=[2],Kind=[AddedNormal]}
1665 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1666 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} Map;
1667 Position : @key{in} Cursor;
1668 New_item : @key{in} Element_Type)@Chg{Version=[5],New=[
1669 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
1670 @key{or else raise} Program_Error) @key{and then}
1671 (Position /= No_Element
1672 @key{or else raise} Constraint_Error) @key{and then}
1673 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
1674
1675 @ChgRef{Version=[2],Kind=[AddedNormal]}
1676 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1677 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element}
1678 (Position : @key{in} Cursor;
1679 Process : @key{not null access procedure} (Key : @key{in} Key_Type;
1680 Element : @key{in} Element_Type))@Chg{Version=[5],New=[
1681 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
1682 Global => @key{in all}],Old=[]};]}
1683
1684 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1685 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Query_Element}
1686 (Container : @key{in} Map;
1687 Position : @key{in} Cursor;
1688 Process : @key{not null access procedure} (Key : @key{in} Key_Type;
1689 Element : @key{in} Element_Type))
1690 @key{with} Pre => (Position /= No_Element
1691 @key{or else raise} Constraint_Error) @key{and then}
1692 (Has_Element (Container, Position)
1693 @key{or else raise} Program_Error);]}
1694
1695 @ChgRef{Version=[2],Kind=[AddedNormal]}
1696 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1697 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element}
1698 (Container : @key{in out} Map;
1699 Position : @key{in} Cursor;
1700 Process : @key{not null access procedure}
1701 (Key : @key{in} Key_Type;
1702 Element : @key{in out} Element_Type))@Chg{Version=[5],New=[
1703 @key{with} Pre => (Position /= No_Element @key{or else raise} Constraint_Error) @key{and then}
1704 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
1705
1706 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1707 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1708 @ChgAdded{Version=[3],Text=[ @key[type] Constant_Reference_Type
1709 (Element : @key[not null access constant] Element_Type) @key[is private]
1710 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
1711 Nonblocking, Global => @key[in out synchronized],
1712 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
1713
1714 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1715 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1716 @ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Reference_Type} (Element : @key[not null access] Element_Type) @key[is private]
1717 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
1718 Nonblocking, Global => @key[in out synchronized],
1719 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
1720
1721 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1722 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1723 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Map;
1724 Position : @key[in] Cursor)
1725 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
1726 @key[with] Pre => (Position /= No_Element
1727 @key[or else raise] Constraint_Error) @key[and then]
1728 (Has_Element (Container, Position)
1729 @key[or else raise] Program_Error),
1730 Post => Tampering_With_Cursors_Prohibited (Container),
1731 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
1732
1733 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1734 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1735 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] Map;
1736 Position : @key[in] Cursor)
1737 @key[return] Reference_Type@Chg{Version=[5],New=[
1738 @key[with] Pre => (Position /= No_Element
1739 @key[or else raise] Constraint_Error) @key[and then]
1740 (Has_Element (Container, Position)
1741 @key[or else raise] Program_Error),
1742 Post => Tampering_With_Cursors_Prohibited (Container),
1743 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
1744
1745 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1746 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1747 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Map;
1748 Key : @key[in] Key_Type)
1749 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
1750 @key[with] Pre => Find (Container, Key) /= No_Element @key[or else raise] Constraint_Error,
1751 Post => Tampering_With_Cursors_Prohibited (Container),
1752 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
1753
1754 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
1755 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1756 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] Map;
1757 Key : @key[in] Key_Type)
1758 @key[return] Reference_Type@Chg{Version=[5],New=[
1759 @key[with] Pre => Find (Container, Key) /= No_Element @key[or else raise] Constraint_Error,
1760 Post => Tampering_With_Cursors_Prohibited (Container),
1761 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
1762
1763 @ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]}
1764 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1765 @ChgAdded{Version=[3],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} Map; Source : @key{in} Map)@Chg{Version=[5],New=[
1766 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Target)
1767 @key[or else raise] Program_Error,
1768 Post => Length (Source) = Length (Target) @key[and then]
1769 Capacity (Target) >= Length (Source)],Old=[]};]}
1770
1771 @ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]}
1772 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
1773 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Copy} (Source : Map; Capacity : Count_Type := 0)
1774 @key[return] Map@Chg{Version=[5],New=[
1775 @key[with] Pre => Capacity = 0 @key[or else] Capacity >= Length (Source)
1776 @key[or else raise] Capacity_Error,
1777 Post =>
1778 Length (Copy'Result) = Length (Source) @key[and then]
1779 @key[not] Tampering_With_Elements_Prohibited (Copy'Result) @key[and then]
1780 @key[not] Tampering_With_Cursors_Prohibited (Copy'Result) @key[and then]
1781 Copy'Result.Capacity = (if Capacity = 0 then
1782 Length (Source) else Capacity)],Old=[]};]}
1783
1784 @ChgRef{Version=[2],Kind=[AddedNormal]}
1785 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1786 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Move} (Target : @key{in out} Map;
1787 Source : @key{in out} Map)@Chg{Version=[5],New=[
1788 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
1789 @key{or else raise} Program_Error) @key{and then}
1790 (@key{not} Tampering_With_Cursors_Prohibited (Source)
1791 @key{or else raise} Program_Error),
1792 Post => (@key{if} Target = Source @key{then} True
1793 @key{else}
1794 Length (Target) = Length (Source'Old) @key{and then}
1795 Length (Source) = 0)],Old=[]};]}
1796
1797 @ChgRef{Version=[2],Kind=[AddedNormal]}
1798 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1799 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Map;
1800 Key : @key{in} Key_Type;
1801 New_Item : @key{in} Element_Type;
1802 Position : @key{out} Cursor;
1803 Inserted : @key{out} Boolean)@Chg{Version=[5],New=[
1804 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1805 @key{or else raise} Program_Error) @key{and then}
1806 (Length (Container) <= Count_Type'Last - 1
1807 @key{or else raise} Constraint_Error),
1808 Post => (@key{declare}
1809 Original_Length : @key{constant} Count_Type :=
1810 Length (Container)'Old;
1811 @key{begin}
1812 Has_Element (Container, Position) @key{and then}
1813 (@key{if} Inserted then
1814 Length (Container) = Original_Length + 1
1815 @key{else}
1816 Length (Container) = Original_Length)) @key{and then}
1817 Capacity (Container) >= Length (Container)],Old=[]};]}
1818
1819 @ChgRef{Version=[2],Kind=[AddedNormal]}
1820 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1821 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Map;
1822 Key : @key{in} Key_Type;
1823 Position : @key{out} Cursor;
1824 Inserted : @key{out} Boolean)@Chg{Version=[5],New=[
1825 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1826 @key{or else raise} Program_Error) @key{and then}
1827 (Length (Container) <= Count_Type'Last - 1
1828 @key{or else raise} Constraint_Error),
1829 Post => (@key{declare}
1830 Original_Length : @key{constant} Count_Type :=
1831 Length (Container)'Old;
1832 @key{begin}
1833 Has_Element (Container, Position) @key{and then}
1834 (@key{if} Inserted then
1835 Length (Container) = Original_Length + 1
1836 @key{else}
1837 Length (Container) = Original_Length)) @key{and then}
1838 Capacity (Container) >= Length (Container)],Old=[]};]}
1839
1840 @ChgRef{Version=[2],Kind=[AddedNormal]}
1841 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1842 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Map;
1843 Key : @key{in} Key_Type;
1844 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
1845 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1846 @key{or else raise} Program_Error) @key{and then}
1847 (Length (Container) <= Count_Type'Last - 1
1848 @key{or else raise} Constraint_Error),
1849 Post => Length (Container) = Length (Container)'Old + 1 @key{and then}
1850 Capacity (Container) >= Length (Container)],Old=[]};]}
1851
1852 @ChgRef{Version=[2],Kind=[AddedNormal]}
1853 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1854 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Include} (Container : @key{in out} Map;
1855 Key : @key{in} Key_Type;
1856 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
1857 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1858 @key{or else raise} Program_Error) @key{and then}
1859 (Length (Container) <= Count_Type'Last - 1
1860 @key{or else raise} Constraint_Error),
1861 Post => (@key{declare}
1862 Original_Length : @key{constant} Count_Type :=
1863 Length (Container)'Old;
1864 @key{begin}
1865 Length (Container)
1866 @key{in} Original_Length | Original_Length + 1) @key{and then}
1867 Capacity (Container) >= Length (Container)],Old=[]};]}
1868
1869 @ChgRef{Version=[2],Kind=[AddedNormal]}
1870 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1871 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace} (Container : @key{in out} Map;
1872 Key : @key{in} Key_Type;
1873 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
1874 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
1875 @key{or else raise} Program_Error,
1876 Post => Length (Container) = Length (Container)'Old],Old=[]};]}
1877
1878 @ChgRef{Version=[2],Kind=[AddedNormal]}
1879 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1880 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Exclude} (Container : @key{in out} Map;
1881 Key : @key{in} Key_Type)@Chg{Version=[5],New=[
1882 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
1883 @key{or else raise} Program_Error,
1884 Post => (@key{declare}
1885 Original_Length : @key{constant} Count_Type :=
1886 Length (Container)'Old;
1887 @key{begin}
1888 Length (Container)
1889 @key{in} Original_Length - 1 | Original_Length)],Old=[]};]}
1890
1891 @ChgRef{Version=[2],Kind=[AddedNormal]}
1892 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1893 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Map;
1894 Key : @key{in} Key_Type)@Chg{Version=[5],New=[
1895 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
1896 @key{or else raise} Program_Error,
1897 Post => Length (Container) = Length (Container)'Old - 1],Old=[]};]}
1898
1899 @ChgRef{Version=[2],Kind=[AddedNormal]}
1900 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1901 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Map;
1902 Position : @key{in out} Cursor)@Chg{Version=[5],New=[
1903 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
1904 @key{or else raise} Program_Error) @key{and then}
1905 (Position /= No_Element
1906 @key{or else raise} Constraint_Error) @key{and then}
1907 (Has_Element (Container, Position)
1908 @key{or else raise} Program_Error),
1909 Post => Length (Container) = Length (Container)'Old - 1 @key{and then}
1910 Position = No_Element],Old=[]};]}
1911
1912 @ChgRef{Version=[2],Kind=[AddedNormal]}
1913 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1914 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First} (Container : Map) @key{return} Cursor@Chg{Version=[5],New=[
1915 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
1916 Post => (@key{if not} Is_Empty (Container)
1917 @key{then} Has_Element (Container, First'Result)
1918 @key{else} First'Result = No_Element)],Old=[]};]}
1919
1920 @ChgRef{Version=[2],Kind=[AddedNormal]}
1921 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1922 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Next} (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
1923 @key{with} Nonblocking, Global => (@key{in all}, @key{use null}),
1924 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
1925 @key{else} True)],Old=[]};]}
1926
1927 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1928 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Next} (Container : Map;
1929 Position : Cursor) @key{return} Cursor
1930 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
1931 Pre => Position = No_Element @key{or else}
1932 Has_Element (Container, Position)
1933 @key{or else raise} Program_Error,
1934 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
1935 @key{elsif} Next'Result = No_Element @key{then}
1936 Position = Last (Container)
1937 @key{else} Has_Element (Container, Next'Result));]}
1938
1939 @ChgRef{Version=[2],Kind=[AddedNormal]}
1940 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1941 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Next} (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
1942 @key{with} Nonblocking, Global => (@key{in all}, @key{use null})],Old=[]};]}
1943
1944 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
1945 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Next} (Container : @key{in} Map;
1946 Position : @key{in out} Cursor)
1947 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
1948 Pre => Position = No_Element @key{or else}
1949 Has_Element (Container, Position)
1950 @key{or else raise} Program_Error,
1951 Post => (@key{if} Position /= No_Element
1952 @key{then} Has_Element (Container, Position));]}
1953
1954 @ChgRef{Version=[2],Kind=[AddedNormal]}
1955 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1956 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Map;
1957 Key : Key_Type)
1958 @key{return} Cursor@Chg{Version=[5],New=[
1959 @key{with} Post => (@key{if} Find'Result = No_Element @key{then} True
1960 @key{else} Has_Element (Container, Find'Result))],Old=[]};]}
1961
1962 @ChgRef{Version=[2],Kind=[AddedNormal]}
1963 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Container : Map;
1964 Key : Key_Type)
1965 @key{return} Element_Type;]}
1966
1967 @ChgRef{Version=[2],Kind=[AddedNormal]}
1968 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Map;
1969 Key : Key_Type) @key{return} Boolean;]}
1970
1971 @ChgRef{Version=[2],Kind=[AddedNormal]}
1972 @ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0212-1]}
1973 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]}]}
1974
1975 @ChgRef{Version=[2],Kind=[AddedNormal]}
1976 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1977 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Keys} (Left, Right : Cursor)
1978 @key{return} Boolean@Chg{Version=[5],New=[
1979 @key{with} Pre => (Left =/ No_Element @key{and then} Right /= No_Element)
1980 @key{or else raise} Constraint_Error,
1981 Global => @key{in all}],Old=[]};]}
1982
1983 @ChgRef{Version=[2],Kind=[AddedNormal]}
1984 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1985 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Keys} (Left : Cursor;
1986 Right : Key_Type)
1987 @key{return} Boolean@Chg{Version=[5],New=[
1988 @key{with} Pre => Left /= No_Element @key{or else raise} Constraint_Error,
1989 Global => @key{in all}],Old=[]};]}
1990
1991 @ChgRef{Version=[2],Kind=[AddedNormal]}
1992 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
1993 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Keys} (Left : Key_Type;
1994 Right : Cursor)
1995 @key{return} Boolean@Chg{Version=[5],New=[
1996 @key{with} Pre => Right /= No_Element @key{or else raise} Constraint_Error,
1997 Global => @key{in all}],Old=[]};]}
1998
1999 @ChgRef{Version=[2],Kind=[AddedNormal]}
2000 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2001 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Iterate}
2002 (Container : @key{in} Map;
2003 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
2004 @key{with} Allows_Exit],Old=[]};]}
2005
2006 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
2007 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1],ARef=[AI12-0266-1]}
2008 @ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] Map)
2009 @key[return] Map_Iterator_Interfaces.@Chg{Version=[5],New=[Parallel_Iterator],Old=[Forward_Iterator]}'Class@Chg{Version=[5],New=[
2010 @key[with] Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
2011
2012 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2013 @ChgAdded{Version=[5],Text=[ @key{package} @AdaPackDefn{Stable} @key{is}]}
2014
2015 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1],ARef=[AI12-0339-1]}
2016 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Map} (Base : @key{not null access} Hashed_Maps.Map) @key{is}
2017 @key{tagged limited private}
2018 @key{with} Constant_Indexing => Constant_Reference,
2019 Variable_Indexing => Reference,
2020 Default_Iterator => Iterate,
2021 Iterator_Element => Element_Type,
2022 Aggregate => (Empty => Empty,
2023 Add_Named => Insert),
2024 Stable_Properties => (Length),
2025 Global => @key[null],
2026 Default_Initial_Condition => Length (Map) = 0;
2027 @key{pragma} Preelaborable_Initialization(Map);]}
2028
2029 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2030 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private};
2031 @key{pragma} Preelaborable_Initialization(Cursor);]}
2032
2033 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2034 @ChgAdded{Version=[5],Text=[ @AdaObjDefn{Empty_Map} : @key{constant} Map;]}
2035
2036 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2037 @ChgAdded{Version=[5],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]}
2038
2039 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2040 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean
2041 @key{with} Nonblocking, Global => (@key{in all}, @key{use null});]}
2042
2043 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2044 @ChgAdded{Version=[5],Text=[ @key{package} @AdaPackDefn{Map_Iterator_Interfaces} @key[is new]
2045 Ada.Iterator_Interfaces (Cursor, Has_Element);]}
2046
2047 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2048 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} Hashed_Maps.Map;
2049 Source : @key{in} Map)
2050 @key{with} Post => Length (Source) = Length (Target);]}
2051
2052 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2053 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Copy} (Source : Hashed_Maps.Map) @key{return} Map
2054 @key{with} Post => Length (Copy'Result) = Length (Source);]}
2055
2056 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2057 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Constant_Reference_Type}
2058 (Element : @key{not null access constant} Element_Type) @key{is private}
2059 @key{with} Implicit_Dereference => Element,
2060 Nonblocking, Global => (@key{null}, @key{use null}),
2061 Default_Initial_Condition => (@key{raise} Program_Error);]}
2062
2063 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2064 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Reference_Type}
2065 (Element : @key{not null access} Element_Type) @key{is private}
2066 @key{with} Implicit_Dereference => Element,
2067 Nonblocking, Global => (@key{null}, @key{use null}),
2068 Default_Initial_Condition => (@key{raise} Program_Error);]}
2069
2070 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2071 @ChgAdded{Version=[5],Text=[ -- @examcom{Additional subprograms as described in the text}
2072 -- @examcom{are declared here.}]}
2073
2074 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2075 @ChgAdded{Version=[5],Text=[ @key{private}]}
2076
2077 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2078 @ChgAdded{Version=[5],Text=[ ... -- @Examcom{not specified by the language}]}
2079
2080 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
2081 @ChgAdded{Version=[5],Text=[ @key{end} Stable;]}
2082
2083 @ChgRef{Version=[2],Kind=[AddedNormal]}
2084 @ChgAdded{Version=[2],Text=[@key{private}]}
2085
2086 @ChgRef{Version=[2],Kind=[AddedNormal]}
2087 @ChgAdded{Version=[2],Text=[ ... -- @RI[not specified by the language]]}
2088
2089 @ChgRef{Version=[2],Kind=[AddedNormal]}
2090 @ChgAdded{Version=[2],Text=[@key{end} Ada.Containers.Hashed_Maps;]}
2091
2092 @end{Example}
2093
2094 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2095 @ChgAdded{Version=[2],Text=[An object of type Map contains an expandable hash
2096 table, which is used to provide direct access to nodes. The @i<capacity> of an
2097 object of type Map is the maximum number of nodes that can be inserted into the
2098 hash table prior to it being automatically
2099 expanded.@Defn2{Term=[capacity],Sec=[of a hashed map]}]}
2100
2101 @begin{ImplNote}
2102 @ChgRef{Version=[2],Kind=[AddedNormal]}
2103 @ChgAdded{Version=[2],Text=[The expected implementation for a Map uses a
2104 hash table which is grown when it is too small, with linked lists hanging off
2105 of each bucket. Note that in that implementation a cursor needs a back
2106 pointer to the Map object to implement iteration; that could either be in the
2107 nodes, or in the cursor object. To provide an average @i{O}(1) access time,
2108 capacity would typically equal the number of buckets in such an
2109 implementation, so that the average bucket linked list length would be no
2110 more than 1.0.]}
2111
2112 @ChgRef{Version=[2],Kind=[AddedNormal]}
2113 @ChgAdded{Version=[2],Text=[There is no defined relationship between elements
2114 in a hashed map. Typically, iteration will return elements in the order that
2115 they are hashed in.]}
2116 @end{ImplNote}
2117
2118 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2119 @ChgAdded{Version=[2],Text=[@Defn2{Term={equivalent key},Sec={of a hashed map}}
2120 Two keys @i<K1> and @i<K2> are defined to be @i<equivalent> if
2121 Equivalent_Keys (@i<K1>, @i<K2>) returns True.]}
2122
2123 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2124 @ChgAdded{Version=[2],Text=[The actual function for the generic formal function
2125 Hash is expected to return the same value each time it is called with a
2126 particular key value. For any two equivalent key values, the actual for Hash is
2127 expected to return the same value. If the actual for Hash behaves in some other
2128 manner, the behavior of this package is unspecified. Which subprograms of this
2129 package call Hash, and how many times they call it, is
2130 unspecified.@PDefn{unspecified}]}
2131
2132 @begin{ImplNote}
2133 @ChgRef{Version=[2],Kind=[AddedNormal]}
2134 @ChgAdded{Version=[2],Text=[The implementation is not required to protect
2135 against Hash raising an exception, or returning random numbers, or any other
2136 @lquotes@;bad@rquotes behavior. It's not practical to do so, and a broken
2137 Hash function makes the container unusable.]}
2138
2139 @ChgRef{Version=[2],Kind=[AddedNormal]}
2140 @ChgAdded{Version=[2],Text=[The implementation can call Hash whenever it is
2141 needed; we don't want to specify how often that happens. The result must
2142 remain the same (this is logically a pure function), or the behavior is
2143 unspecified.]}
2144 @end{ImplNote}
2145
2146 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2147 @ChgAdded{Version=[2],Text=[The actual function for the generic formal function
2148 Equivalent_Keys on Key_Type values is expected to return the same value each
2149 time it is called with a particular pair of key values. It should define an
2150 equivalence relationship, that is, be reflexive, symmetric, and transitive. If
2151 the actual for Equivalent_Keys behaves in some other manner, the behavior of
2152 this package is unspecified. Which subprograms of this package call
2153 Equivalent_Keys, and how many times they call it, is
2154 unspecified.@PDefn{unspecified}]}
2155
2156 @begin{ImplNote}
2157 @ChgRef{Version=[2],Kind=[AddedNormal]}
2158 @ChgAdded{Version=[2],Text=[As with Hash, the implementation is not required
2159 to protect against Equivalent_Keys raising an exception or returning random
2160 results. Similarly, the implementation can call this operation whenever it is
2161 needed. The result must remain the same (this is a logically pure function),
2162 or the behavior is unspecified.]}
2163 @end{ImplNote}
2164
2165 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2166 @ChgAdded{Version=[2],Text=[If the value of a key stored in a node of a map is
2167 changed other than by an operation in this package such that at least one of
2168 Hash or Equivalent_Keys give different results, the behavior of this package is
2169 unspecified.@PDefn{unspecified}]}
2170
2171 @begin{ImplNote}
2172 @ChgRef{Version=[2],Kind=[AddedNormal]}
2173 @ChgAdded{Version=[2],Text=[The implementation is not required to protect
2174 against changes to key values other than via the operations declared in the
2175 Hashed_Maps package.]}
2176
2177 @ChgRef{Version=[2],Kind=[AddedNormal]}
2178 @ChgAdded{Version=[2],Type=[Leading],Text=[To see how this could happen,
2179 imagine an instance of Hashed_Maps where the key type is an
2180 access-to-variable type and Hash returns a value derived from the components
2181 of the designated object. Then, any operation that has a key value could
2182 modify those components and change the hash value:]}
2183
2184 @begin{Example}
2185 @ChgRef{Version=[2],Kind=[AddedNormal]}
2186 @ChgAdded{Version=[2],Text=[Key (Map).Some_Component := New_Value;]}
2187 @end{Example}
2188 @ChgRef{Version=[2],Kind=[AddedNormal]}
2189 @ChgAdded{Version=[2],Text=[This is really a design error on the part of the
2190 user of the map; it shouldn't be possible to modify keys stored in a map. But
2191 we can't prevent this error anymore than we can prevent someone passing as
2192 Hash a random number generator.]}
2193 @end{ImplNote}
2194
2195 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2196 @ChgAdded{Version=[2],Text=[@Defn2{Term=[first node],Sec=[of a hashed map]}
2197 @Defn2{Term=[last node],Sec=[of a hashed map]}
2198 @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
2199 successor of a given node, are unspecified, other than the general semantics
2200 described in @RefSecNum{Maps}.@PDefn{unspecified}]}
2201
2202 @begin{ImplNote}
2203 @ChgRef{Version=[2],Kind=[AddedNormal]}
2204 @ChgAdded{Version=[2],Text=[Typically the first node will be the first node
2205 in the first bucket, the last node will be the last node in the last bucket,
2206 and the successor will be obtained by following the collision list, and going
2207 to the next bucket at the end of each bucket.]}
2208 @end{ImplNote}
2209
2210 @begin{DescribeCode}
2211
2212 @begin{Example}
2213 @ChgRef{Version=[5],Kind=[Added]}
2214 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Empty (Capacity : Count_Type := @RI{implementation-defined})
2215 @key[return] Map
2216 @key[with] Post =>
2217 Capacity (Empty'Result) >= Capacity @key[and then]
2218 @key[not] Tampering_With_Elements_Prohibited (Empty'Result) @key[and then]
2219 @key[not] Tampering_With_Cursors_Prohibited (Empty'Result) @key[and then]
2220 Length (Empty'Result) = 0;]}
2221 @end{Example}
2222
2223 @ChgRef{Version=[2],Kind=[Added],ARef=[AI12-0339-1]}
2224 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns an empty map.]}
2225
2226 @begin{Example}
2227 @ChgRef{Version=[2],Kind=[AddedNormal]}
2228 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2229 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Capacity (Container : Map) @key{return} Count_Type@Chg{Version=[5],New=[
2230 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
2231 @end{Example}
2232
2233 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2234 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the capacity of Container.]}
2235
2236 @begin{Example}
2237 @ChgRef{Version=[2],Kind=[AddedNormal]}
2238 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2239 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reserve_Capacity (Container : @key{in out} Map;
2240 Capacity : @key{in} Count_Type)@Chg{Version=[5],New=[
2241 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
2242 @key[or else raise] Program_Error,
2243 Post => Container.Capacity >= Capacity],Old=[]};]}
2244 @end{Example}
2245
2246 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2247 @ChgAdded{Version=[2],Text=[Reserve_Capacity allocates a new hash table such
2248 that the length of the resulting map can become at least the value Capacity
2249 without requiring an additional call to Reserve_Capacity, and is large enough
2250 to hold the current length of Container. Reserve_Capacity then rehashes the
2251 nodes in Container onto the new hash table. It replaces the old hash table with
2252 the new hash table, and then deallocates the old hash table. Any exception
2253 raised during allocation is propagated and Container is not modified.]}
2254
2255 @ChgRef{Version=[2],Kind=[AddedNormal]}
2256 @ChgRef{Version=[5],Kind=[Deleted],ARef=[AI12-0112-1]}
2257 @ChgAdded{Version=[2],Type=[Trailing],
2258 Text=[@Chg{Version=[5],New=[],Old=[Reserve_Capacity tampers with the
2259 cursors of Container.]}]}
2260
2261 @begin{ImplNote}
2262 @ChgRef{Version=[2],Kind=[AddedNormal]}
2263 @ChgAdded{Version=[2],Text=[This routine is used to preallocate the internal
2264 hash table to the specified capacity such that future Inserts do not require
2265 expansion of the hash table. Therefore, the implementation should allocate
2266 the needed memory to make that true at this point, even though the visible
2267 semantics could be preserved by waiting until enough elements are inserted.]}
2268
2269 @ChgRef{Version=[2],Kind=[AddedNormal]}
2270 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]}
2271 @ChgAdded{Version=[2],Text=[While Reserve_Capacity can be used to reduce the
2272 capacity of a map, we do not specify whether an implementation actually
2273 supports reduction of the capacity. Since the actual capacity can be anything
2274 greater than or equal to @Chg{Version=[3],New=[Capacity],Old=[Count]},
2275 an implementation never has to reduce the capacity.]}
2276
2277 @ChgRef{Version=[2],Kind=[AddedNormal]}
2278 @ChgAdded{Version=[2],Text=[Reserve_Capacity tampers with the cursors, as
2279 rehashing probably will change the order that elements are stored in the
2280 map.]}
2281 @end{ImplNote}
2282
2283 @begin{Example}
2284 @ChgRef{Version=[2],Kind=[AddedNormal]}
2285 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2286 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Clear (Container : @key{in out} Map)@Chg{Version=[5],New=[
2287 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
2288 @key[or else raise] Program_Error,
2289 Post => Capacity (Container) = Capacity (Container)'Old @key{and then}
2290 Length (Container) = 0],Old=[]};]}
2291 @end{Example}
2292
2293 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2294 @ChgAdded{Version=[2],Type=[Trailing],Text=[In addition to the semantics
2295 described in @RefSecNum{Maps}, Clear does not affect the capacity of
2296 Container.]}
2297
2298 @begin{Example}
2299 @ChgRef{Version=[3],Kind=[Added]}
2300 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2301 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[procedure] Assign (Target : @key[in out] Map; Source : @key[in] Map)@Chg{Version=[5],New=[
2302 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Target)
2303 @key[or else raise] Program_Error,
2304 Post => Length (Source) = Length (Target) @key[and then]
2305 Capacity (Target) >= Length (Source)],Old=[]};]}
2306 @end{Example}
2307
2308 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0248-1]}
2309 @ChgAdded{Version=[3],Type=[Trailing],Text=[In addition to the semantics
2310 described in @RefSecNum{Maps}, if the length of Source is greater than the
2311 capacity of Target,
2312 Reserve_Capacity (Target, Length (Source)) is called before assigning
2313 any elements.]}
2314
2315 @begin{Example}
2316 @ChgRef{Version=[3],Kind=[Added]}
2317 @ChgRef{Version=[5],Kind=[RevisedAdded]}
2318 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Copy (Source : Map; Capacity : Count_Type := 0)
2319 @key[return] Map@Chg{Version=[5],New=[
2320 @key[with] Pre => Capacity = 0 @key[or else] Capacity >= Length (Source)
2321 @key[or else raise] Capacity_Error,
2322 Post =>
2323 Length (Copy'Result) = Length (Source) @key[and then]
2324 @key[not] Tampering_With_Elements_Prohibited (Copy'Result) @key[and then]
2325 @key[not] Tampering_With_Cursors_Prohibited (Copy'Result) @key[and then]
2326 Copy'Result.Capacity = (if Capacity = 0 then
2327 Length (Source) else Capacity)],Old=[]};]}
2328 @end{Example}
2329
2330 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
2331 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2332 @ChgAdded{Version=[3],Type=[Trailing],Text=[Returns a map whose keys and
2333 elements are initialized from the keys and elements of
2334 Source.@Chg{Version=[5],New=[],Old=[ If Capacity is 0,
2335 then the map capacity is the length of Source; if Capacity is equal to or
2336 greater than the length of Source, the map capacity is at least the specified
2337 value. Otherwise, the operation propagates Capacity_Error.]}]}
2338
2339 @begin{ImplNote}
2340 @ChgRef{Version=[2],Kind=[AddedNormal]}
2341 @ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[In:]}
2342
2343 @begin{Example}
2344 @ChgRef{Version=[2],Kind=[AddedNormal]}
2345 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Move (Target : @key{in out} Map;
2346 Source : @key{in out} Map);]}
2347 @end{Example}
2348
2349 @ChgRef{Version=[2],Kind=[AddedNormal]}
2350 @ChgAdded{Version=[2],Text=[The intended implementation is that the internal
2351 hash table of Target is first deallocated; then the internal hash table is
2352 removed from Source and moved to Target.]}
2353 @end{ImplNote}
2354
2355 @begin{Example}
2356 @ChgRef{Version=[2],Kind=[AddedNormal]}
2357 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2358 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Map;
2359 Key : @key{in} Key_Type;
2360 New_Item : @key{in} Element_Type;
2361 Position : @key{out} Cursor;
2362 Inserted : @key{out} Boolean)@Chg{Version=[5],New=[
2363 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
2364 @key{or else raise} Program_Error) @key{and then}
2365 (Length (Container) <= Count_Type'Last - 1
2366 @key{or else raise} Constraint_Error),
2367 Post => (@key{declare}
2368 Original_Length : @key{constant} Count_Type :=
2369 Length (Container)'Old;
2370 @key{begin}
2371 Has_Element (Container, Position) @key{and then}
2372 (@key{if} Inserted then
2373 Length (Container) = Original_Length + 1
2374 @key{else}
2375 Length (Container) = Original_Length)) @key{and then}
2376 Capacity (Container) >= Length (Container)],Old=[]};]}
2377 @end{Example}
2378
2379 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2380 @ChgAdded{Version=[2],Type=[Trailing],Text=[In addition to the semantics
2381 described in @RefSecNum{Maps}, if Length (Container) equals Capacity
2382 (Container), then Insert first calls Reserve_Capacity to increase the capacity
2383 of Container to some larger value.]}
2384
2385 @begin{ImplNote}
2386 @ChgRef{Version=[2],Kind=[AddedNormal]}
2387 @ChgAdded{Version=[2],Text=[Insert should only compare keys that hash to the
2388 same bucket in the hash table.]}
2389
2390 @ChgRef{Version=[2],Kind=[AddedNormal]}
2391 @ChgAdded{Version=[2],Text=[We specify when Reserve_Capacity is called to bound
2392 the overhead of capacity expansion operations (which are potentially
2393 expensive). Moreover, expansion can be predicted by comparing Capacity(Map) to
2394 Length(Map). Since we don't specify by how much the hash table is expanded,
2395 this only can be used to predict the next expansion, not later ones.]}
2396
2397 @end{ImplNote}
2398 @begin{ImplNote}
2399 @ChgRef{Version=[2],Kind=[AddedNormal]}
2400 @ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[In:]}
2401
2402 @begin{Example}
2403 @ChgRef{Version=[2],Kind=[AddedNormal]}
2404 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Exclude (Container : @key{in out} Map;
2405 Key : @key{in} Key_Type);]}
2406 @end{Example}
2407
2408 @ChgRef{Version=[2],Kind=[AddedNormal]}
2409 @ChgAdded{Version=[2],Text=[Exclude should only compare keys that hash to the same bucket in the hash
2410 table.]}
2411
2412 @end{ImplNote}
2413 @begin{ImplNote}
2414 @ChgRef{Version=[2],Kind=[AddedNormal]}
2415 @ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[In:]}
2416
2417 @begin{Example}
2418 @ChgRef{Version=[2],Kind=[AddedNormal]}
2419 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Map;
2420 Key : @key{in} Key_Type);]}
2421 @end{Example}
2422
2423 @ChgRef{Version=[2],Kind=[AddedNormal]}
2424 @ChgAdded{Version=[2],Text=[Delete should only compare keys that hash to the
2425 same bucket in the hash table. The node containing the element may be
2426 deallocated now, or it may be saved and reused later.]}
2427
2428 @end{ImplNote}
2429 @begin{ImplNote}
2430 @ChgRef{Version=[2],Kind=[AddedNormal]}
2431 @ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[In:]}
2432
2433 @begin{Example}
2434 @ChgRef{Version=[2],Kind=[AddedNormal]}
2435 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First (Container : Map) @key{return} Cursor;]}
2436 @end{Example}
2437
2438 @ChgRef{Version=[2],Kind=[AddedNormal]}
2439 @ChgAdded{Version=[2],Text=[In a typical implementation, this will be the first node in the lowest numbered
2440 hash bucket that contains a node.]}
2441
2442 @end{ImplNote}
2443 @begin{ImplNote}
2444 @ChgRef{Version=[2],Kind=[AddedNormal]}
2445 @ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[In:]}
2446
2447 @begin{Example}
2448 @ChgRef{Version=[2],Kind=[AddedNormal]}
2449 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Next (Position : Cursor) @key{return} Cursor;]}
2450 @end{Example}
2451
2452 @ChgRef{Version=[2],Kind=[AddedNormal]}
2453 @ChgAdded{Version=[2],Text=[In a typical implementation, this will return the next node in a bucket; if
2454 Position is the last node in a bucket, this will return the first node in the
2455 next nonempty bucket.]}
2456
2457 @ChgRef{Version=[2],Kind=[AddedNormal]}
2458 @ChgAdded{Version=[2],Text=[A typical implementation will need to a keep a pointer at the map container
2459 in the cursor in order to implement this function.]}
2460 @end{ImplNote}
2461 @begin{ImplNote}
2462 @ChgRef{Version=[2],Kind=[AddedNormal]}
2463 @ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[In:]}
2464
2465 @begin{Example}
2466 @ChgRef{Version=[2],Kind=[AddedNormal]}
2467 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Find (Container : Map;
2468 Key : Key_Type) @key{return} Cursor;]}
2469 @end{Example}
2470
2471 @ChgRef{Version=[2],Kind=[AddedNormal]}
2472 @ChgAdded{Version=[2],Text=[Find should only compare keys that hash to the same bucket in the hash table.]}
2473
2474 @end{ImplNote}
2475
2476 @begin{Example}
2477 @ChgRef{Version=[2],Kind=[AddedNormal]}
2478 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2479 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Keys (Left, Right : Cursor)
2480 @key{return} Boolean@Chg{Version=[5],New=[
2481 @key{with} Pre => (Left /= No_Element @key{and then} Right /= No_Element)
2482 @key{or else raise} Constraint_Error,
2483 Global => @key{in all}],Old=[]};]}
2484 @end{Example}
2485
2486 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2487 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Equivalent_Keys (Key
2488 (Left), Key (Right)).]}
2489
2490 @begin{Example}
2491 @ChgRef{Version=[2],Kind=[AddedNormal]}
2492 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2493 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Keys (Left : Cursor;
2494 Right : Key_Type) @key{return} Boolean@Chg{Version=[5],New=[
2495 @key{with} Pre => Left /= No_Element @key{or else raise} Constraint_Error,
2496 Global => @key{in all}],Old=[]};]}
2497 @end{Example}
2498
2499 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2500 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Equivalent_Keys (Key
2501 (Left), Right).]}
2502
2503 @begin{Example}
2504 @ChgRef{Version=[2],Kind=[AddedNormal]}
2505 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2506 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Keys (Left : Key_Type;
2507 Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
2508 @key{with} Pre => Right /= No_Element @key{or else raise} Constraint_Error,
2509 Global => @key{in all}],Old=[]};]}
2510 @end{Example}
2511
2512 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2513 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Equivalent_Keys
2514 (Left, Key (Right)).]}
2515
2516 @begin{Example}
2517 @ChgRef{Version=[3],Kind=[Added]}
2518 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1],ARef=[AI12-0266-1]}
2519 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Map)
2520 @key[return] Map_Iterator_Interfaces.@Chg{Version=[5],New=[Parallel_Iterator],Old=[Forward_Iterator]}'Class@Chg{Version=[5],New=[
2521 @key[with] Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
2522 @end{Example}
2523
2524 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]}
2525 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0266-1]}
2526 @ChgAdded{Version=[3],Type=[Trailing],Text=[Iterate returns
2527 an iterator object (see @RefSecNum{User-Defined Iterator Types}) that
2528 will generate a value for a loop parameter (see
2529 @RefSecNum{Generalized Loop Iteration}) designating
2530 each node in Container, starting with the first node and moving the cursor
2531 according to the successor relation@Chg{Version=[5],New=[ when used as a forward
2532 iterator, and processing all nodes concurrently when used as a parallel
2533 iterator],Old=[]}. Tampering with the cursors of Container is prohibited while
2534 the iterator object exists (in particular, in the @nt{sequence_of_statements} of
2535 the @nt{loop_statement} whose @nt{iterator_specification} denotes this object).
2536 The iterator object needs finalization.]}
2537
2538 @end{DescribeCode}
2539 @end{StaticSem}
2540
2541 @begin{ImplAdvice}
2542
2543 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2544 @ChgAdded{Version=[2],Text=[If @i<N> is the length of a map, the average time
2545 complexity of the subprograms Element, Insert, Include, Replace, Delete,
2546 Exclude and Find that take a key parameter should be @i{O}(log @i<N>). The average
2547 time complexity of the subprograms that take a cursor parameter should be @i{O}(1).
2548 The average time complexity of Reserve_Capacity should be @i{O}(@i<N>).]}
2549 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
2550 Text=[The average time complexity of Element, Insert, Include, Replace,
2551 Delete, Exclude and Find operations that
2552 take a key parameter for Containers.Hashed_Maps should be
2553 @i{O}(log @i<N>). The average
2554 time complexity of the subprograms of Containers.Hashed_Maps that take
2555 a cursor parameter should be @i{O}(1). The average time complexity of
2556 Containers.Hashed_Maps.Reserve_Capacity should be @i{O}(@i<N>).]}]}
2557
2558 @begin{Reason}
2559 @ChgRef{Version=[2],Kind=[AddedNormal]}
2560 @ChgAdded{Version=[2],Text=[We do not mean to overly constrain implementation
2561 strategies here. However, it is important for portability that the
2562 performance of large containers has roughly the same factors on different
2563 implementations. If a program is moved to an implementation for which Find is
2564 @i{O}(@i<N>), that program could be unusable when the maps are large. We allow
2565 @i{O}(log @i<N>) access because the proportionality constant and caching effects
2566 are likely to be larger than the log factor, and we don't want to discourage
2567 innovative implementations.]}
2568 @end{Reason}
2569 @end{ImplAdvice}
2570
2571 @begin{Extend95}
2572 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2573 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
2574 The generic package Containers.Hashed_Maps is new.]}
2575 @end{Extend95}
2576
2577 @begin{Incompatible2005}
2578 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
2579 @ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Subprograms Assign and Copy
2580 are added to Containers.Hashed_Maps. If an instance of Containers.Hashed_Maps
2581 is referenced in a @nt{use_clause}, and an entity @i<E> with the same
2582 @nt{defining_identifier} as a new entity in Containers.Hashed_Maps is
2583 defined in a package that is also referenced in a @nt{use_clause}, the
2584 entity @i<E> may no longer be use-visible, resulting in errors. This should
2585 be rare and is easily fixed if it does occur.]}
2586 @end{Incompatible2005}
2587
2588 @begin{Extend2005}
2589 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]}
2590 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
2591 Added iterator and indexing support to make hashed map containers more
2592 convenient to use.]}
2593 @end{Extend2005}
2594
2595 @begin{Diffword2005}
2596 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0084-1]}
2597 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a pragma
2598 Remote_Types so that containers can be used in distributed programs.]}
2599 @end{Diffword2005}
2600
2601 @begin{Incompatible2012}
2602 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1],ARef=[AI12-0112-1],ARef=[AI12-0339-1]}
2603 @ChgAdded{Version=[5],Text=[@Defn{incompatibilities with Ada 2012}A number of
2604 new subprograms, types, and even a nested package were added to
2605 Containers.Hashed_Maps to better support contracts and stable views. If an
2606 instance of Containers.Hashed_Maps
2607 is referenced in a @nt{use_clause}, and an entity @i<E> with the same
2608 @nt{defining_identifier} as a new entity in Containers.Hashed_Maps is
2609 defined in a package that is also referenced in a @nt{use_clause}, the
2610 entity @i<E> may no longer be use-visible, resulting in errors. This should
2611 be rare and is easily fixed if it does occur.]}
2612 @end{Incompatible2012}
2613
2614 @begin{Extend2012}
2615 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0212-1]}
2616 @ChgAdded{Version=[5],Text=[@Defn{extensions to Ada 2012}Maps now support
2617 named container aggregates, so @nt{aggregate} syntax can be used to
2618 create Maps.]}
2619
2620 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0266-1]}
2621 @ChgAdded{Version=[5],Text=[The iterator for the
2622 container now can return a parallel iterator which can be used to
2623 process the container in parallel.]}
2624 @end{Extend2012}
2625
2626 @begin{DiffWord2012}
2627 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
2628 @ChgAdded{Version=[5],Text=[Added contracts to this container. This includes
2629 describing some of the semantics with pre- and postconditions, rather than
2630 English text. Note that the preconditions can be Suppressed (see
2631 @RefSecNum{Suppressing Checks}).]}
2632 @end{DiffWord2012}
2633
2634
2635 @LabeledAddedSubclause{Version=[2],Name=[The Generic Package Containers.Ordered_Maps]}
2636
2637 @begin{StaticSem}
2638
2639 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
2640 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library
2641 package Containers.Ordered_Maps has the following declaration:]}
2642 @begin{Example}
2643 @ChgRef{Version=[2],Kind=[AddedNormal]}
2644 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0084-1],ARef=[AI05-0212-1]}
2645 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2646 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[@key[with] Ada.Iterator_Interfaces;
2647 ],Old=[]}@key{generic}
2648 @key{type} Key_Type @key{is private};
2649 @key{type} Element_Type @key{is private};
2650 @key{with function} "<" (Left, Right : Key_Type) @key{return} Boolean @key{is} <>;
2651 @key{with function} "=" (Left, Right : Element_Type) @key{return} Boolean @key{is} <>;
2652 @key{package} Ada.Containers.Ordered_Maps@Chg{Version=[5],New=[],Old=[ @key{is}]}@ChildUnit{Parent=[Ada.Containers],Child=[Ordered_Maps]}@Chg{Version=[5],New=[
2653 @key[with] Preelaborate, Remote_Types,
2654 Nonblocking, Global => @key[null] @key[is]],Old=[
2655 @key{pragma} Preelaborate(Ordered_Maps);@Chg{Version=[3],New=[
2656 @key{pragma} Remote_Types(Ordered_Maps);],Old=[]}]}]}
2657
2658 @begin{Discussion}
2659 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
2660 @ChgAdded{Version=[5],Text=[For discussion on the reasons and meaning of
2661 the specifications of the Global and Nonblocking aspects in this generic
2662 package, see the notes on the equivalent operations in the specification
2663 of the Containers.Vectors package (see
2664 @RefSecNum{The Generic Package Containers.Vectors}).]}
2665 @end{Discussion}
2666
2667 @ChgRef{Version=[2],Kind=[AddedNormal]}
2668 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2669 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Keys} (Left, Right : Key_Type) @key{return} Boolean@Chg{Version=[5],New=[
2670 @key{is} (@key{not} ((Left < Right) @key{or} (Right < Left)));],Old=[]}]}
2671
2672 @ChgRef{Version=[2],Kind=[AddedNormal]}
2673 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]}
2674 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0111-1],ARef=[AI12-0112-1],ARef=[AI12-0212-1],ARef=[AI12-0339-1]}
2675 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Map} @key{is tagged private}@Chg{Version=[3],New=[
2676 @key[with] Constant_Indexing => Constant_Reference,
2677 Variable_Indexing => Reference,
2678 Default_Iterator => Iterate,
2679 Iterator_Element => Element_Type],Old=[]}@Chg{Version=[5],New=[,
2680 Iterator_View => Stable.Map,
2681 Aggregate => (Empty => Empty,
2682 Add_Named => Insert),
2683 Stable_Properties => (Length,
2684 Tampering_With_Cursors_Prohibited,
2685 Tampering_With_Elements_Prohibited),
2686 Default_Initial_Condition =>
2687 Length (Map) = 0 @key{and then}
2688 (@key{not} Tampering_With_Cursors_Prohibited (Map)) @key{and then}
2689 (@key{not} Tampering_With_Elements_Prohibited (Map))],Old=[]};
2690 @key{pragma} Preelaborable_Initialization(Map);]}
2691
2692 @ChgRef{Version=[2],Kind=[AddedNormal]}
2693 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private};
2694 @key{pragma} Preelaborable_Initialization(Cursor);]}
2695
2696 @ChgRef{Version=[2],Kind=[AddedNormal]}
2697 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{Empty_Map} : @key{constant} Map;]}
2698
2699 @ChgRef{Version=[2],Kind=[AddedNormal]}
2700 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]}
2701
2702 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
2703 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2704 @ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
2705 @key[with] Nonblocking, Global => (@key[in all], @key[use null])],Old=[]};]}
2706
2707 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
2708 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Has_Element} (Container : Map; Position : Cursor)
2709 @key{return} Boolean
2710 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
2711
2712 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
2713 @ChgRef{Version=[5],Kind=[RevisedAdded]}@ChgNote{Just a paragraph number change}
2714 @ChgAdded{Version=[3],Text=[ @key[package] @AdaPackDefn{Map_Iterator_Interfaces} @key[is new]
2715 Ada.Iterator_Interfaces (Cursor, Has_Element);]}
2716
2717 @ChgRef{Version=[2],Kind=[AddedNormal]}
2718 @ChgAdded{Version=[2],Text=[ @key{function} "=" (Left, Right : Map) @key{return} Boolean;]}
2719
2720 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
2721 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Tampering_With_Cursors_Prohibited}
2722 (Container : Map) @key{return} Boolean
2723 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
2724
2725 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
2726 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Tampering_With_Elements_Prohibited}
2727 (Container : Map) @key{return} Boolean
2728 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
2729
2730 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0339-1]}
2731 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Empty} @key{return} Map
2732 @key[is] (Empty_Map)
2733 @key[with] Post =>
2734 @key[not] Tampering_With_Elements_Prohibited (Empty'Result) @key[and then]
2735 @key[not] Tampering_With_Cursors_Prohibited (Empty'Result) @key[and then]
2736 Length (Empty'Result) = 0;]}
2737
2738 @ChgRef{Version=[2],Kind=[AddedNormal]}
2739 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2740 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Length} (Container : Map) @key{return} Count_Type@Chg{Version=[5],New=[
2741 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
2742
2743 @ChgRef{Version=[2],Kind=[AddedNormal]}
2744 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2745 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Empty} (Container : Map) @key{return} Boolean@Chg{Version=[5],New=[
2746 @key[with] Nonblocking, Global => (@key[null], @key[use null]),
2747 Post => Is_Empty'Result = (Length (Container) = 0)],Old=[]};]}
2748
2749 @ChgRef{Version=[2],Kind=[AddedNormal]}
2750 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2751 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Clear} (Container : @key{in out} Map)@Chg{Version=[5],New=[
2752 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
2753 @key[or else raise] Program_Error,
2754 Post => Length (Container) = 0],Old=[]};]}
2755
2756 @ChgRef{Version=[2],Kind=[AddedNormal]}
2757 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2758 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Key} (Position : Cursor) @key{return} Key_Type@Chg{Version=[5],New=[
2759 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
2760 Nonblocking => Key_Type'Nonblocking,
2761 Global => (@key{in all}, @key{use} Key_Type)],Old=[]};]}
2762
2763 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
2764 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Key} (Container : Map;
2765 Position : Cursor) @key{return} Key_Type
2766 @key{with} Pre => (Position /= No_Element
2767 @key{or else raise} Constraint_Error) @key{and then}
2768 (Has_Element (Container, Position)
2769 @key{or else raise} Program_Error),
2770 Nonblocking => Key_Type'Nonblocking,
2771 Global => (@key{null}, @key{use} Key_Type);]}
2772
2773 @ChgRef{Version=[2],Kind=[AddedNormal]}
2774 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2775 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Position : Cursor) @key{return} Element_Type@Chg{Version=[5],New=[
2776 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
2777 Nonblocking => Element_Type'Nonblocking,
2778 Global => (@key{in all}, @key{use} Element_Type)],Old=[]};]}
2779
2780 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
2781 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Element} (Container : Map;
2782 Position : Cursor) @key{return} Element_Type
2783 @key{with} Pre => (Position /= No_Element
2784 @key{or else raise} Constraint_Error) @key{and then}
2785 (Has_Element (Container, Position)
2786 @key{or else raise} Program_Error),
2787 Nonblocking => Element_Type'Nonblocking,
2788 Global => (@key{null}, @key{use} Element_Type);]}
2789
2790 @ChgRef{Version=[2],Kind=[AddedNormal]}
2791 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2792 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} Map;
2793 Position : @key{in} Cursor;
2794 New_item : @key{in} Element_Type)@Chg{Version=[5],New=[
2795 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
2796 @key{or else raise} Program_Error) @key{and then}
2797 (Position /= No_Element
2798 @key{or else raise} Constraint_Error) @key{and then}
2799 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
2800
2801 @ChgRef{Version=[2],Kind=[AddedNormal]}
2802 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2803 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element}
2804 (Position : @key{in} Cursor;
2805 Process : @key{not null access procedure} (Key : @key{in} Key_Type;
2806 Element : @key{in} Element_Type))@Chg{Version=[5],New=[
2807 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
2808 Global => @key{in all}],Old=[]};]}
2809
2810 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
2811 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Query_Element}
2812 (Container : @key{in} Map;
2813 Position : @key{in} Cursor;
2814 Process : @key{not null access procedure} (Key : @key{in} Key_Type;
2815 Element : @key{in} Element_Type))
2816 @key{with} Pre => (Position /= No_Element
2817 @key{or else raise} Constraint_Error) @key{and then}
2818 (Has_Element (Container, Position)
2819 @key{or else raise} Program_Error);]}
2820
2821 @ChgRef{Version=[2],Kind=[AddedNormal]}
2822 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2823 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element}
2824 (Container : @key{in out} Map;
2825 Position : @key{in} Cursor;
2826 Process : @key{not null access procedure}
2827 (Key : @key{in} Key_Type;
2828 Element : @key{in out} Element_Type))@Chg{Version=[5],New=[
2829 @key{with} Pre => (Position /= No_Element @key{or else raise} Constraint_Error) @key{and then}
2830 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
2831
2832 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
2833 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2834 @ChgAdded{Version=[3],Text=[ @key[type] Constant_Reference_Type
2835 (Element : @key[not null access constant] Element_Type) @key[is private]
2836 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
2837 Nonblocking, Global => @key[in out synchronized],
2838 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
2839
2840 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
2841 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2842 @ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Reference_Type} (Element : @key[not null access] Element_Type) @key[is private]
2843 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
2844 Nonblocking, Global => @key[in out synchronized],
2845 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
2846
2847 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
2848 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2849 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Map;
2850 Position : @key[in] Cursor)
2851 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
2852 @key[with] Pre => (Position /= No_Element
2853 @key[or else raise] Constraint_Error) @key[and then]
2854 (Has_Element (Container, Position)
2855 @key[or else raise] Program_Error),
2856 Post => Tampering_With_Cursors_Prohibited (Container),
2857 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
2858
2859 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
2860 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2861 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] Map;
2862 Position : @key[in] Cursor)
2863 @key[return] Reference_Type@Chg{Version=[5],New=[
2864 @key[with] Pre => (Position /= No_Element
2865 @key[or else raise] Constraint_Error) @key[and then]
2866 (Has_Element (Container, Position)
2867 @key[or else raise] Program_Error),
2868 Post => Tampering_With_Cursors_Prohibited (Container),
2869 Nonblocking, Global =>(@key[null], @key[use null])],Old=[]};]}
2870
2871 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
2872 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2873 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Map;
2874 Key : @key[in] Key_Type)
2875 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
2876 @key[with] Pre => Find (Container, Key) /= No_Element @key[or else raise] Constraint_Error,
2877 Post => Tampering_With_Cursors_Prohibited (Container),
2878 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
2879
2880 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
2881 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2882 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference} (Container : @key[aliased in out] Map;
2883 Key : @key[in] Key_Type)
2884 @key[return] Reference_Type@Chg{Version=[5],New=[
2885 @key[with] Pre => Find (Container, Key) /= No_Element @key[or else raise] Constraint_Error,
2886 Post => Tampering_With_Cursors_Prohibited (Container),
2887 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
2888
2889 @ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]}
2890 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2891 @ChgAdded{Version=[3],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} Map; Source : @key{in} Map)@Chg{Version=[5],New=[
2892 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Target)
2893 @key[or else raise] Program_Error,
2894 Post => Length (Source) = Length (Target)],Old=[]};]}
2895
2896 @ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]}
2897 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
2898 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Copy} (Source : Map)
2899 @key[return] Map@Chg{Version=[5],New=[
2900 @key[with] Post =>
2901 Length (Copy'Result) = Length (Source) @key[and then]
2902 @key[not] Tampering_With_Elements_Prohibited (Copy'Result) @key[and then]
2903 @key[not] Tampering_With_Cursors_Prohibited (Copy'Result)],Old=[]};]}
2904
2905 @ChgRef{Version=[2],Kind=[AddedNormal]}
2906 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2907 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Move} (Target : @key{in out} Map;
2908 Source : @key{in out} Map)@Chg{Version=[5],New=[
2909 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
2910 @key{or else raise} Program_Error) @key{and then}
2911 (@key{not} Tampering_With_Cursors_Prohibited (Source)
2912 @key{or else raise} Program_Error),
2913 Post => (@key{if} Target = Source @key{then} True
2914 @key{else}
2915 Length (Target) = Length (Source'Old) @key{and then}
2916 Length (Source) = 0)],Old=[]};]}
2917
2918 @ChgRef{Version=[2],Kind=[AddedNormal]}
2919 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2920 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Map;
2921 Key : @key{in} Key_Type;
2922 New_Item : @key{in} Element_Type;
2923 Position : @key{out} Cursor;
2924 Inserted : @key{out} Boolean)@Chg{Version=[5],New=[
2925 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
2926 @key{or else raise} Program_Error) @key{and then}
2927 (Length (Container) <= Count_Type'Last - 1
2928 @key{or else raise} Constraint_Error),
2929 Post => (@key{declare}
2930 Original_Length : @key{constant} Count_Type :=
2931 Length (Container)'Old;
2932 @key{begin}
2933 Has_Element (Container, Position) @key{and then}
2934 (@key{if} Inserted then
2935 Length (Container) = Original_Length + 1
2936 @key{else}
2937 Length (Container) = Original_Length))],Old=[]};]}
2938
2939 @ChgRef{Version=[2],Kind=[AddedNormal]}
2940 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2941 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Map;
2942 Key : @key{in} Key_Type;
2943 Position : @key{out} Cursor;
2944 Inserted : @key{out} Boolean)@Chg{Version=[5],New=[
2945 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
2946 @key{or else raise} Program_Error) @key{and then}
2947 (Length (Container) <= Count_Type'Last - 1
2948 @key{or else raise} Constraint_Error),
2949 Post => (@key{declare}
2950 Original_Length : @key{constant} Count_Type :=
2951 Length (Container)'Old;
2952 @key{begin}
2953 Has_Element (Container, Position) @key{and then}
2954 (@key{if} Inserted then
2955 Length (Container) = Original_Length + 1
2956 @key{else}
2957 Length (Container) = Original_Length))],Old=[]};]}
2958
2959 @ChgRef{Version=[2],Kind=[AddedNormal]}
2960 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2961 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Map;
2962 Key : @key{in} Key_Type;
2963 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
2964 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
2965 @key{or else raise} Program_Error) @key{and then}
2966 (Length (Container) <= Count_Type'Last - 1
2967 @key{or else raise} Constraint_Error),
2968 Post => Length (Container) = Length (Container)'Old + 1],Old=[]};]}
2969
2970 @ChgRef{Version=[2],Kind=[AddedNormal]}
2971 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2972 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Include} (Container : @key{in out} Map;
2973 Key : @key{in} Key_Type;
2974 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
2975 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
2976 @key{or else raise} Program_Error) @key{and then}
2977 (Length (Container) <= Count_Type'Last - 1
2978 @key{or else raise} Constraint_Error),
2979 Post => (@key{declare}
2980 Original_Length : @key{constant} Count_Type :=
2981 Length (Container)'Old;
2982 @key{begin}
2983 Length (Container)
2984 @key{in} Original_Length | Original_Length + 1)],Old=[]};]}
2985
2986 @ChgRef{Version=[2],Kind=[AddedNormal]}
2987 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2988 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace} (Container : @key{in out} Map;
2989 Key : @key{in} Key_Type;
2990 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
2991 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
2992 @key{or else raise} Program_Error,
2993 Post => Length (Container) = Length (Container)'Old],Old=[]};]}
2994
2995 @ChgRef{Version=[2],Kind=[AddedNormal]}
2996 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
2997 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Exclude} (Container : @key{in out} Map;
2998 Key : @key{in} Key_Type)@Chg{Version=[5],New=[
2999 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
3000 @key{or else raise} Program_Error,
3001 Post => (@key{declare}
3002 Original_Length : @key{constant} Count_Type :=
3003 Length (Container)'Old;
3004 @key{begin}
3005 Length (Container)
3006 @key{in} Original_Length - 1 | Original_Length)],Old=[]};]}
3007
3008 @ChgRef{Version=[2],Kind=[AddedNormal]}
3009 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3010 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Map;
3011 Key : @key{in} Key_Type)@Chg{Version=[5],New=[
3012 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
3013 @key{or else raise} Program_Error,
3014 Post => Length (Container) = Length (Container)'Old - 1],Old=[]};]}
3015
3016 @ChgRef{Version=[2],Kind=[AddedNormal]}
3017 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3018 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Map;
3019 Position : @key{in out} Cursor)@Chg{Version=[5],New=[
3020 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
3021 @key{or else raise} Program_Error) @key{and then}
3022 (Position /= No_Element
3023 @key{or else raise} Constraint_Error) @key{and then}
3024 (Has_Element (Container, Position)
3025 @key{or else raise} Program_Error),
3026 Post => Length (Container) = Length (Container)'Old - 1 @key{and then}
3027 Position = No_Element],Old=[]};]}
3028
3029 @ChgRef{Version=[2],Kind=[AddedNormal]}
3030 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3031 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_First} (Container : @key{in out} Map)@Chg{Version=[5],New=[
3032 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
3033 @key{or else raise} Program_Error,
3034 Post => (@key{declare}
3035 Original_Length : @key{constant} Count_Type :=
3036 Length (Container)'Old;
3037 @key{begin}
3038 (@key{if} Original_Length = 0 @key{then} Length (Container) = 0
3039 @key{else} Length (Container) = Original_Length - 1))],Old=[]};]}
3040
3041 @ChgRef{Version=[2],Kind=[AddedNormal]}
3042 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3043 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_Last} (Container : @key{in out} Map)@Chg{Version=[5],New=[
3044 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
3045 @key{or else raise} Program_Error,
3046 Post => (@key{declare}
3047 Original_Length : @key{constant} Count_Type :=
3048 Length (Container)'Old;
3049 @key{begin}
3050 (@key{if} Original_Length = 0 @key{then} Length (Container) = 0
3051 @key{else} Length (Container) = Original_Length - 1))],Old=[]};]}
3052
3053 @ChgRef{Version=[2],Kind=[AddedNormal]}
3054 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3055 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First} (Container : Map) @key{return} Cursor@Chg{Version=[5],New=[
3056 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3057 Post => (@key{if not} Is_Empty (Container)
3058 @key{then} Has_Element (Container, First'Result)
3059 @key{else} First'Result = No_Element)],Old=[]};]}
3060
3061 @ChgRef{Version=[2],Kind=[AddedNormal]}
3062 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3063 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First_Element} (Container : Map)
3064 @key{return} Element_Type@Chg{Version=[5],New=[
3065 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
3066
3067 @ChgRef{Version=[2],Kind=[AddedNormal]}
3068 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3069 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First_Key} (Container : Map)
3070 @key{return} Key_Type@Chg{Version=[5],New=[
3071 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
3072
3073 @ChgRef{Version=[2],Kind=[AddedNormal]}
3074 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3075 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last} (Container : Map) @key{return} Cursor@Chg{Version=[5],New=[
3076 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3077 Post => (@key{if} not Is_Empty (Container)
3078 @key{then} Has_Element (Container, Last'Result)
3079 @key{else} Last'Result = No_Element)],Old=[]};]}
3080
3081 @ChgRef{Version=[2],Kind=[AddedNormal]}
3082 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3083 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last_Element} (Container : Map)
3084 @key{return} Element_Type@Chg{Version=[5],New=[
3085 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
3086
3087 @ChgRef{Version=[2],Kind=[AddedNormal]}
3088 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3089 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last_Key} (Container : Map)
3090 @key{return} Key_Type@Chg{Version=[5],New=[
3091 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
3092
3093 @ChgRef{Version=[2],Kind=[AddedNormal]}
3094 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3095 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Next} (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
3096 @key{with} Global => (@key{in all}, @key{use null}),
3097 Nonblocking => True,
3098 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
3099 @key{else} True)],Old=[]};]}
3100
3101 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
3102 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Next} (Container : Map;
3103 Position : Cursor) @key{return} Cursor
3104 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3105 Pre => Position = No_Element @key{or else}
3106 Has_Element (Container, Position)
3107 @key{or else raise} Program_Error,
3108 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
3109 @key{elsif} Next'Result = No_Element @key{then}
3110 Position = Last (Container)
3111 @key{else} Has_Element (Container, Next'Result));]}
3112
3113 @ChgRef{Version=[2],Kind=[AddedNormal]}
3114 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3115 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Next} (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
3116 @key{with} Nonblocking, Global => (@key{in all}, @key{use null})],Old=[]};]}
3117
3118 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
3119 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Next} (Container : @key{in} Map;
3120 Position : @key{in out} Cursor)
3121 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3122 Pre => Position = No_Element @key{or else}
3123 Has_Element (Container, Position)
3124 @key{or else raise} Program_Error,
3125 Post => (@key{if} Position /= No_Element
3126 @key{then} Has_Element (Container, Position));]}
3127
3128 @ChgRef{Version=[2],Kind=[AddedNormal]}
3129 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3130 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Previous} (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
3131 @key{with} Nonblocking, Global => (@key{in all}, @key{use null}),
3132 Post => (@key{if} Position = No_Element @key{then}
3133 Previous'Result = No_Element
3134 @key{else} True)],Old=[]};]}
3135
3136 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
3137 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Previous} (Container : Map;
3138 Position : Cursor) @key{return} Cursor
3139 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3140 Pre => Position = No_Element @key{or else}
3141 Has_Element (Container, Position)
3142 @key{or else raise} Program_Error,
3143 Post => (@key{if} Position = No_Element @key{then}
3144 Previous'Result = No_Element
3145 @key{elsif} Previous'Result = No_Element @key{then}
3146 Position = First (Container)
3147 @key{else} Has_Element (Container, Previous'Result));]}
3148
3149 @ChgRef{Version=[2],Kind=[AddedNormal]}
3150 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3151 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Previous} (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
3152 @key{with} Nonblocking, Global => (@key{in all}, @key{use null})],Old=[]};]}
3153
3154 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
3155 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Previous} (Container : @key{in} Map;
3156 Position : @key{in out} Cursor)
3157 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3158 Pre => Position = No_Element @key{or else}
3159 Has_Element (Container, Position)
3160 @key{or else raise} Program_Error,
3161 Post => (@key{if} Position /= No_Element
3162 @key{then} Has_Element (Container, Position));]}
3163
3164 @ChgRef{Version=[2],Kind=[AddedNormal]}
3165 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3166 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Map;
3167 Key : Key_Type) @key{return} Cursor@Chg{Version=[5],New=[
3168 @key{with} Post => (@key{if} Find'Result = No_Element @key{then} True
3169 @key{else} Has_Element (Container, Find'Result))],Old=[]};]}
3170
3171 @ChgRef{Version=[2],Kind=[AddedNormal]}
3172 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Container : Map;
3173 Key : Key_Type) @key{return} Element_Type;]}
3174
3175 @ChgRef{Version=[2],Kind=[AddedNormal]}
3176 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3177 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Floor} (Container : Map;
3178 Key : Key_Type) @key{return} Cursor@Chg{Version=[5],New=[
3179 @key{with} Post => (@key{if} Floor'Result = No_Element @key{then} True
3180 @key{else} Has_Element (Container, Floor'Result))],Old=[]};]}
3181
3182 @ChgRef{Version=[2],Kind=[AddedNormal]}
3183 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3184 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Ceiling} (Container : Map;
3185 Key : Key_Type) @key{return} Cursor@Chg{Version=[5],New=[
3186 @key{with} Post => (@key{if} Ceiling'Result = No_Element @key{then} True
3187 @key{else} Has_Element (Container, Ceiling'Result))],Old=[]};]}
3188
3189 @ChgRef{Version=[2],Kind=[AddedNormal]}
3190 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Map;
3191 Key : Key_Type) @key{return} Boolean;]}
3192
3193 @ChgRef{Version=[2],Kind=[AddedNormal]}
3194 @ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0212-1]}
3195 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]}]}
3196
3197 @ChgRef{Version=[2],Kind=[AddedNormal]}
3198 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3199 @ChgAdded{Version=[2],Text=[ @key{function} "<" (Left, Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
3200 @key{with} Pre => (Left /= No_Element @key{and then} Right /= No_Element)
3201 @key{or else raise} Constraint_Error,
3202 Global => @key{in all}],Old=[]};]}
3203
3204 @ChgRef{Version=[2],Kind=[AddedNormal]}
3205 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3206 @ChgAdded{Version=[2],Text=[ @key{function} ">" (Left, Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
3207 @key{with} Pre => (Left /= No_Element @key{and then} Right /= No_Element)
3208 @key{or else raise} Constraint_Error,
3209 Global => @key{in all}],Old=[]};]}
3210
3211 @ChgRef{Version=[2],Kind=[AddedNormal]}
3212 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3213 @ChgAdded{Version=[2],Text=[ @key{function} "<" (Left : Cursor; Right : Key_Type) @key{return} Boolean@Chg{Version=[5],New=[
3214 @key{with} Pre => Left /= No_Element @key{or else raise} Constraint_Error,
3215 Global => @key{in all}],Old=[]};]}
3216
3217 @ChgRef{Version=[2],Kind=[AddedNormal]}
3218 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3219 @ChgAdded{Version=[2],Text=[ @key{function} ">" (Left : Cursor; Right : Key_Type) @key{return} Boolean@Chg{Version=[5],New=[
3220 @key{with} Pre => Left /= No_Element @key{or else raise} Constraint_Error,
3221 Global => @key{in all}],Old=[]};]}
3222
3223 @ChgRef{Version=[2],Kind=[AddedNormal]}
3224 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3225 @ChgAdded{Version=[2],Text=[ @key{function} "<" (Left : Key_Type; Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
3226 @key{with} Pre => Right /= No_Element @key{or else raise} Constraint_Error,
3227 Global => @key{in all}],Old=[]};]}
3228
3229 @ChgRef{Version=[2],Kind=[AddedNormal]}
3230 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3231 @ChgAdded{Version=[2],Text=[ @key{function} ">" (Left : Key_Type; Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
3232 @key{with} Pre => Right /= No_Element @key{or else raise} Constraint_Error,
3233 Global => @key{in all}],Old=[]};]}
3234
3235 @ChgRef{Version=[2],Kind=[AddedNormal]}
3236 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3237 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Iterate}
3238 (Container : @key{in} Map;
3239 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
3240 @key{with} Allows_Exit],Old=[]};]}
3241
3242 @ChgRef{Version=[2],Kind=[AddedNormal]}
3243 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3244 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reverse_Iterate}
3245 (Container : @key{in} Map;
3246 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
3247 @key{with} Allows_Exit],Old=[]};]}
3248
3249 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
3250 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1],ARef=[AI12-0266-1]}
3251 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Iterate} (Container : @key[in] Map)
3252 @key[return] Map_Iterator_Interfaces.@Chg{Version=[5],New=[Parallel_Reversible_Iterator],Old=[Reversible_Iterator]}'Class@Chg{Version=[5],New=[
3253 @key[with] Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
3254
3255 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0262-1]}
3256 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
3257 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Iterate} (Container : @key[in] Map; Start : @key[in] Cursor)
3258 @key[return] Map_Iterator_Interfaces.Reversible_Iterator'Class@Chg{Version=[5],New=[
3259 @key[with] Pre => (Start /= No_Element
3260 @key[or else raise] Constraint_Error) @key[and then]
3261 (Has_Element (Container, Start)
3262 @key[or else raise] Program_Error),
3263 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
3264
3265 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3266 @ChgAdded{Version=[5],Text=[ @key{package} @AdaPackDefn{Stable} @key{is}]}
3267
3268 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1],ARef=[AI12-0339-1]}
3269 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Map} (Base : @key{not null access} Ordered_Maps.Map) @key{is}
3270 @key{tagged limited private}
3271 @key{with} Constant_Indexing => Constant_Reference,
3272 Variable_Indexing => Reference,
3273 Default_Iterator => Iterate,
3274 Iterator_Element => Element_Type,
3275 Aggregate => (Empty => Empty,
3276 Add_Named => Insert),
3277 Stable_Properties => (Length),
3278 Global => @key[null],
3279 Default_Initial_Condition => Length (Map) = 0;
3280 @key{pragma} Preelaborable_Initialization(Map);]}
3281
3282 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3283 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private};
3284 @key{pragma} Preelaborable_Initialization(Cursor);]}
3285
3286 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3287 @ChgAdded{Version=[5],Text=[ @AdaObjDefn{Empty_Map} : @key{constant} Map;]}
3288
3289 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3290 @ChgAdded{Version=[5],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]}
3291
3292 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3293 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean
3294 @key{with} Nonblocking, Global => (@key{in all}, @key{use null});]}
3295
3296 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3297 @ChgAdded{Version=[5],Text=[ @key{package} @AdaPackDefn{Map_Iterator_Interfaces} @key[is new]
3298 Ada.Iterator_Interfaces (Cursor, Has_Element);]}
3299
3300 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3301 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} Ordered_Maps.Map;
3302 Source : @key{in} Map)
3303 @key{with} Post => Length (Source) = Length (Target);]}
3304
3305 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3306 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Copy} (Source : Ordered_Maps.Map) @key{return} Map
3307 @key{with} Post => Length (Copy'Result) = Length (Source);]}
3308
3309 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3310 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Constant_Reference_Type}
3311 (Element : @key{not null access constant} Element_Type) @key{is private}
3312 @key{with} Implicit_Dereference => Element,
3313 Nonblocking, Global => (@key{null}, @key{use null}),
3314 Default_Initial_Condition => (@key{raise} Program_Error);]}
3315
3316 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3317 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Reference_Type}
3318 (Element : @key{not null access} Element_Type) @key{is private}
3319 @key{with} Implicit_Dereference => Element,
3320 Nonblocking, Global => (@key{null}, @key{use null}),
3321 Default_Initial_Condition => (@key{raise} Program_Error);]}
3322
3323 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3324 @ChgAdded{Version=[5],Text=[ -- @examcom{Additional subprograms as described in the text}
3325 -- @examcom{are declared here.}]}
3326
3327 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3328 @ChgAdded{Version=[5],Text=[ @key{private}]}
3329
3330 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3331 @ChgAdded{Version=[5],Text=[ ... -- @Examcom{not specified by the language}]}
3332
3333 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
3334 @ChgAdded{Version=[5],Text=[ @key{end} Stable;]}
3335
3336 @ChgRef{Version=[2],Kind=[AddedNormal]}
3337 @ChgAdded{Version=[2],Text=[@key{private}]}
3338
3339 @ChgRef{Version=[2],Kind=[AddedNormal]}
3340 @ChgAdded{Version=[2],Text=[ ... -- @RI[not specified by the language]]}
3341
3342 @ChgRef{Version=[2],Kind=[AddedNormal]}
3343 @ChgAdded{Version=[2],Text=[@key{end} Ada.Containers.Ordered_Maps;]}
3344
3345 @end{Example}
3346
3347 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3348 @ChgAdded{Version=[2],Text=[@Defn2{Term={equivalent key},Sec={of an ordered map}}
3349 Two keys @i<K1> and @i<K2> are @i<equivalent> if both @i<K1> < @i<K2> and
3350 @i<K2> < @i<K1> return False, using the generic formal "<" operator for keys.
3351 Function Equivalent_Keys returns True if Left and Right are equivalent, and
3352 False otherwise.]}
3353
3354 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3355 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0044-1]}
3356 @ChgAdded{Version=[2],Text=[The actual function for the generic formal function
3357 "<" on Key_Type values is expected to return the same value each time it is
3358 called with a particular pair of key values. It should define a strict
3359 @Chg{Version=[3],New=[weak ],Old=[]}ordering relationship@Chg{Version=[3],
3360 New=[ (see @RefSecNum{Containers})],Old=[, that is, be irreflexive, asymmetric,
3361 and transitive]}. If the
3362 actual for "<" behaves in some other manner, the behavior of this package is
3363 unspecified. Which subprograms of this package call "<" and how many times they
3364 call it, is unspecified.@PDefn{unspecified}]}
3365
3366 @begin{ImplNote}
3367 @ChgRef{Version=[2],Kind=[AddedNormal]}
3368 @ChgAdded{Version=[2],Text=[The implementation is not required to protect
3369 against "<" raising an exception, or returning random results, or any
3370 other @lquotes@;bad@rquotes behavior. It's not practical to do so, and a
3371 broken "<" function makes the container unusable.]}
3372
3373 @ChgRef{Version=[2],Kind=[AddedNormal]}
3374 @ChgAdded{Version=[2],Text=[The implementation can call "<" whenever
3375 it is needed; we don't want to specify how often that happens. The result
3376 must remain the same (this is a logically pure function), or the behavior is
3377 unspecified.]}
3378 @end{ImplNote}
3379
3380 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3381 @ChgAdded{Version=[2],Text=[If the value of a key stored in a map is changed
3382 other than by an operation in this package such that at least one of "<" or "="
3383 give different results, the behavior of this package is
3384 unspecified.@PDefn{unspecified}]}
3385
3386 @begin{ImplNote}
3387 @ChgRef{Version=[2],Kind=[AddedNormal]}
3388 @ChgAdded{Version=[2],Text=[The implementation is not required to protect
3389 against changes to key values other than via the operations declared in the
3390 Ordered_Maps package.]}
3391
3392 @ChgRef{Version=[2],Kind=[AddedNormal]}
3393 @ChgAdded{Version=[2],Type=[Leading],Text=[To see how this could happen,
3394 imagine an instance of Ordered_Maps package where the key type is an
3395 access-to-variable type and "<" returns a value derived from comparing the
3396 components of the designated objects. Then, any operation that has a key
3397 value (even if the key value is constant) could modify those components and
3398 change the result of "<":]}
3399
3400 @begin{example}
3401 @ChgRef{Version=[2],Kind=[AddedNormal]}
3402 @ChgAdded{Version=[2],Text=[Key (Map).Some_Component := New_Value;]}
3403 @end{example}
3404
3405 @ChgRef{Version=[2],Kind=[AddedNormal]}
3406 @ChgAdded{Version=[2],Text=[This is really a design error on the part of the
3407 user of the map; it shouldn't be possible to modify keys stored in a map such
3408 that "<" changes. But we can't prevent this error anymore than we can prevent
3409 someone passing as "<" a routine that produces random answers.]}
3410 @end{ImplNote}
3411
3412 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3413 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]}
3414 @ChgAdded{Version=[2],Text=[@Defn2{Term=[first node],Sec=[of an ordered map]}
3415 @Defn2{Term=[last node],Sec=[of an ordered map]}
3416 @Defn2{Term=[successor node],Sec=[of an ordered map]}@Chg{Version=[3],New=[
3417 @Defn2{Term=[predecessor node],Sec=[of an ordered map]}],Old=[]}
3418 The @Chg{Version=[3],New=[@i<first node>],Old=[first node]}
3419 of a nonempty map is the one whose key is less than the key of
3420 all the other nodes in the map. The @Chg{Version=[3],New=[@i<last node>],Old=[last node]}
3421 of a nonempty map is the one
3422 whose key is greater than the key of all the other elements in the map. The
3423 @Chg{Version=[3],New=[@i<successor>],Old=[successor]}
3424 of a node is the node with the smallest key that is larger than the
3425 key of the given node. The @Chg{Version=[3],New=[@i<predecessor>],Old=[predecessor]}
3426 of a node is the node with the largest key that is smaller than the key of the
3427 given node. All comparisons are done using the generic formal "<" operator for
3428 keys.]}
3429
3430 @begin{DescribeCode}
3431
3432 @begin{Example}
3433 @ChgRef{Version=[3],Kind=[Added]}
3434 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
3435 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Copy (Source : Map)
3436 @key[return] Map@Chg{Version=[5],New=[
3437 @key[with] Post =>
3438 Length (Copy'Result) = Length (Source) @key[and then]
3439 @key[not] Tampering_With_Elements_Prohibited (Copy'Result) @key[and then]
3440 @key[not] Tampering_With_Cursors_Prohibited (Copy'Result)],Old=[]};]}
3441 @end{Example}
3442
3443 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
3444 @ChgAdded{Version=[3],Type=[Trailing],Text=[Returns a map whose keys and
3445 elements are initialized from the corresponding keys and elements of Source.]}
3446
3447 @begin{Example}
3448 @ChgRef{Version=[2],Kind=[AddedNormal]}
3449 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3450 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_First (Container : @key{in out} Map)@Chg{Version=[5],New=[
3451 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
3452 @key{or else raise} Program_Error,
3453 Post => (@key{declare}
3454 Original_Length : @key{constant} Count_Type :=
3455 Length (Container)'Old;
3456 @key{begin}
3457 (@key{if} Original_Length = 0 @key{then} Length (Container) = 0
3458 @key{else} Length (Container) = Original_Length - 1))],Old=[]};]}
3459 @end{Example}
3460
3461 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3462 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
3463 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Delete_First
3464 has no effect. Otherwise@Chg{Version=[3],New=[,],Old=[]}
3465 the node designated by First (Container) is removed
3466 from Container. Delete_First tampers with the cursors of Container.]}
3467
3468 @begin{Example}
3469 @ChgRef{Version=[2],Kind=[AddedNormal]}
3470 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3471 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_Last (Container : @key{in out} Map)@Chg{Version=[5],New=[
3472 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
3473 @key{or else raise} Program_Error,
3474 Post => (@key{declare}
3475 Original_Length : @key{constant} Count_Type :=
3476 Length (Container)'Old;
3477 @key{begin}
3478 (@key{if} Original_Length = 0 @key{then} Length (Container) = 0
3479 @key{else} Length (Container) = Original_Length - 1))],Old=[]};]}
3480 @end{Example}
3481
3482
3483 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3484 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
3485 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Delete_Last
3486 has no effect. Otherwise@Chg{Version=[3],New=[,],Old=[]}
3487 the node designated by Last (Container) is removed
3488 from Container. Delete_Last tampers with the cursors of Container.]}
3489
3490 @begin{Example}
3491 @ChgRef{Version=[2],Kind=[AddedNormal]}
3492 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3493 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First_Element (Container : Map)
3494 @key{return} Element_Type@Chg{Version=[5],New=[
3495 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
3496 @end{Example}
3497
3498 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3499 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (First (Container)).]}
3500
3501 @begin{Example}
3502 @ChgRef{Version=[2],Kind=[AddedNormal]}
3503 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3504 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First_Key (Container : Map)
3505 @key{return} Key_Type@Chg{Version=[5],New=[
3506 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
3507 @end{Example}
3508
3509 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3510 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (First (Container)).]}
3511
3512 @begin{Example}
3513 @ChgRef{Version=[2],Kind=[AddedNormal]}
3514 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3515 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last (Container : Map) @key{return} Cursor@Chg{Version=[5],New=[
3516 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3517 Post => (@key{if} not Is_Empty (Container)
3518 @key{then} Has_Element (Container, Last'Result)
3519 @key{else} Last'Result = No_Element)],Old=[]};]}
3520 @end{Example}
3521
3522 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3523 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a cursor that designates
3524 the last node in Container. If Container is empty, returns No_Element.]}
3525
3526 @begin{Example}
3527 @ChgRef{Version=[2],Kind=[AddedNormal]}
3528 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3529 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last_Element (Container : Map)
3530 @key{return} Element_Type@Chg{Version=[5],New=[
3531 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
3532 @end{Example}
3533
3534 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3535 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Last (Container)).]}
3536
3537 @begin{Example}
3538 @ChgRef{Version=[2],Kind=[AddedNormal]}
3539 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3540 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last_Key (Container : Map)
3541 @key{return} Key_Type@Chg{Version=[5],New=[
3542 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
3543 @end{Example}
3544
3545 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3546 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (Last (Container)).]}
3547
3548 @begin{Example}
3549 @ChgRef{Version=[2],Kind=[AddedNormal]}
3550 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3551 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Previous (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
3552 @key{with} Nonblocking, Global => (@key{in all}, @key{use null}),
3553 Post => (@key{if} Position = No_Element @key{then}
3554 Previous'Result = No_Element
3555 @key{else} True)],Old=[]};]}
3556 @end{Example}
3557
3558 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3559 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]}
3560 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then
3561 Previous returns No_Element. Otherwise@Chg{Version=[3],New=[,],Old=[]}
3562 Previous returns a cursor designating the @Chg{Version=[3],New=[predecessor
3563 ],Old=[]}node @Chg{Version=[3],New=[of],Old=[that precedes]} the one designated
3564 by Position. If Position designates the first element, then Previous returns
3565 No_Element.]}
3566
3567 @begin{Example}
3568 @ChgRef{Version=[5],Kind=[Added]}
3569 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Previous (Container : Map;
3570 Position : Cursor) @key{return} Cursor
3571 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3572 Pre => Position = No_Element @key{or else}
3573 Has_Element (Container, Position)
3574 @key{or else raise} Program_Error,
3575 Post => (@key{if} Position = No_Element @key{then}
3576 Previous'Result = No_Element
3577 @key{elsif} Previous'Result = No_Element @key{then}
3578 Position = First (Container)
3579 @key{else} Has_Element (Container, Previous'Result));]}
3580 @end{Example}
3581
3582 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
3583 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns a cursor designating the
3584 predecessor of the node designated by Position in Container, if any.]}
3585
3586 @begin{Example}
3587 @ChgRef{Version=[2],Kind=[AddedNormal]}
3588 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3589 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Previous (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
3590 @key{with} Nonblocking, Global => (@key{in all}, @key{use null})],Old=[]};]}
3591 @end{Example}
3592
3593 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3594 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Previous (Position).]}
3595
3596 @begin{Example}
3597 @ChgRef{Version=[5],Kind=[Added]}
3598 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{procedure} Previous (Container : @key{in} Map;
3599 Position : @key{in out} Cursor)
3600 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
3601 Pre => Position = No_Element @key{or else}
3602 Has_Element (Container, Position)
3603 @key{or else raise} Program_Error,
3604 Post => (@key{if} Position /= No_Element
3605 @key{then} Has_Element (Container, Position));]}
3606 @end{Example}
3607
3608 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
3609 @ChgAdded{Version=[5],Type=[Trailing],Text=[Equivalent to Position :=
3610 Previous (Container, Position).]}
3611
3612 @begin{Example}
3613 @ChgRef{Version=[2],Kind=[AddedNormal]}
3614 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3615 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Floor (Container : Map;
3616 Key : Key_Type) @key{return} Cursor@Chg{Version=[5],New=[
3617 @key{with} Post => (@key{if} Floor'Result = No_Element @key{then} True
3618 @key{else} Has_Element (Container, Floor'Result))],Old=[]};]}
3619 @end{Example}
3620
3621 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3622 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
3623 @ChgAdded{Version=[2],Type=[Trailing],Text=[Floor searches for the last node
3624 whose key is not greater than Key, using the generic formal "<" operator for keys.
3625 If such a node is found, a cursor that designates it is returned.
3626 Otherwise@Chg{Version=[3],New=[,],Old=[]}
3627 No_Element is returned.]}
3628
3629 @begin{Example}
3630 @ChgRef{Version=[2],Kind=[AddedNormal]}
3631 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3632 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Ceiling (Container : Map;
3633 Key : Key_Type) @key{return} Cursor@Chg{Version=[5],New=[
3634 @key{with} Post => (@key{if} Ceiling'Result = No_Element @key{then} True
3635 @key{else} Has_Element (Container, Ceiling'Result))],Old=[]};]}
3636 @end{Example}
3637
3638 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3639 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
3640 @ChgAdded{Version=[2],Type=[Trailing],Text=[Ceiling searches for the first node
3641 whose key is not less than Key, using the generic formal "<" operator for keys.
3642 If such a node is found, a cursor that designates it is returned.
3643 Otherwise@Chg{Version=[3],New=[,],Old=[]} No_Element is returned.]}
3644
3645 @begin{Example}
3646 @ChgRef{Version=[2],Kind=[AddedNormal]}
3647 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3648 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "<" (Left, Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
3649 @key{with} Pre => (Left /= No_Element @key{and then} Right /= No_Element)
3650 @key{or else raise} Constraint_Error,
3651 Global => @key{in all}],Old=[]};]}
3652 @end{Example}
3653
3654 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3655 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (Left) < Key (Right).]}
3656
3657 @begin{Example}
3658 @ChgRef{Version=[2],Kind=[AddedNormal]}
3659 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3660 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} ">" (Left, Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
3661 @key{with} Pre => (Left /= No_Element @key{and then} Right /= No_Element)
3662 @key{or else raise} Constraint_Error,
3663 Global => @key{in all}],Old=[]};]}
3664 @end{Example}
3665
3666 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3667 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (Right) < Key (Left).]}
3668
3669 @begin{Example}
3670 @ChgRef{Version=[2],Kind=[AddedNormal]}
3671 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3672 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "<" (Left : Cursor; Right : Key_Type) @key{return} Boolean@Chg{Version=[5],New=[
3673 @key{with} Pre => Left /= No_Element @key{or else raise} Constraint_Error,
3674 Global => @key{in all}],Old=[]};]}
3675 @end{Example}
3676
3677 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3678 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (Left) < Right.]}
3679
3680 @begin{Example}
3681 @ChgRef{Version=[2],Kind=[AddedNormal]}
3682 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3683 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} ">" (Left : Cursor; Right : Key_Type) @key{return} Boolean@Chg{Version=[5],New=[
3684 @key{with} Pre => Left /= No_Element @key{or else raise} Constraint_Error,
3685 Global => @key{in all}],Old=[]};]}
3686 @end{Example}
3687
3688 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3689 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Right < Key (Left).]}
3690
3691 @begin{Example}
3692 @ChgRef{Version=[2],Kind=[AddedNormal]}
3693 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3694 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "<" (Left : Key_Type; Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
3695 @key{with} Pre => Right /= No_Element @key{or else raise} Constraint_Error,
3696 Global => @key{in all}],Old=[]};]}
3697 @end{Example}
3698
3699 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3700 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Left < Key (Right).]}
3701
3702 @begin{Example}
3703 @ChgRef{Version=[2],Kind=[AddedNormal]}
3704 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3705 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} ">" (Left : Key_Type; Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
3706 @key{with} Pre => Right /= No_Element @key{or else raise} Constraint_Error,
3707 Global => @key{in all}],Old=[]};]}
3708 @end{Example}
3709
3710 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3711 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (Right) < Left.]}
3712
3713 @begin{Example}
3714 @ChgRef{Version=[2],Kind=[AddedNormal]}
3715 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
3716 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reverse_Iterate
3717 (Container : @key{in} Map;
3718 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
3719 @key{with} Allows_Exit],Old=[]};]}
3720 @end{Example}
3721
3722 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3723 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]}
3724 @ChgAdded{Version=[2],Type=[Trailing],Text=[Iterates over the nodes in
3725 Container as per @Chg{Version=[3],New=[procedure ],Old=[]}Iterate,
3726 with the difference that the nodes are traversed in
3727 predecessor order, starting with the last node.]}
3728
3729 @begin{Example}
3730 @ChgRef{Version=[3],Kind=[Added]}
3731 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1],ARef=[AI12-0266-1]}
3732 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Map)
3733 @key[return] Map_Iterator_Interfaces.@Chg{Version=[5],New=[Parallel_Reversible_Iterator],Old=[Reversible_Iterator]}'Class@Chg{Version=[5],New=[
3734 @key[with] Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
3735 @end{Example}
3736
3737 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]}
3738 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0266-1]}
3739 @ChgAdded{Version=[3],Type=[Trailing],Text=[Iterate returns
3740 @Chg{Version=[5],New=[an],Old=[a reversible]}
3741 iterator object (see @RefSecNum{User-Defined Iterator Types}) that
3742 will generate a value for a loop parameter
3743 (see @RefSecNum{Generalized Loop Iteration}) designating
3744 each node in Container, starting with the first node and moving the cursor
3745 according to the successor relation when used as a forward iterator, and
3746 starting with the last node and moving the cursor according to the predecessor
3747 relation when used as a reverse iterator@Chg{Version=[5],New=[, and processing
3748 all nodes concurrently when used as a parallel iterator],Old=[]}.
3749 Tampering with the cursors of Container is prohibited while
3750 the iterator object exists (in particular, in
3751 the @nt{sequence_of_statements} of the @nt{loop_statement} whose
3752 @nt{iterator_specification} denotes this object). The iterator object needs
3753 finalization.]}
3754
3755 @begin{Example}
3756 @ChgRef{Version=[3],Kind=[Added]}
3757 @ChgRef{Version=[5],Kind=[RevisedAdded]}
3758 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Map; Start : @key[in] Cursor)
3759 @key[return] Map_Iterator_Interfaces.Reversible_Iterator'Class@Chg{Version=[5],New=[
3760 @key[with] Pre => (Start /= No_Element
3761 @key[or else raise] Constraint_Error) @key[and then]
3762 (Has_Element (Container, Start)
3763 @key[or else raise] Program_Error),
3764 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
3765 @end{Example}
3766
3767 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0262-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]}
3768 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
3769 @ChgAdded{Version=[3],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
3770 Start is not No_Element and does not designate an item in Container,
3771 then Program_Error is propagated. If Start is No_Element, then Constraint_Error
3772 is propagated. Otherwise, ]}Iterate returns a reversible iterator object
3773 (see @RefSecNum{User-Defined Iterator Types}) that will generate
3774 a value for a loop parameter (see @RefSecNum{Generalized Loop Iteration})
3775 designating each node in Container, starting with
3776 the node designated by Start and moving the cursor according to the successor
3777 relation when used as a forward iterator, or moving the cursor according to the
3778 predecessor relation when used as a reverse iterator.
3779 Tampering with the cursors of Container is prohibited while the iterator object
3780 exists (in particular, in the @nt{sequence_of_statements} of the
3781 @nt{loop_statement} whose @nt{iterator_specification} denotes this object). The
3782 iterator object needs finalization.]}
3783
3784 @begin{Discussion}
3785 @ChgRef{Version=[3],Kind=[AddedNormal]}
3786 @ChgAdded{Version=[3],Type=[Leading],Text=[Exits are allowed from the loops
3787 created using the iterator objects. In particular, to stop the iteration at a
3788 particular cursor, just add]}
3789 @begin{Example}
3790 @ChgRef{Version=[3],Kind=[AddedNormal]}
3791 @ChgAdded{Version=[3],Text=[@key[exit when] Cur = Stop;]}
3792 @end{Example}
3793 @ChgRef{Version=[3],Kind=[AddedNormal]}
3794 @ChgAdded{Version=[3],Type=[Trailing],Text=[in the body of the loop (assuming
3795 that @exam{Cur} is the loop parameter and @exam{Stop} is the cursor that you
3796 want to stop at).]}
3797 @end{Discussion}
3798 @end{DescribeCode}
3799 @end{StaticSem}
3800
3801 @begin{ImplAdvice}
3802
3803 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3804 @ChgAdded{Version=[2],Text=[If @i<N> is the length of a map, then the
3805 worst-case time complexity of the
3806 Element, Insert, Include, Replace, Delete, Exclude and Find operations that
3807 take a key parameter should be @i{O}((log @i<N>)**2) or better. The worst-case
3808 time complexity of the subprograms that take a cursor parameter should be @i{O}(1).]}
3809 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
3810 Text=[The worst-case time complexity of Element, Insert, Include, Replace,
3811 Delete, Exclude and Find operations that
3812 take a key parameter for Containers.Ordered_Maps should be
3813 @i{O}((log @i<N>)**2) or better. The worst-case
3814 time complexity of the subprograms of Containers.Ordered_Maps that take
3815 a cursor parameter should be @i{O}(1).]}]}
3816
3817 @begin{ImplNote}
3818 @ChgRef{Version=[2],Kind=[AddedNormal]}
3819 @ChgAdded{Version=[2],Text=[A balanced (red-black) tree for keys has
3820 @i{O}(log @i<N>) worst-case performance. Note that a @i{O}(@i<N>) worst-case
3821 implementation (like a list) would be wrong.]}
3822 @end{ImplNote}
3823
3824 @begin{Reason}
3825 @ChgRef{Version=[2],Kind=[AddedNormal]}
3826 @ChgAdded{Version=[2],Text=[We do not mean to overly constrain implementation
3827 strategies here. However, it is important for portability that the
3828 performance of large containers has roughly the same factors on different
3829 implementations. If a program is moved to an implementation that takes @i{O}(@i<N>)
3830 to find elements, that program could be unusable when the maps are large. We
3831 allow the extra log @i<N> factors because the proportionality constant and
3832 caching effects are likely to be larger than the log factor, and we don't
3833 want to discourage innovative implementations.]}
3834 @end{Reason}
3835
3836 @end{ImplAdvice}
3837
3838 @begin{Extend95}
3839 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3840 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
3841 The generic package Containers.Ordered_Maps is new.]}
3842 @end{Extend95}
3843
3844 @begin{Incompatible2005}
3845 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
3846 @ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Subprograms Assign and Copy
3847 are added to Containers.Ordered_Maps. If an instance of Containers.Ordered_Maps
3848 is referenced in a @nt{use_clause}, and an entity @i<E> with the same
3849 @nt{defining_identifier} as a new entity in Containers.Ordered_Maps is
3850 defined in a package that is also referenced in a @nt{use_clause}, the
3851 entity @i<E> may no longer be use-visible, resulting in errors. This should
3852 be rare and is easily fixed if it does occur.]}
3853 @end{Incompatible2005}
3854
3855 @begin{Extend2005}
3856 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]}
3857 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
3858 Added iterator and indexing support to make ordered map containers more
3859 convenient to use.]}
3860 @end{Extend2005}
3861
3862 @begin{DiffWord2005}
3863 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]}
3864 @ChgAdded{Version=[3],Text=[@b<Correction:> Redefined "<" actuals
3865 to require a strict weak ordering; the old definition allowed
3866 indeterminant comparisons that would not have worked in a container.]}
3867
3868 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0084-1]}
3869 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a pragma
3870 Remote_Types so that containers can be used in distributed programs.]}
3871 @end{DiffWord2005}
3872
3873 @begin{Incompatible2012}
3874 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1],ARef=[AI12-0112-1],ARef=[AI12-0339-1]}
3875 @ChgAdded{Version=[5],Text=[@Defn{incompatibilities with Ada 2012}A number of
3876 new subprograms, types, and even a nested package were added to
3877 Containers.Ordered_Maps to better support contracts and stable views. If an
3878 instance of Containers.Ordered_Maps
3879 is referenced in a @nt{use_clause}, and an entity @i<E> with the same
3880 @nt{defining_identifier} as a new entity in Containers.Ordered_Maps is
3881 defined in a package that is also referenced in a @nt{use_clause}, the
3882 entity @i<E> may no longer be use-visible, resulting in errors. This should
3883 be rare and is easily fixed if it does occur.]}
3884 @end{Incompatible2012}
3885
3886 @begin{Extend2012}
3887 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0212-1]}
3888 @ChgAdded{Version=[5],Text=[@Defn{extensions to Ada 2012}Maps now support
3889 named container aggregates, so @nt{aggregate} syntax can be used to
3890 create Maps.]}
3891
3892 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0266-1]}
3893 @ChgAdded{Version=[5],Text=[The iterator for the
3894 entire container now can return a parallel iterator which can be used to
3895 process the container in parallel.]}
3896 @end{Extend2012}
3897
3898 @begin{DiffWord2012}
3899 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
3900 @ChgAdded{Version=[5],Text=[Added contracts to this container. This includes
3901 describing some of the semantics with pre- and postconditions, rather than
3902 English text. Note that the preconditions can be Suppressed (see
3903 @RefSecNum{Suppressing Checks}).]}
3904 @end{DiffWord2012}
3905
3906
3907 @LabeledAddedSubclause{Version=[2],Name=[Sets]}
3908
3909 @begin{Intro}
3910 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3911 @ChgAdded{Version=[2],Text=[The language-defined generic packages
3912 Containers.Hashed_Sets and Containers.Ordered_Sets provide private types Set
3913 and Cursor, and a set of operations for each type. A set container allows
3914 elements of an arbitrary type to be stored without duplication. A hashed set
3915 uses a hash function to organize elements, while an ordered set orders its
3916 element per a specified relation.@Defn{set container}
3917 @Defn2{Term=[container],Sec=[set]}]}
3918
3919 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3920 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
3921 @ChgAdded{Version=[2],Text=[This @Chg{Version=[3],New=[subclause],Old=[section]}
3922 describes the declarations that are common to both kinds of sets.
3923 See @RefSecNum{The Generic Package Containers.Hashed_Sets} for a description of the
3924 semantics specific to
3925 Containers.Hashed_Sets and @RefSecNum{The Generic Package Containers.Ordered_Sets} for
3926 a description of the semantics specific to Containers.Ordered_Sets.]}
3927 @end{Intro}
3928
3929 @begin{StaticSem}
3930
3931 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3932 @ChgAdded{Version=[2],Text=[The actual function for the generic formal function
3933 "=" on Element_Type values is expected to define a reflexive and symmetric
3934 relationship and return the same result value each time it is called with a
3935 particular pair of values. If it behaves in some other manner, the function
3936 "=" on set values returns an unspecified value. The
3937 exact arguments and number of calls of this generic formal function by the
3938 function "=" on set values are unspecified.@PDefn{unspecified}]}
3939
3940 @begin{Ramification}
3941 @ChgRef{Version=[2],Kind=[AddedNormal]}
3942 @ChgAdded{Version=[2],Text=[If the actual function for "=" is not symmetric
3943 and consistent, the result returned by the "=" for Set objects cannot be
3944 predicted. The implementation is not required to protect
3945 against "=" raising an exception, or returning random results, or any
3946 other @lquotes@;bad@rquotes behavior. And it can call "=" in whatever
3947 manner makes sense. But note that only the result of "=" for Set objects
3948 is unspecified; other subprograms are not allowed to break if "=" is bad
3949 (they aren't expected to use "=").]}
3950 @end{Ramification}
3951
3952 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3953 @ChgAdded{Version=[2],Text=[The type Set is used to represent sets. The type
3954 Set needs finalization@PDefn2{Term=<needs finalization>,Sec=<language-defined type>}
3955 (see @RefSecNum{Assignment and Finalization}).]}
3956
3957 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3958 @ChgAdded{Version=[2],Text=[A set contains elements. Set cursors designate
3959 elements. There exists an equivalence relation on elements, whose definition is
3960 different for hashed sets and ordered sets. A set never contains two or more
3961 equivalent elements. The @i{length} of a set is the number of elements it
3962 contains.@Defn2{Term={length},Sec={of a set}}]}
3963
3964 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3965 @ChgAdded{Version=[2],Text=[@Defn2{Term=[first element],Sec=[of a set]}
3966 @Defn2{Term=[last element],Sec=[of a set]}
3967 @Defn2{Term=[successor element],Sec=[of a set]}
3968 Each nonempty set has two particular elements called the @i{first element} and
3969 the @i{last element} (which may be the same). Each element except for the last
3970 element has a @i{successor element}. If there are no other intervening
3971 operations, starting with the first element and repeatedly going to the
3972 successor element will visit each element in the set exactly once until the
3973 last element is reached. The exact definition of these terms is different for
3974 hashed sets and ordered sets.]}
3975
3976 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
3977 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
3978 @ChgAdded{Version=[2],Text=[@Redundant[Some
3979 operations @Chg{Version=[5],New=[@Defn2{Term=[tamper with cursors],Sec=[of a set]}@Defn2{Term=[tamper with elements],Sec=[of a set]}],Old=[of
3980 these generic packages
3981 have access-to-subprogram parameters. To ensure such operations are
3982 well-defined, they guard against certain actions by the designated
3983 subprogram. In particular, some operations]} check for @lquotes@;tampering with
3984 cursors@rquotes of a container because they depend on the set of elements of
3985 the container remaining constant@Chg{Version=[5],New=[ and ],Old=[, and others
3986 check for @lquotes@;tampering with
3987 elements@rquotes of a container because they depend]} on elements of the
3988 container not being replaced.]@Chg{Version=[5],New=[ When
3989 tampering with cursors is @i<prohibited>@Defn2{Term=[prohibited],Sec=[tampering with a set]}
3990 @Defn2{Term=[tampering],Sec=[prohibited for a set]}for a particular
3991 set object @i<M>, Program_Error is propagated by the finalization
3992 of @i<M>@Redundant[, as well as by a call that passes @i<M> to
3993 certain of the operations of this package, as indicated by the precondition
3994 of such an operation].],Old=[]}]}
3995
3996 @begin{Discussion}
3997 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
3998 @ChgAdded{Version=[5],Text=[Note that Replace_Element tampers with cursors
3999 because it might delete and reinsert the element if it moves in the set.
4000 That could change the order of iteration, which is what this check is
4001 designed to prevent. Replace also tampers with cursors, as it is defined
4002 in terms of Replace_Element.]}
4003
4004 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
4005 @ChgAdded{Version=[5],Text=[These inclusions mean that there are no operations
4006 that would tamper with elements that do not tamper with cursors. As such,
4007 we do not define tampering with elements at all for set containers. Earlier
4008 versions of Ada did so just so the description of subprograms are the same
4009 between containers, but since we've changed those to pre- and postconditions
4010 which are necessarily specific to each container, there no longer seems to
4011 be any reason to define tampering with elements for sets.]}
4012 @end{Discussion}
4013
4014 @begin{NotIso}
4015 @ChgAdded{Version=[5],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 8 through 14
4016 are removed as preconditions now describe these rules.>}]}@Comment{This message should be
4017 deleted if the paragraphs are ever renumbered.}
4018 @end{NotIso}
4019
4020 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4021 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
4022 @ChgDeleted{Version=[5],Type=[Leading],Text=[@Chg{Version=[2],New=[@Defn2{Term=[tamper with cursors],Sec=[of a set]}
4023 A subprogram is said to @i{tamper with cursors} of a set object @i<S>
4024 if:],Old=[]}]}
4025 @begin{Itemize}
4026
4027 @ChgRef{Version=[2],Kind=[AddedNormal]}
4028 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
4029 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
4030 inserts or deletes elements of @i{S}, that is,
4031 it calls the Insert, Include, Clear, Delete, Exclude, or Replace_Element
4032 procedures with @i{S} as a parameter; or]}]}
4033
4034 @begin{Honest}
4035 @ChgRef{Version=[2],Kind=[AddedNormal]}
4036 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
4037 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[Operations which
4038 are defined to be equivalent to
4039 a call on one of these operations also are included. Similarly, operations
4040 which call one of these as part of their definition are included.]}]}
4041 @end{Honest}
4042
4043 @begin{Discussion}
4044 @ChgRef{Version=[2],Kind=[AddedNormal]}
4045 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
4046 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[We have to
4047 include Replace_Element here because
4048 it might delete and reinsert the element if it moves in the set. That could
4049 change the order of iteration, which is what this check is designed to
4050 prevent. Replace is also included, as it is defined in terms of
4051 Replace_Element.]}]}
4052 @end{Discussion}
4053
4054 @ChgRef{Version=[2],Kind=[AddedNormal]}
4055 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
4056 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
4057 finalizes @i<S>; or]}]}
4058
4059 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
4060 @ChgRef{Version=[5],Kind=[DeletedAddedNoDelMsg]}
4061 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[it
4062 calls the Assign procedure with @i<S> as the Target parameter; or]}]}
4063
4064 @begin{Ramification}
4065 @ChgRef{Version=[3],Kind=[AddedNormal]}
4066 @ChgAdded{Version=[3],Text=[We don't need to explicitly mention
4067 @nt{assignment_statement}, because that finalizes the target object
4068 as part of the operation, and finalization of an object is already defined
4069 as tampering with cursors.]}
4070 @end{Ramification}
4071
4072 @ChgRef{Version=[2],Kind=[AddedNormal]}
4073 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
4074 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
4075 calls the Move procedure with @i<S> as a parameter; or]}]}
4076
4077 @ChgRef{Version=[2],Kind=[AddedNormal]}
4078 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
4079 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
4080 calls one of the operations defined to tamper with the cursors of @i<S>.]}]}
4081
4082 @end{Itemize}
4083
4084 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4085 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
4086 @ChgDeleted{Version=[5],Type=[Leading],Text=[@Chg{Version=[2],New=[@Defn2{Term=[tamper with elements],Sec=[of a list]}
4087 A subprogram is said to @i{tamper with elements} of a set
4088 object @i<S> if:],Old=[]}]}
4089
4090
4091 @begin{Itemize}
4092
4093 @ChgRef{Version=[2],Kind=[AddedNormal]}
4094 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
4095 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[it
4096 tampers with cursors of @i<S>.]}]}
4097
4098
4099 @begin{Reason}
4100 @ChgRef{Version=[2],Kind=[AddedNormal]}
4101 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
4102 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[Complete
4103 replacement of an element can cause its
4104 memory to be deallocated while another operation is holding onto a reference
4105 to it. That can't be allowed. However, a simple modification of (part of) an
4106 element is not a problem, so Update_@!Element_@!Preserving_@!Key does not cause a
4107 problem.]}]}
4108
4109 @ChgRef{Version=[2],Kind=[AddedNormal]}
4110 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
4111 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[We
4112 don't need to list Replace and Replace_Element
4113 here because they are covered by @lquotes@;tamper with cursors@rquotes.
4114 For Set, @lquotes@;tamper with cursors@rquotes@;
4115 and @lquotes@;tamper with elements@rquotes are the same. We leave both
4116 terms so that the rules for routines like Iterate and
4117 Query_Element are consistent across all containers.]}]}
4118 @end{Reason}
4119
4120 @end{Itemize}
4121
4122 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0265-1]}
4123 @ChgRef{Version=[4],Kind=[RevisedAdded],ARef=[AI12-0110-1]}
4124 @ChgRef{Version=[5],Kind=[DeletedAddedNoDelMsg],ARef=[AI12-0111-1],ARef=[AI12-0112-1]}
4125 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[@Defn2{Term=[prohibited],Sec=[tampering with a set]}
4126 @Defn2{Term=[tampering],Sec=[prohibited for a set]}
4127 When tampering with cursors is @i<prohibited> for a particular set object
4128 @i<S>, Program_Error is propagated by a call of any language-defined subprogram
4129 that is defined to tamper with the cursors of @i<S>, leaving @i<S> unmodified.
4130 Similarly, when tampering with elements is @i<prohibited> for a particular set
4131 object @i<S>, Program_Error is propagated by a call of any language-defined
4132 subprogram that is defined to tamper with the elements of @i<S> @Redundant[(or
4133 tamper with the cursors of @i<S>)], leaving @i<S>
4134 unmodified.@Chg{Version=[4],New=[ These checks are made before any other
4135 defined behavior of the body of the language-defined subprogram.],Old=[]}]}]}
4136 @begin{TheProof}
4137 @ChgRef{Version=[3],Kind=[AddedNormal]}
4138 @ChgRef{Version=[5],Kind=[DeletedNoDelMsg]}
4139 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[Tampering
4140 with elements includes tampering with
4141 cursors, so we mention it only from completeness in the second sentence.]}]}
4142 @end{TheProof}
4143
4144 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4145 @ChgAdded{Version=[2],Text=[Empty_Set represents the empty Set object. It has a
4146 length of 0. If an object of type Set is not otherwise initialized, it is
4147 initialized to the same value as Empty_Set.]}
4148
4149 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4150 @ChgAdded{Version=[2],Text=[No_Element represents a cursor that designates no
4151 element. If an object of type Cursor is not otherwise initialized, it is
4152 initialized to the same value as No_Element.]}
4153
4154 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4155 @ChgAdded{Version=[2],Text=[The predefined "=" operator for type Cursor returns
4156 True if both cursors are No_Element, or designate the same element in the same
4157 container.]}
4158
4159 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4160 @ChgAdded{Version=[2],Text=[Execution of the default implementation of the
4161 Input, Output, Read, or Write attribute of type Cursor raises Program_Error.]}
4162
4163 @begin{Reason}
4164 @ChgRef{Version=[2],Kind=[AddedNormal]}
4165 @ChgAdded{Version=[2],Text=[A cursor will probably be implemented in terms
4166 of one or more access values, and the effects of streaming access values is
4167 unspecified. Rather than letting the user stream junk by accident, we mandate
4168 that streaming of cursors raise Program_Error by default. The attributes
4169 can always be specified if there is a need to support streaming.]}
4170 @end{Reason}
4171
4172 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]}
4173 @ChgAdded{Version=[3],Text=[Set'Write for a Set object @i<S> writes
4174 Length(@i<S>) elements of the set to the stream. It also may write
4175 additional information about the set.]}
4176
4177 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0262-1]}
4178 @ChgAdded{Version=[3],Text=[Set'Read reads the representation of a set
4179 from the stream, and assigns to @i<Item> a set with the same length and
4180 elements as was written by Set'Write.]}
4181
4182 @begin{Ramification}
4183 @ChgRef{Version=[3],Kind=[AddedNormal]}
4184 @ChgAdded{Version=[3],Text=[Streaming more elements than the container
4185 length is wrong. For implementation implications of this rule, see the Implementation Note in
4186 @RefSecNum{The Generic Package Containers.Vectors}.]}
4187 @end{Ramification}
4188
4189 @begin{DescribeCode}
4190
4191 @begin{Example}
4192 @ChgRef{Version=[3],Kind=[Added]}
4193 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
4194 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
4195 @key[with] Nonblocking, Global => (@key{in all}, @key{use null})],Old=[]};]}
4196 @end{Example}
4197
4198 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
4199 @ChgAdded{Version=[3],Type=[Trailing],Text=[Returns True if Position designates
4200 an element, and returns False otherwise.]}
4201
4202 @begin{Honest}
4203 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1],ARef=[AI05-0212-1]}
4204 @ChgAdded{Version=[3],Text=[This function might not detect cursors that
4205 designate deleted elements; such cursors are invalid (see below) and the
4206 result of calling Has_Element with an invalid cursor is unspecified (but
4207 not erroneous).]}
4208 @end{Honest}
4209
4210 @begin{Example}
4211 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
4212 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Has_Element (Container : Set; Position : Cursor)
4213 @key{return} Boolean
4214 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
4215 @end{Example}
4216
4217 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
4218 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns True if Position designates
4219 an element in Container, and returns False otherwise.]}
4220
4221 @begin{Ramification}
4222 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
4223 @ChgAdded{Version=[5],Text=[If Position is No_Element, Has_Element returns
4224 False.]}
4225 @end{Ramification}
4226
4227 @begin{Example}
4228 @ChgRef{Version=[2],Kind=[AddedNormal]}
4229 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "=" (Left, Right : Set) @key{return} Boolean;]}
4230 @end{Example}
4231
4232 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4233 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Left and Right denote the same
4234 set object, then the function returns True. If Left and Right have different
4235 lengths, then the function returns False. Otherwise, for each element @i<E> in
4236 Left, the function returns False if an element equal to @i<E> (using
4237 the generic formal equality operator) is not present in Right. If the function
4238 has not returned a result after checking all of the elements, it returns True.
4239 Any exception raised during evaluation of element equality is propagated.]}
4240 @begin{ImplNote}
4241 @ChgRef{Version=[2],Kind=[AddedNormal]}
4242 @ChgAdded{Version=[2],Text=[This wording describes the canonical semantics.
4243 However, the order and number of calls on the formal equality function is
4244 unspecified for all of the operations that use it in this package, so an
4245 implementation can call it as many or as few times as it needs to get the
4246 correct answer. Specifically, there is no requirement to call the formal
4247 equality additional times once the answer has been determined.]}
4248 @end{ImplNote}
4249
4250 @begin{Example}
4251 @ChgRef{Version=[2],Kind=[AddedNormal]}
4252 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Sets (Left, Right : Set) @key{return} Boolean;]}
4253 @end{Example}
4254
4255 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4256 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Left and Right denote the same
4257 set object, then the function returns True. If Left and Right have different
4258 lengths, then the function returns False. Otherwise, for each element @i<E> in
4259 Left, the function returns False if an element equivalent to @i<E> is not
4260 present in Right. If the function has not returned a result after checking all
4261 of the elements, it returns True. Any exception raised during evaluation of
4262 element equivalence is propagated.]}
4263
4264 @begin{Example}
4265 @ChgRef{Version=[5],Kind=[Added]}
4266 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key[function] Tampering_With_Cursors_Prohibited
4267 (Container : Set) @key{return} Boolean
4268 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
4269 @end{Example}
4270
4271 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
4272 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns True if tampering with
4273 cursors is currently prohibited for Container, and returns False otherwise.]}
4274
4275 @begin{ImplNote}
4276 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
4277 @ChgAdded{Version=[5],Text=[Various contracts elsewhere in this specification
4278 require that this function is implemented with synchronized data. Moreover,
4279 it is possible for tampering to be prohibited by multiple operations
4280 (sequentiually or in parallel). Therefore, tampering needs to be
4281 implemented with an atomic or protected counter. The counter is initialized
4282 to zero, and is incremented when tampering is prohibited, and decremented
4283 when leaving an area that prohibited tampering. Function
4284 Tampering_With_Cursors_Prohibited returns True if the counter is nonzero.
4285 (Note that any case where the result is not well-defined for one task
4286 is incorrect use of shared variables and would be erroneous by the rules
4287 of @RefSecNum{Shared Variables}, so no special protection is needed to
4288 read the counter.)]}
4289 @end{ImplNote}
4290
4291
4292 @begin{Example}
4293 @ChgRef{Version=[2],Kind=[AddedNormal]}
4294 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4295 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key[function] To_Set (New_Item : Element_Type) @key{return} Set@Chg{Version=[5],New=[
4296 @key[with] Post => Length (To_Set'Result) = 1 @key[and then]
4297 @key{not} Tampering_with_Cursors_Prohibited (To_Set'Result)],Old=[]};]}
4298 @end{Example}
4299
4300 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4301 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a set containing the single element New_Item.]}
4302
4303 @begin{Example}
4304 @ChgRef{Version=[2],Kind=[AddedNormal]}
4305 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4306 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key[function] Length (Container : Set) @key{return} Count_Type@Chg{Version=[5],New=[
4307 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
4308 @end{Example}
4309
4310 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4311 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the number of elements in
4312 Container.]}
4313
4314 @begin{Example}
4315 @ChgRef{Version=[2],Kind=[AddedNormal]}
4316 @ChgRef{Version=[5],Kind=[Revised]}
4317 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key[function] Is_Empty (Container : Set) @key{return} Boolean@Chg{Version=[5],New=[
4318 @key[with] Nonblocking, Global => (@key[null], @key[use null]),
4319 Post => Is_Empty'Result = (Length (Container) = 0)],Old=[]};]}
4320 @end{Example}
4321
4322 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4323 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4324 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[Returns True
4325 if Container is empty],Old=[Equivalent to Length (Container) = 0]}.]}
4326
4327 @begin{Example}
4328 @ChgRef{Version=[2],Kind=[AddedNormal]}
4329 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4330 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Clear (Container : @key{in out} Set)@Chg{Version=[5],New=[
4331 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
4332 @key[or else raise] Program_Error,
4333 Post => Length (Container) = 0],Old=[]};]}
4334 @end{Example}
4335
4336 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4337 @ChgAdded{Version=[2],Type=[Trailing],Text=[Removes all the elements from
4338 Container.]}
4339
4340 @begin{Example}
4341 @ChgRef{Version=[2],Kind=[AddedNormal]}
4342 @ChgRef{Version=[5],Kind=[Revised]}
4343 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Element (Position : Cursor) @key{return} Element_Type@Chg{Version=[5],New=[
4344 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
4345 Nonblocking => Element_Type'Nonblocking,
4346 Global => (@key{in all}, @key{use} Element_Type)],Old=[]};]}
4347 @end{Example}
4348
4349 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4350 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4351 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
4352 Position equals No_Element, then
4353 Constraint_Error is propagated. Otherwise, ]}Element returns the element
4354 designated by Position.]}
4355
4356 @begin{Example}
4357 @ChgRef{Version=[5],Kind=[Added]}
4358 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Element (Container : Set;
4359 Position : Cursor) @key{return} Element_Type
4360 @key{with} Pre => (Position /= No_Element
4361 @key{or else raise} Constraint_Error) @key{and then}
4362 (Has_Element (Container, Position)
4363 @key{or else raise} Program_Error),
4364 Nonblocking => Element_Type'Nonblocking,
4365 Global => (@key{null}, @key{use} Element_Type);]}
4366 @end{Example}
4367
4368 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
4369 @ChgAdded{Version=[5],Type=[Trailing],Text=[Element returns the element
4370 designated by Position.]}
4371
4372
4373 @begin{Example}
4374 @ChgRef{Version=[2],Kind=[AddedNormal]}
4375 @ChgRef{Version=[5],Kind=[Revised]}
4376 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace_Element (Container : @key{in out} Set;
4377 Position : @key{in} Cursor;
4378 New_item : @key{in} Element_Type)@Chg{Version=[5],New=[
4379 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
4380 @key{or else raise} Program_Error) @key{and then}
4381 (Position /= No_Element
4382 @key{or else raise} Constraint_Error) @key{and then}
4383 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
4384 @end{Example}
4385
4386 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4387 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1],ARef=[AI12-0196-1]}
4388 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
4389 Position equals No_Element, then
4390 Constraint_Error is propagated; if Position does not designate an element in
4391 Container, then Program_Error is propagated.
4392 If an element equivalent to New_Item is already present in Container at a
4393 position other than Position, Program_Error is propagated.
4394 Otherwise@Chg{Version=[3],New=[,],Old=[]} ]}Replace_Element
4395 assigns New_Item to the element designated by Position. Any
4396 exception raised by the assignment is
4397 propagated.@Chg{Version=[5],New=[ For the purposes of
4398 determining whether the parameters overlap in a call to Replace_Element, the
4399 Container parameter is not considered to overlap with any object
4400 @Redundant[(including itself)].],Old=[]}]}
4401
4402 @begin{ImplNote}
4403 @ChgRef{Version=[2],Kind=[AddedNormal]}
4404 @ChgAdded{Version=[2],Text=[The final assignment may require that the node of
4405 the element be moved in the Set's data structures. That could mean that
4406 implementing this operation exactly as worded above could require the
4407 overhead of searching twice. Implementations are encouraged to avoid this
4408 extra overhead when possible, by prechecking if the old element is equivalent
4409 to the new one, by inserting a placeholder node while checking for an
4410 equivalent element, and similar optimizations.]}
4411
4412 @ChgRef{Version=[2],Kind=[AddedNormal]}
4413 @ChgAdded{Version=[2],Text=[The cursor still designates the same element
4414 after this operation; only the value of that element has changed. Cursors
4415 cannot include information about the relative position of an element in a
4416 Set (as they must survive insertions and deletions of other elements), so
4417 this should not pose an implementation hardship.]}
4418 @end{ImplNote}
4419
4420 @begin{Example}
4421 @ChgRef{Version=[2],Kind=[AddedNormal]}
4422 @ChgRef{Version=[5],Kind=[Revised]}
4423 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Query_Element
4424 (Position : @key{in} Cursor;
4425 Process : @key{not null access procedure} (Element : @key{in} Element_Type))@Chg{Version=[5],New=[
4426 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
4427 Global => @key{in all}],Old=[]};]}
4428 @end{Example}
4429
4430 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4431 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0021-1],ARef=[AI05-0265-1]}
4432 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4433 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
4434 Position equals No_Element, then
4435 Constraint_Error is propagated. Otherwise, ]}Query_Element calls
4436 Process.@key{all} with the element designated by Position as the argument.
4437 @Chg{Version=[3],New=[Tampering],Old=[Program_Error
4438 is propagated if Process.@key{all} tampers]}
4439 with the elements of @Chg{Version=[3],New=[the set that contains the
4440 element designated by Position is prohibited during the
4441 execution of the call on Process.@key{all}],Old=[Container]}. Any exception
4442 raised by Process.@key{all} is propagated.]}
4443
4444 @begin{Example}
4445 @ChgRef{Version=[5],Kind=[Added]}
4446 @ChgAdded{Version=[5],Text=[@key{procedure} Query_Element
4447 (Container : @key{in} Set;
4448 Position : @key{in} Cursor;
4449 Process : @key{not null access procedure} (Element : @key{in} Element_Type))
4450 @key{with} Pre => (Position /= No_Element
4451 @key{or else raise} Constraint_Error) @key{and then}
4452 (Has_Element (Container, Position)
4453 @key{or else raise} Program_Error);]}
4454 @end{Example}
4455
4456 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
4457 @ChgAdded{Version=[5],Type=[Trailing],Text=[Query_Element calls
4458 Process.@key{all} with the key and element from the node designated by Position
4459 as the arguments. Tampering with the elements of Container is prohibited during the execution of the call on
4460 Process.@key{all}. Any exception raised by Process.@key{all} is propagated.]}
4461
4462
4463 @begin{Example}
4464 @ChgRef{Version=[3],Kind=[Added]}
4465 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
4466 @ChgAdded{Version=[3],Text=[@key[type] Constant_Reference_Type
4467 (Element : @key[not null access constant] Element_Type) @key[is private]
4468 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
4469 Nonblocking, Global => @key[in out synchronized],
4470 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
4471 @end{Example}
4472
4473 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
4474 @ChgAdded{Version=[3],Type=[Trailing],Text=[The type Constant_Reference_Type
4475 needs finalization.@PDefn2{Term=<needs finalization>,
4476 Sec=<language-defined type>}]}
4477
4478 @ChgRef{Version=[3],Kind=[Added]}
4479 @ChgRef{Version=[5],Kind=[DeletedAdded],ARef=[AI12-0112-1]}
4480 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[The default
4481 initialization of an object of type
4482 Constant_Reference_Type propagates Program_Error.]}]}
4483
4484 @begin{Reason}
4485 @ChgRef{Version=[3],Kind=[AddedNormal]}
4486 @ChgAdded{Version=[3],Text=[It is expected that
4487 Constant_Reference_Type will be a controlled type, for which finalization
4488 will have some action to terminate the tampering check for the associated
4489 container. If the object is created by default, however, there is no
4490 associated container. Since this is useless, and supporting this case would
4491 take extra work, we define it to raise an exception.]}
4492 @end{Reason}
4493
4494 @begin{Example}
4495 @ChgRef{Version=[3],Kind=[Added]}
4496 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
4497 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] Set;
4498 Position : @key[in] Cursor)
4499 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
4500 @key[with] Pre => (Position /= No_Element
4501 @key[or else raise] Constraint_Error) @key[and then]
4502 (Has_Element (Container, Position)
4503 @key[or else raise] Program_Error),
4504 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
4505 @end{Example}
4506
4507 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
4508 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
4509 Constant_Indexing and Implicit_Dereference aspects) provides a convenient way to
4510 gain read access to an individual element of a set given a cursor.]}
4511
4512 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]}
4513 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
4514 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[If
4515 Position equals No_Element, then Constraint_Error
4516 is propagated; if Position does not designate an element in Container, then
4517 Program_Error is propagated. Otherwise, ]}Constant_Reference returns an object
4518 whose discriminant is an access value that designates the element designated by
4519 Position. Tampering with the @Chg{Version=[5],New=[cursors],Old=[elements]}
4520 of Container is prohibited while the
4521 object returned by Constant_Reference exists and has not been finalized.]}
4522
4523 @begin{Example}
4524 @ChgRef{Version=[3],Kind=[Added]}
4525 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
4526 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key{procedure} Assign (Target : @key{in out} Set; Source : @key{in} Set)@Chg{Version=[5],New=[
4527 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Target)
4528 @key[or else raise] Program_Error,
4529 Post => Length (Source) = Length (Target)],Old=[]};]}
4530 @end{Example}
4531
4532 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0248-1]}
4533 @ChgAdded{Version=[3],Type=[Trailing],Text=[If Target denotes the same object as Source, the operation has no
4534 effect. Otherwise, the elements of Source are copied to Target as
4535 for an @nt{assignment_statement} assigning Source to Target.]}
4536 @begin{Discussion}
4537 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0005-1]}
4538 @ChgAdded{Version=[3],Text=[This routine exists for compatibility with the
4539 bounded set containers. For an unbounded set, @exam{Assign(A, B)} and
4540 @exam{A := B} behave identically. For a bounded set, := will raise an
4541 exception if the container capacities are different, while Assign will
4542 not raise an exception if there is enough room in the target.]}
4543 @end{Discussion}
4544
4545 @begin{Example}
4546 @ChgRef{Version=[2],Kind=[AddedNormal]}
4547 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4548 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Move (Target : @key{in out} Set;
4549 Source : @key{in out} Set)@Chg{Version=[5],New=[
4550 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
4551 @key{or else raise} Program_Error) @key{and then}
4552 (@key{not} Tampering_With_Cursors_Prohibited (Source)
4553 @key{or else raise} Program_Error),
4554 Post => (@key{if} Target = Source @key{then} True
4555 @key{else}
4556 Length (Target) = Length (Source'Old) @key{and then}
4557 Length (Source) = 0)],Old=[]};]}
4558 @end{Example}
4559
4560 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4561 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0262-1]}
4562 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Target denotes the same object
4563 as Source, then @Chg{Version=[3],New=[the operation],Old=[Move]}
4564 has no effect. Otherwise, @Chg{Version=[3],New=[the operation is equivalent
4565 to Assign (Target, Source) followed by Clear (Source)],Old=[Move first clears
4566 Target. Then, each element from Source is removed from Source and inserted into
4567 Target. The length of Source is 0 after a successful call to Move]}.]}
4568
4569 @begin{Example}
4570 @ChgRef{Version=[2],Kind=[AddedNormal]}
4571 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4572 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Set;
4573 New_Item : @key{in} Element_Type;
4574 Position : @key{out} Cursor;
4575 Inserted : @key{out} Boolean)@Chg{Version=[5],New=[
4576 @key{with} Pre => (@key{not} Tampering_With_Elements_Prohibited (Container)
4577 @key{or else raise} Program_Error) @key{and then}
4578 (Length (Container) <= Count_Type'Last - 1
4579 @key{or else raise} Constraint_Error),
4580 Post => (@key{declare}
4581 Original_Length : @key{constant} Count_Type :=
4582 Length (Container)'Old;
4583 @key{begin}
4584 Has_Element (Container, Position) @key{and then}
4585 (@key{if} Inserted then
4586 Length (Container) = Original_Length + 1
4587 @key{else}
4588 Length (Container) = Original_Length))],Old=[]};]}
4589 @end{Example}
4590
4591 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4592 @ChgAdded{Version=[2],Type=[Trailing],Text=[Insert checks if an element
4593 equivalent to New_Item is already present in Container. If a match is found,
4594 Inserted is set to False and Position designates the matching element.
4595 Otherwise, Insert adds New_Item to Container; Inserted is set to True and
4596 Position designates the newly-inserted element. Any exception raised during
4597 allocation is propagated and Container is not modified.]}
4598
4599 @begin{Example}
4600 @ChgRef{Version=[2],Kind=[AddedNormal]}
4601 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4602 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Set;
4603 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
4604 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
4605 @key{or else raise} Program_Error) @key{and then}
4606 (Length (Container) <= Count_Type'Last - 1
4607 @key{or else raise} Constraint_Error),
4608 Post => Length (Container) = Length (Container)'Old + 1],Old=[]};]}
4609 @end{Example}
4610
4611 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4612 @ChgAdded{Version=[2],Type=[Trailing],Text=[Insert inserts New_Item into
4613 Container as per the four-parameter Insert, with the difference that if an
4614 element equivalent to New_Item is already in the set, then Constraint_Error is
4615 propagated.]}
4616
4617 @begin{Discussion}
4618 @ChgRef{Version=[2],Kind=[AddedNormal]}
4619 @ChgAdded{Version=[2],Type=[Leading],Text=[This is equivalent to:]}
4620 @begin{Example}
4621 @ChgRef{Version=[2],Kind=[AddedNormal]}
4622 @ChgAdded{Version=[2],Text=[@key{declare}
4623 Inserted : Boolean; C : Cursor;
4624 @key{begin}
4625 Insert (Container, New_Item, C, Inserted);
4626 @key{if not} Inserted @key{then}
4627 @key{raise} Constraint_Error;
4628 @key{end if};
4629 @key{end};]}
4630 @end{Example}
4631 @ChgRef{Version=[2],Kind=[AddedNormal]}
4632 @ChgAdded{Version=[2],Text=[but doesn't require the hassle of @key{out}
4633 parameters.]}
4634 @end{Discussion}
4635
4636 @begin{Example}
4637 @ChgRef{Version=[2],Kind=[AddedNormal]}
4638 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4639 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Include (Container : @key{in out} Set;
4640 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
4641 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
4642 @key{or else raise} Program_Error) @key{and then}
4643 (Length (Container) <= Count_Type'Last - 1
4644 @key{or else raise} Constraint_Error),
4645 Post => (@key{declare}
4646 Original_Length : @key{constant} Count_Type :=
4647 Length (Container)'Old;
4648 @key{begin}
4649 Length (Container)
4650 @key{in} Original_Length | Original_Length + 1)],Old=[]};]}
4651 @end{Example}
4652
4653 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4654 @ChgAdded{Version=[2],Type=[Trailing],Text=[Include inserts New_Item into
4655 Container as per the four-parameter Insert, with the difference that if an
4656 element equivalent to New_Item is already in the set, then it is replaced. Any
4657 exception raised during assignment is propagated.]}
4658
4659 @begin{Example}
4660 @ChgRef{Version=[2],Kind=[AddedNormal]}
4661 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4662 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace (Container : @key{in out} Set;
4663 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
4664 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
4665 @key{or else raise} Program_Error,
4666 Post => Length (Container) = Length (Container)'Old],Old=[]};]}
4667 @end{Example}
4668
4669 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4670 @ChgAdded{Version=[2],Type=[Trailing],Text=[Replace checks if an element
4671 equivalent to New_Item is already in the set. If a match is found, that element
4672 is replaced with New_Item; otherwise, Constraint_Error is propagated.]}
4673
4674 @begin{Example}
4675 @ChgRef{Version=[2],Kind=[AddedNormal]}
4676 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4677 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Exclude (Container : @key{in out} Set;
4678 Item : @key{in} Element_Type)@Chg{Version=[5],New=[
4679 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
4680 @key{or else raise} Program_Error,
4681 Post => (@key{declare}
4682 Original_Length : @key{constant} Count_Type :=
4683 Length (Container)'Old;
4684 @key{begin}
4685 Length (Container) @key{in}
4686 Original_Length - 1 | Original_Length)],Old=[]};]}
4687 @end{Example}
4688
4689 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4690 @ChgAdded{Version=[2],Type=[Trailing],Text=[Exclude checks if an element
4691 equivalent to Item is present in Container. If a match is found, Exclude
4692 removes the element from the set.]}
4693
4694 @begin{Example}
4695 @ChgRef{Version=[2],Kind=[AddedNormal]}
4696 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4697 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Set;
4698 Item : @key{in} Element_Type)@Chg{Version=[5],New=[
4699 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
4700 @key{or else raise} Program_Error,
4701 Post => Length (Container) = Length (Container)'Old - 1],Old=[]};]}
4702 @end{Example}
4703
4704 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4705 @ChgAdded{Version=[2],Type=[Trailing],Text=[Delete checks if an element
4706 equivalent to Item is present in Container. If a match is found, Delete removes
4707 the element from the set; otherwise, Constraint_Error is propagated.]}
4708
4709 @begin{Example}
4710 @ChgRef{Version=[2],Kind=[AddedNormal]}
4711 @ChgRef{Version=[5],Kind=[Revised]}
4712 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete (Container : @key{in out} Set;
4713 Position : @key{in out} Cursor)@Chg{Version=[5],New=[
4714 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
4715 @key{or else raise} Program_Error) @key{and then}
4716 (Position /= No_Element
4717 @key{or else raise} Constraint_Error) @key{and then}
4718 (Has_Element (Container, Position)
4719 @key{or else raise} Program_Error),
4720 Post => Length (Container) = Length (Container)'Old - 1 @key{and then}
4721 Position = No_Element],Old=[]};]}
4722 @end{Example}
4723
4724 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4725 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4726 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
4727 Position equals No_Element,
4728 then Constraint_Error is propagated. If Position does not designate an element
4729 in Container, then Program_Error is propagated. Otherwise, ]}Delete removes the
4730 element designated by Position from the set.@Chg{Version=[5],New=[],Old=[
4731 Position is set to No_Element on return.]}]}
4732
4733 @begin{Ramification}
4734 @ChgRef{Version=[2],Kind=[AddedNormal]}
4735 @ChgAdded{Version=[2],Text=[The check on Position checks that the cursor does
4736 not belong to some other set. This check implies that a reference to the set
4737 is included in the cursor value. This wording is not meant to require
4738 detection of dangling cursors; such cursors are defined to be invalid, which
4739 means that execution is erroneous, and any result is allowed (including not
4740 raising an exception).]}
4741 @end{Ramification}
4742
4743 @begin{Example}
4744 @ChgRef{Version=[2],Kind=[AddedNormal]}
4745 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4746 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Union (Target : @key{in out} Set;
4747 Source : @key{in} Set)@Chg{Version=[5],New=[
4748 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Target)
4749 @key{or else raise} Program_Error,
4750 Post => Length (Target) <= Length (Target)'Old + Length (Source)],Old=[]};]}
4751 @end{Example}
4752
4753 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4754 @ChgAdded{Version=[2],Type=[Trailing],Text=[Union inserts into Target the
4755 elements of Source that are not equivalent to some element already in Target.]}
4756
4757 @begin{ImplNote}
4758 @ChgRef{Version=[2],Kind=[AddedNormal]}
4759 @ChgAdded{Version=[2],Text=[If the objects are the same, the result is the
4760 same as the original object. The implementation needs to take care so that
4761 aliasing effects do not make the result trash; Union (S, S); must work.]}
4762 @end{ImplNote}
4763
4764
4765 @begin{Example}
4766 @ChgRef{Version=[2],Kind=[AddedNormal]}
4767 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4768 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Union (Left, Right : Set) @key{return} Set@Chg{Version=[5],New=[
4769 @key{with} Post => Length (Union'Result) <= Length (Left) + Length (Right) @key{and then}
4770 @key{not} Tampering_With_Cursors_Prohibited (Union'Result)],Old=[]};]}
4771 @end{Example}
4772
4773 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4774 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a set comprising all of the
4775 elements of Left, and the elements of Right that are not equivalent to some
4776 element of Left.]}
4777
4778 @begin{Example}
4779 @ChgRef{Version=[2],Kind=[AddedNormal]}
4780 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4781 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Intersection (Target : @key{in out} Set;
4782 Source : @key{in} Set)@Chg{Version=[5],New=[
4783 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Target)
4784 @key{or else raise} Program_Error,
4785 Post => Length (Target) <= Length (Target)'Old + Length (Source)],Old=[]};]}
4786 @end{Example}
4787
4788 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4789 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0004-1]}
4790 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[Intersection],Old=[Union]} deletes from Target the
4791 elements of Target that are not equivalent to some element of Source.]}
4792
4793 @begin{ImplNote}
4794 @ChgRef{Version=[2],Kind=[AddedNormal]}
4795 @ChgAdded{Version=[2],Text=[If the objects are the same, the result is the
4796 same as the original object. The implementation needs to take care so that
4797 aliasing effects do not make the result trash; Intersection (S, S); must
4798 work.]}
4799 @end{ImplNote}
4800
4801 @begin{Example}
4802 @ChgRef{Version=[2],Kind=[AddedNormal]}
4803 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4804 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Intersection (Left, Right : Set) @key{return} Set@Chg{Version=[5],New=[
4805 @key{with} Post => Length (Intersection'Result) <= Length (Left) + Length (Right) @key{and then}
4806 @key{not} Tampering_With_Cursors_Prohibited (Intersection'Result)],Old=[]};]}
4807 @end{Example}
4808
4809 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4810 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a set comprising all the
4811 elements of Left that are equivalent to the some element of Right.]}
4812
4813 @begin{Example}
4814 @ChgRef{Version=[2],Kind=[AddedNormal]}
4815 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4816 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Difference (Target : @key{in out} Set;
4817 Source : @key{in} Set)@Chg{Version=[5],New=[
4818 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Target)
4819 @key{or else raise} Program_Error,
4820 Post => Length (Target) <= Length (Target)'Old + Length (Source)],Old=[]};]}
4821 @end{Example}
4822
4823 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4824 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Target denotes the same object
4825 as Source, then Difference clears Target. Otherwise, it deletes from Target the
4826 elements that are equivalent to some element of Source.]}
4827
4828 @begin{Example}
4829 @ChgRef{Version=[2],Kind=[AddedNormal]}
4830 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4831 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Difference (Left, Right : Set) @key{return} Set@Chg{Version=[5],New=[
4832 @key{with} Post => Length (Difference'Result) <= Length (Left) + Length (Right) @key{and then}
4833 @key{not} Tampering_With_Cursors_Prohibited (Difference'Result)],Old=[]};]}
4834 @end{Example}
4835
4836 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4837 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a set comprising the
4838 elements of Left that are not equivalent to some element of Right.]}
4839
4840 @begin{Example}
4841 @ChgRef{Version=[2],Kind=[AddedNormal]}
4842 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4843 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Symmetric_Difference (Target : @key{in out} Set;
4844 Source : @key{in} Set)@Chg{Version=[5],New=[
4845 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Target)
4846 @key{or else raise} Program_Error,
4847 Post => Length (Target) <= Length (Target)'Old + Length (Source)],Old=[]};]}
4848 @end{Example}
4849
4850 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4851 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Target denotes the same object
4852 as Source, then Symmetric_Difference clears Target. Otherwise, it deletes from
4853 Target the elements that are equivalent to some element of Source, and inserts
4854 into Target the elements of Source that are not equivalent to some element of
4855 Target.]}
4856
4857 @begin{Example}
4858 @ChgRef{Version=[2],Kind=[AddedNormal]}
4859 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4860 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Symmetric_Difference (Left, Right : Set) @key{return} Set@Chg{Version=[5],New=[
4861 @key{with} Post => Length (Symmetric_Difference'Result) <= Length (Left) + Length (Right) @key{and then}
4862 @key{not} Tampering_With_Cursors_Prohibited (Symmetric_Difference'Result)],Old=[]};]}
4863 @end{Example}
4864
4865 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4866 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a set comprising the
4867 elements of Left that are not equivalent to some element of Right, and the
4868 elements of Right that are not equivalent to some element of Left.]}
4869
4870 @begin{Example}
4871 @ChgRef{Version=[2],Kind=[AddedNormal]}
4872 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Overlap (Left, Right : Set) @key{return} Boolean;]}
4873 @end{Example}
4874
4875 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4876 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
4877 @ChgAdded{Version=[2],Type=[Trailing],Text=[If an element of Left is equivalent
4878 to some element of Right, then Overlap returns True.
4879 Otherwise@Chg{Version=[3],New=[,],Old=[]} it returns False.]}
4880
4881 @begin{Discussion}
4882 @ChgRef{Version=[2],Kind=[AddedNormal]}
4883 @ChgAdded{Version=[2],Text=[This operation is commutative. If Overlap returns
4884 False, the two sets are disjoint.]}
4885 @end{Discussion}
4886
4887 @begin{Example}
4888 @ChgRef{Version=[2],Kind=[AddedNormal]}
4889 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Is_Subset (Subset : Set;
4890 Of_Set : Set) @key{return} Boolean;]}
4891 @end{Example}
4892
4893 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4894 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
4895 @ChgAdded{Version=[2],Type=[Trailing],Text=[If an element of Subset is not
4896 equivalent to some element of Of_Set, then Is_Subset returns False.
4897 Otherwise@Chg{Version=[3],New=[,],Old=[]} it returns True.]}
4898
4899 @begin{Discussion}
4900 @ChgRef{Version=[2],Kind=[AddedNormal]}
4901 @ChgAdded{Version=[2],Text=[This operation is not commutative, so we use
4902 parameter names that make it clear in named notation which set is which.]}
4903 @end{Discussion}
4904
4905 @begin{Example}
4906 @ChgRef{Version=[2],Kind=[AddedNormal]}
4907 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4908 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First (Container : Set) @key{return} Cursor@Chg{Version=[5],New=[
4909 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
4910 Post => (@key{if not} Is_Empty (Container)
4911 @key{then} Has_Element (Container, First'Result)
4912 @key{else} First'Result = No_Element)],Old=[]};]}
4913 @end{Example}
4914
4915 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4916 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Length (Container) = 0, then
4917 First returns No_Element. Otherwise, First returns a cursor that designates the
4918 first element in Container.]}
4919
4920 @begin{Example}
4921 @ChgRef{Version=[2],Kind=[AddedNormal]}
4922 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4923 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Next (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
4924 @key{with} Nonblocking, Global => (@key{in all}, @key{use null}),
4925 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
4926 @key{else} True)],Old=[]};]}
4927 @end{Example}
4928
4929 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4930 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a cursor that designates the successor of the element
4931 designated by Position. If Position designates the last element, then
4932 No_Element is returned. If Position equals No_Element, then No_Element is
4933 returned.]}
4934
4935 @begin{Example}
4936 @ChgRef{Version=[5],Kind=[Added]}
4937 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Next (Container : Set;
4938 Position : Cursor) @key{return} Cursor
4939 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
4940 Pre => Position = No_Element @key{or else}
4941 Has_Element (Container, Position)
4942 @key{or else raise} Program_Error,
4943 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
4944 @key{elsif} Next'Result = No_Element @key{then}
4945 Position = Last (Container)
4946 @key{else} Has_Element (Container, Next'Result));]}
4947 @end{Example}
4948
4949 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
4950 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns a cursor designating the
4951 successor of the node designated by Position in Container.]}
4952
4953 @begin{Example}
4954 @ChgRef{Version=[2],Kind=[AddedNormal]}
4955 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4956 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Next (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
4957 @key{with} Nonblocking, Global => (@key{in all}, @key{use null})],Old=[]};]}
4958 @end{Example}
4959
4960 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4961 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Next (Position).]}
4962
4963 @begin{Example}
4964 @ChgRef{Version=[5],Kind=[Added]}
4965 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{procedure} Next (Container : @key{in} Set;
4966 Position : @key{in out} Cursor)
4967 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
4968 Pre => Position = No_Element @key{or else}
4969 Has_Element (Container, Position)
4970 @key{or else raise} Program_Error,
4971 Post => (@key{if} Position /= No_Element
4972 @key{then} Has_Element (Container, Position));]}
4973 @end{Example}
4974
4975 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
4976 @ChgAdded{Version=[5],Type=[Trailing],Text=[Equivalent to Position := Next
4977 (Container, Position).]}
4978
4979 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4980 @ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0004-1]}
4981 @ChgDeleted{Version=[3],Type=[Trailing],Text=[@Chg{Version=[2],New=[Equivalent to Find (Container, Item) /= No_Element.],Old=[]}]}
4982
4983 @begin{Example}
4984 @ChgRef{Version=[2],Kind=[AddedNormal]}
4985 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
4986 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Find (Container : Set;
4987 Item : Element_Type) @key{return} Cursor@Chg{Version=[5],New=[
4988 @key{with} Post => (@key{if} Find'Result = No_Element @key{then} True
4989 @key{else} Has_Element (Container, Find'Result))],Old=[]};]}
4990 @end{Example}
4991
4992
4993 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
4994 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Length (Container) equals 0,
4995 then Find returns No_Element. Otherwise, Find checks if an element equivalent
4996 to Item is present in Container. If a match is found, a cursor designating the
4997 matching element is returned; otherwise, No_Element is returned.]}
4998
4999 @begin{Example}
5000 @ChgRef{Version=[2],Kind=[AddedNormal]}
5001 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Contains (Container : Set;
5002 Item : Element_Type) @key{return} Boolean;]}
5003 @end{Example}
5004
5005 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0004-1]}
5006 @ChgAdded{Version=[3],Type=[Trailing],Text=[Equivalent to Find (Container, Item) /= No_Element.]}
5007
5008 @begin{Example}
5009 @ChgRef{Version=[2],Kind=[AddedNormal]}
5010 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg]}
5011 @ChgAdded{Version=[2],KeepNext=[T],Text=[@Chg{Version=[3],New=[],Old=[@key{function} Has_Element (Position : Cursor) @key{return} Boolean;]}]}
5012 @end{Example}
5013
5014 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5015 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]}
5016 @ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[],Old=[Returns True if Position designates
5017 an element, and returns False otherwise.]}]}
5018
5019 @begin{Honest}
5020 @ChgRef{Version=[2],Kind=[AddedNormal]}
5021 @ChgRef{Version=[3],Kind=[DeletedNoDelMsg],ARef=[AI05-0212-1]}
5022 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[This function may not detect cursors that
5023 designate deleted elements; such cursors are invalid (see below) and the
5024 result of calling Has_Element with an invalid cursor is unspecified (but
5025 not erroneous).]}]}
5026 @end{Honest}
5027 @begin{NotIso}
5028 @ChgAdded{Version=[3],Noparanum=[T],Text=[@Shrink{@i<Paragraphs 83 and 84
5029 were moved above.>}]}@Comment{This message should be
5030 deleted if the paragraphs are ever renumbered.}
5031 @end{NotIso}
5032
5033 @begin{Example}
5034 @ChgRef{Version=[2],Kind=[AddedNormal]}
5035 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5036 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Iterate
5037 (Container : @key{in} Set;
5038 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
5039 @key{with} Allows_Exit],Old=[]};]}
5040 @end{Example}
5041
5042 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5043 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]}
5044 @ChgAdded{Version=[2],Type=[Trailing],Text=[Iterate calls Process.@key{all}
5045 with a cursor that designates each element in Container, starting with the
5046 first element and moving the cursor according to the successor relation.
5047 @Chg{Version=[3],New=[Tampering],Old=[Program_Error
5048 is propagated if Process.@key{all} tampers]}
5049 with the cursors of Container@Chg{Version=[3],New=[ is prohibited during the
5050 execution of a call on Process.@key{all}],Old=[]}. Any exception raised by
5051 Process.@key{all} is propagated.]}
5052
5053 @begin{ImplNote}
5054 @ChgRef{Version=[2],Kind=[AddedNormal]}
5055 @ChgAdded{Version=[2],Text=[The @lquotes@;tamper with cursors@rquotes@;
5056 check takes place when the operations that insert or delete elements, and
5057 so on are called.]}
5058
5059 @ChgRef{Version=[2],Kind=[AddedNormal]}
5060 @ChgAdded{Version=[2],Text=[See Iterate for vectors
5061 (@RefSecNum{The Generic Package Containers.Vectors}) for a suggested
5062 implementation of the check.]}
5063 @end{ImplNote}
5064
5065 @end{DescribeCode}
5066
5067 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5068 @ChgAdded{Version=[2],Text=[Both Containers.Hashed_Set and
5069 Containers.Ordered_Set declare a nested generic package Generic_Keys, which
5070 provides operations that allow set manipulation in terms of a key (typically, a
5071 portion of an element) instead of a complete element. The formal function Key
5072 of Generic_Keys extracts a key value from an element. It is expected to return
5073 the same value each time it is called with a particular element. The behavior
5074 of Generic_Keys is unspecified if Key behaves in some other
5075 manner.@PDefn{unspecified}]}
5076
5077 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5078 @ChgAdded{Version=[2],Text=[A key is expected to unambiguously determine a
5079 single equivalence class for elements. The behavior of Generic_Keys is
5080 unspecified if the formal parameters of this package behave in some other
5081 manner.@PDefn{unspecified}]}
5082
5083 @begin{DescribeCode}
5084 @begin{Example}
5085 @ChgRef{Version=[2],Kind=[AddedNormal]}
5086 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5087 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Key (Position : Cursor) @key{return} Key_Type@Chg{Version=[5],New=[
5088 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
5089 Global => @key{in all}],Old=[]};]}
5090 @end{Example}
5091
5092 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5093 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Key (Element (Position)).]}
5094
5095 @begin{Example}
5096 @ChgRef{Version=[5],Kind=[Added]}
5097 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Key (Container : Set;
5098 Position : Cursor) @key{return} Key_Type
5099 @key{with} Pre => (Position /= No_Element
5100 @key{or else raise} Constraint_Error) @key{and then}
5101 (Has_Element (Container, Position)
5102 @key{or else raise} Program_Error);]}
5103 @end{Example}
5104
5105 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5106 @ChgAdded{Version=[5],Type=[Trailing],Text=[Equivalent to
5107 Key (Element (Container, Position)).]}
5108
5109 @end{DescribeCode}
5110
5111 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5112 @ChgAdded{Version=[2],Text=[The subprograms in package Generic_Keys named
5113 Contains, Find, Element, Delete, and Exclude, are equivalent to the
5114 corresponding subprograms in the parent package, with the difference that the
5115 Key parameter is used to locate an element in the set.]}
5116
5117 @begin{DescribeCode}
5118 @begin{Example}
5119 @ChgRef{Version=[2],Kind=[AddedNormal]}
5120 @ChgRef{Version=[2],Kind=[AddedNormal]}
5121 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5122 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Replace (Container : @key{in out} Set;
5123 Key : @key{in} Key_Type;
5124 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
5125 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
5126 @key{or else raise} Program_Error,
5127 Post => Length (Container) = Length (Container)'Old],Old=[]};]}
5128 @end{Example}
5129
5130 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5131 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Replace_Element (Container, Find (Container, Key), New_Item).]}
5132
5133 @begin{Example}
5134 @ChgRef{Version=[2],Kind=[AddedNormal]}
5135 @ChgRef{Version=[5],Kind=[Revised]}
5136 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Update_Element_Preserving_Key
5137 (Container : @key{in out} Set;
5138 Position : @key{in} Cursor;
5139 Process : @key{not null access procedure}
5140 (Element : @key{in out} Element_Type))@Chg{Version=[5],New=[
5141 @key{with} Pre => (Position /= No_Element
5142 @key{or else raise} Constraint_Error) @key{and then}
5143 (Has_Element (Container, Position)
5144 @key{or else raise} Program_Error)],Old=[]};]}
5145 @end{Example}
5146
5147 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5148 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0265-1]}
5149 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5150 @ChgAdded{Version=[2],Text=[@Chg{Version=[5],New=[],Old=[If
5151 Position equals No_Element, then
5152 Constraint_Error is propagated; if Position does not designate an element in
5153 Container, then Program_Error is propagated. Otherwise,
5154 ]}Update_@!Element_@!Preserving_Key uses Key to save the key value @i<K> of the
5155 element designated by Position. Update_@!Element_@!Preserving_Key then calls
5156 Process.@key{all} with that element as the argument.
5157 @Chg{Version=[3],New=[Tampering],Old=[Program_Error
5158 is propagated if Process.@key{all} tampers]}
5159 with the @Chg{Version=[5],New=[cursors],Old=[elements]}
5160 of Container@Chg{Version=[3],New=[ is prohibited during the
5161 execution of the call on Process.@key{all}],Old=[]}. Any
5162 exception raised by Process.@key{all} is propagated. After Process.@key{all}
5163 returns, Update_@!Element_@!Preserving_Key checks if @i<K> determines the same
5164 equivalence class as that for the new element; if not, the element is removed
5165 from the set and Program_Error is propagated.]}
5166
5167 @begin{Reason}
5168 @ChgRef{Version=[2],Kind=[AddedNormal]}
5169 @ChgAdded{Version=[2],Text=[The key check ensures that the invariants of
5170 the set are preserved by the modification. The @lquotes@;tampers with
5171 the elements@rquotes@; check prevents data loss (if Element_Type is by-copy)
5172 or erroneous execution (if element type is unconstrained and indefinite).]}
5173 @end{Reason}
5174
5175 @ChgRef{Version=[2],Kind=[AddedNormal]}
5176 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Element_Type is unconstrained
5177 and definite, then the actual Element parameter of Process.@key{all} shall be
5178 unconstrained.]}
5179
5180 @begin{Ramification}
5181 @ChgRef{Version=[2],Kind=[AddedNormal]}
5182 @ChgAdded{Version=[2],Text=[This means that the elements cannot be
5183 directly allocated from the heap; it must be possible to change the
5184 discriminants of the element in place.]}
5185 @end{Ramification}
5186
5187 @begin{Example}
5188 @ChgRef{Version=[3],Kind=[Added]}
5189 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5190 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[type] Reference_Type (Element : @key[not null access] Element_Type) @key[is private]
5191 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
5192 Nonblocking, Global => @key[in out synchronized],
5193 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
5194 @end{Example}
5195
5196 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
5197 @ChgAdded{Version=[3],Type=[Trailing],Text=[The type Reference_Type needs
5198 finalization.@PDefn2{Term=<needs finalization>,
5199 Sec=<language-defined type>}]}
5200
5201 @ChgRef{Version=[3],Kind=[Added]}
5202 @ChgRef{Version=[5],Kind=[DeletedAdded],ARef=[AI12-0112-1]}
5203 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[The default
5204 initialization of an object of type
5205 Reference_Type propagates Program_Error.]}]}
5206
5207 @begin{Example}
5208 @ChgRef{Version=[3],Kind=[Added]}
5209 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5210 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference_Preserving_Key (Container : @key[aliased in out] Set;
5211 Position : @key[in] Cursor)
5212 @key[return] Reference_Type@Chg{Version=[5],New=[
5213 @key[with] Pre => (Position /= No_Element
5214 @key[or else raise] Constraint_Error) @key[and then]
5215 (Has_Element (Container, Position)
5216 @key[or else raise] Program_Error),
5217 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
5218 @end{Example}
5219
5220 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
5221 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
5222 Implicit_Dereference aspect) provides a convenient way to
5223 gain read and write access to an individual element of a set given a cursor.]}
5224
5225 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1]}
5226 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5227 @ChgAdded{Version=[3],Text=[@Chg{Version=[5],New=[],Old=[If
5228 Position equals No_Element, then Constraint_Error
5229 is propagated; if Position does not designate an element in Container, then
5230 Program_Error is propagated. Otherwise, ]}Reference_Preserving_Key uses Key to
5231 save the key value @i<K>; then returns an object whose discriminant is an access
5232 value that designates the element designated by
5233 Position. Tampering with the @Chg{Version=[5],New=[cursors],Old=[elements]}
5234 of Container is prohibited while the
5235 object returned by Reference_Preserving_Key exists and has not been finalized.
5236 When the object returned by Reference_Preserving_Key is finalized, a check is
5237 made if @i<K> determines the same equivalence class as that for the new element;
5238 if not, the element is removed from the set and Program_Error is propagated.]}
5239
5240 @begin{Example}
5241 @ChgRef{Version=[3],Kind=[Added]}
5242 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5243 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Constant_Reference (Container : @key[aliased in] Set;
5244 Key : @key[in] Key_Type)
5245 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
5246 @key[with] Pre => Find (Container, Key) /= No_Element @key[or else raise] Constraint_Error,
5247 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
5248 @end{Example}
5249
5250 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
5251 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
5252 Implicit_Dereference aspect) provides a convenient way to
5253 gain read access to an individual element of a set given a key value.]}
5254
5255 @ChgRef{Version=[3],Kind=[Added]}
5256 @ChgAdded{Version=[3],Text=[Equivalent to
5257 Constant_Reference (Container, Find (Container, Key)).]}
5258
5259 @begin{Example}
5260 @ChgRef{Version=[3],Kind=[Added]}
5261 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5262 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Reference_Preserving_Key (Container : @key[aliased in out] Set;
5263 Key : @key[in] Key_Type)
5264 @key[return] Reference_Type@Chg{Version=[5],New=[
5265 @key[with] Pre => Find (Container, Key) /= No_Element @key[or else raise] Constraint_Error,
5266 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
5267 @end{Example}
5268
5269 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0269-1]}
5270 @ChgAdded{Version=[3],Type=[Trailing],Text=[This function (combined with the
5271 Implicit_Dereference aspect) provides a convenient way to gain
5272 read and write access to an individual element of a set given a key value.]}
5273
5274 @ChgRef{Version=[3],Kind=[Added]}
5275 @ChgAdded{Version=[3],Text=[Equivalent to Reference_Preserving_Key (Container, Find (Container, Key)).]}
5276 @end{DescribeCode}
5277
5278
5279 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
5280 @ChgAdded{Version=[5],Text=[The nested package Stable
5281 provides a type Stable.Set that represents
5282 a @i<stable> set,@Defn2{Term=(stable),Sec=(set)} which is one that
5283 cannot grow and shrink. Such a list can be created by calling the
5284 Copy function, or by establishing a
5285 @i<stabilized view> of a regular set.@Defn2{Term=[stabilized view],Sec=[set]}]}
5286
5287 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
5288 @ChgAdded{Version=[5],Type=[Leading],Text=[The subprograms of the set package
5289 that have a parameter or result of type Set
5290 are included in the nested package Stable with the same specification, except
5291 that the following are omitted:]}
5292
5293 @begin{Indent}
5294 @ChgRef{Version=[5],Kind=[Added]}
5295 @ChgAdded{Version=[5],Text=[Tampering_With_Cursors_Prohibited,
5296 Assign, Move, Insert, Include, Clear, Delete, Exclude, Replace, Replace_Element,
5297 procedures Union, Intersection, Difference, and Symmetric_Difference,
5298 (for Ordered_sets) Delete_First and
5299 Delete_Last, and (for Hashed_sets) Reserve_Capacity]}
5300 @end{Indent}
5301
5302 @begin{Discussion}
5303 @ChgRef{Version=[5],Kind=[Added]}
5304 @ChgAdded{Version=[5],Text=[The Generic_Keys package is not included in the
5305 Stable package. The functions Union, Intersection, Difference, and
5306 Symmetric_Difference are included in the Stable package.]}
5307 @end{Discussion}
5308 @begin{Ramification}
5309 @ChgRef{Version=[5],Kind=[Added]}
5310 @ChgAdded{Version=[5],Text=[The names Set and Cursor mean the types
5311 declared in the nested package in these subprogram specifications.]}
5312 @end{Ramification}
5313 @begin{Reason}
5314 @ChgRef{Version=[5],Kind=[Added]}
5315 @ChgAdded{Version=[5],Text=[The omitted routines are those that tamper with
5316 cursors (or test that state). The model is that it is
5317 impossible to tamper with cursors of a stable view since no
5318 such operations are included. Thus tampering checks are not needed for
5319 a stable view, and we omit the operations associated with those checks.]}
5320 @end{Reason}
5321
5322 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
5323 @ChgAdded{Version=[5],Text=[The operations of this package are equivalent
5324 to those for regular sets, except that the calls to
5325 Tampering_With_Cursors_Prohibited that occur in preconditions are replaced
5326 by False, and any that occur in postconditions are replaced by True.]}
5327
5328 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
5329 @ChgAdded{Version=[5],Text=[If a stable set is declared with the Base
5330 discriminant designating a pre-existing regular set, the stable set
5331 represents a stabilized view of the underlying regular set, and any operation
5332 on the stable set is reflected on the underlying regular set. While a
5333 stabilized view exists, any operation that tampers with cursors performed on
5334 the underlying set is prohibited. The finalization of a stable set that
5335 provides such a view removes this restriction on the underlying regular set
5336 @Redundant[(though some other restriction might exist due to other concurrent
5337 iterations or stabilized views)].]}
5338
5339 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0111-1]}
5340 @ChgAdded{Version=[5],Text=[If a stable set is declared without specifying
5341 Base, the object must be initialized. The initializing expression of the stable
5342 set, @Redundant[typically a call on Copy], determines the Length
5343 of the set. The Length of a stable set never changes after
5344 initialization.]}
5345
5346 @end{StaticSem}
5347
5348 @begin{Bounded}
5349 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0022-1],ARef=[AI05-0248-1]}
5350 @ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}
5351 It is a bounded error for the actual function
5352 associated with a generic formal subprogram, when called as part of an
5353 operation of a set package, to tamper with elements of any set parameter of
5354 the operation. Either Program_Error is raised, or the operation works as
5355 defined on the value of the set either prior to, or subsequent to, some or
5356 all of the modifications to the set.@Defn2{Term=[Program_Error],Sec=(raised by detection of a bounded error)}]}
5357
5358 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0027-1]}
5359 @ChgAdded{Version=[3],Text=[@PDefn2{Term=(bounded error),Sec=(cause)}
5360 It is a bounded error to call any subprogram
5361 declared in the visible part of a set package
5362 when the associated container has been finalized. If the operation takes
5363 Container as an @key[in out] parameter, then it raises Constraint_Error or
5364 Program_Error. Otherwise, the operation either proceeds as it would
5365 for an empty container, or it raises
5366 Constraint_Error or@Defn2{Term=[Constraint_Error],Sec=(raised by detection of a bounded error)}
5367 Program_Error.@Defn2{Term=[Program_Error],Sec=(raised by detection of a bounded error)}]}
5368 @end{Bounded}
5369
5370 @begin{Erron}
5371 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5372 @ChgAdded{Version=[2],Type=[Leading],Text=[
5373 A Cursor value is @i<invalid> if any of the following have occurred since it was
5374 created:@Defn2{Term=[invalid cursor],Sec=[of a set]}
5375 @PDefn2{Term=[cursor],Sec=[invalid]}]}
5376
5377 @begin{Itemize}
5378
5379 @ChgRef{Version=[2],Kind=[AddedNormal]}
5380 @ChgAdded{Version=[2],Text=[The set that contains the element it designates
5381 has been finalized;]}
5382
5383 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0160-1]}
5384 @ChgAdded{Version=[3],Text=[The set that contains the element it designates has been used as the Target of
5385 a call to Assign, or as the target of an @nt{assignment_statement};]}
5386
5387 @ChgRef{Version=[2],Kind=[AddedNormal]}
5388 @ChgAdded{Version=[2],Text=[The set that contains the element it designates
5389 has been used as the Source or Target of a call to Move; or]}
5390
5391 @ChgRef{Version=[2],Kind=[AddedNormal]}
5392 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0160-1],ARef=[AI05-0262-1]}
5393 @ChgAdded{Version=[2],Text=[The element it designates has been
5394 @Chg{Version=[3],New=[removed],Old=[deleted]} from the
5395 set@Chg{Version=[3],New=[ that previously contained the element],Old=[]}.]}
5396 @begin{Ramification}
5397 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]}
5398 @ChgAdded{Version=[3],Text=[This can happen directly via calls to Clear,
5399 Exclude, Delete, and Update_Element_Preserving_Key, and indirectly via calls
5400 to procedures Intersection, Difference, and Symmetric_Difference.]}
5401 @end{Ramification}
5402
5403 @end{Itemize}
5404
5405 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5406 @ChgAdded{Version=[2],Text=[The result of "=" or Has_Element is
5407 unspecified if these functions are called with an invalid cursor
5408 parameter.@PDefn{unspecified} Execution is erroneous if any other subprogram
5409 declared in Containers.Hashed_Sets or Containers.Ordered_Sets is called with an
5410 invalid cursor parameter.@PDefn2{Term=(erroneous execution),Sec=(cause)}]}
5411
5412 @begin{Discussion}
5413 @ChgRef{Version=[2],Kind=[AddedNormal]}
5414 @ChgAdded{Version=[2],Text=[The list above is intended to be
5415 exhaustive. In other cases, a cursor value continues to designate its
5416 original element. For instance, cursor values survive the insertion and
5417 deletion of other elements.]}
5418
5419 @ChgRef{Version=[2],Kind=[AddedNormal]}
5420 @ChgAdded{Version=[2],Text=[While it is possible to check for these cases, in
5421 many cases the overhead necessary to make the check is substantial in time or
5422 space. Implementations are encouraged to check for as many of these cases as
5423 possible and raise Program_Error if detected.]}
5424 @end{Discussion}
5425
5426 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
5427 @ChgAdded{Version=[3],Text=[Execution is erroneous if the set associated with
5428 the result of a call to Reference or Constant_Reference is finalized before the
5429 result object returned by the call to Reference or Constant_Reference is
5430 finalized.]}
5431 @begin{Reason}
5432 @ChgRef{Version=[3],Kind=[AddedNormal]}
5433 @ChgAdded{Version=[3],Text=[Each object of Reference_Type and
5434 Constant_Reference_Type probably contains some reference to the originating
5435 container. If that container is prematurely finalized (which is only possible
5436 via Unchecked_Deallocation, as accessibility checks prevent passing a
5437 container to Reference that will not live as long as the result), the
5438 finalization of the object of Reference_Type will try to access a nonexistent
5439 object. This is a normal case of a dangling pointer created by
5440 Unchecked_Deallocation; we have to explicitly mention it here as the pointer
5441 in question is not visible in the specification of the type. (This is the same
5442 reason we have to say this for invalid cursors.)]}
5443 @end{Reason}
5444 @end{Erron}
5445
5446 @begin{ImplReq}
5447
5448 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5449 @ChgAdded{Version=[2],Text=[No storage associated with a Set object shall be
5450 lost upon assignment or scope exit.]}
5451
5452 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5453 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]}
5454 @ChgAdded{Version=[2],Text=[The execution of an @nt{assignment_statement} for
5455 a set shall have the effect of copying the elements from the source set
5456 object to the target set object@Chg{Version=[3],New=[ and changing the length
5457 of the target object to that of the source object],Old=[]}.]}
5458
5459 @begin{ImplNote}
5460 @ChgRef{Version=[2],Kind=[AddedNormal]}
5461 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0298-1]}
5462 @ChgAdded{Version=[2],Text=[An assignment of a Set is a @lquotes@;deep@rquotes
5463 copy; that is the elements are copied as well as the data structures.
5464 We say @lquotes@;effect of@rquotes in order to allow the implementation to
5465 avoid copying elements immediately if it wishes. For instance, an
5466 implementation that avoided copying until one of the containers is modified
5467 would be allowed.@Chg{Version=[3],New=[ (Note that this implementation would
5468 require care, see @RefSecNum{The Generic Package Containers.Vectors} for more.)],Old=[]}]}
5469 @end{ImplNote}
5470
5471 @end{ImplReq}
5472
5473 @begin{ImplAdvice}
5474
5475 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5476 @ChgAdded{Version=[2],Text=[Move should not copy elements, and should minimize
5477 copying of internal data structures.]}
5478 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
5479 Text=[Move for sets should not copy elements, and should minimize
5480 copying of internal data structures.]}]}
5481
5482 @begin{ImplNote}
5483 @ChgRef{Version=[2],Kind=[AddedNormal]}
5484 @ChgAdded{Version=[2],Text=[Usually that can be accomplished simply by
5485 moving the pointer(s) to the internal data structures from the Source
5486 container to the Target container.]}
5487 @end{ImplNote}
5488
5489 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5490 @ChgAdded{Version=[2],Text=[If an exception is propagated from a set
5491 operation, no storage should be lost, nor any elements removed from a set
5492 unless specified by the operation.]}
5493 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
5494 Text=[If an exception is propagated from a set
5495 operation, no storage should be lost, nor any elements removed from a set
5496 unless specified by the operation.]}]}
5497
5498 @begin{Reason}
5499 @ChgRef{Version=[2],Kind=[AddedNormal]}
5500 @ChgAdded{Version=[2],Text=[This is important so that programs can recover
5501 from errors. But we don't want to require heroic efforts, so we just require
5502 documentation of cases where this can't be accomplished.]}
5503 @end{Reason}
5504
5505 @end{ImplAdvice}
5506
5507 @begin{DiffWord95}
5508 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5509 @ChgAdded{Version=[2],Text=[This description of sets is new; the
5510 extensions are documented with the specific packages.]}
5511 @end{DiffWord95}
5512
5513 @begin{Extend2005}
5514 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]}
5515 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
5516 Added reference support to make set containers more
5517 convenient to use.]}
5518 @end{Extend2005}
5519
5520 @begin{DiffWord2005}
5521 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
5522 @ChgAdded{Version=[3],Text=[Added procedure Assign;
5523 the extension and incompatibility is documented with the specific packages.]}
5524
5525 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
5526 @ChgAdded{Version=[3],Text=[Generalized the definition
5527 of Move. Specified which elements are read/written by stream attributes.]}
5528
5529 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0022-1]}
5530 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName
5531 to cover tampering by generic actual subprograms.]}
5532
5533 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0027-1]}
5534 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a @BoundedName
5535 to cover access to finalized set containers.]}
5536
5537 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0160-1]}
5538 @ChgAdded{Version=[3],Text=[@b<Correction:> Revised the definition
5539 of invalid cursors to cover missing (and new) cases.]}
5540
5541 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0265-1]}
5542 @ChgAdded{Version=[3],Text=[@b<Correction:> Defined when a container
5543 prohibits tampering in order to more clearly define where the check is
5544 made and the exception raised.]}
5545 @end{DiffWord2005}
5546
5547 @begin{Inconsistent2012}
5548 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1]}
5549 @ChgAdded{Version=[5],Text=[@Defn{inconsistencies with Ada 2012}Procedures
5550 Union, Intersection, Difference, and Symmeteric_Difference are now defined
5551 to tamper with the cursors of the Target parameter. A program which attempts
5552 to use one of these operations while tampering is prohibited will raise
5553 Program_Error. However, since the operations do modify the container, the
5554 effects would have been unpredictable, so this change will likely fix
5555 bugs.]}
5556 @end{Inconsistent2012}
5557
5558 @begin{Extend2012}
5559 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0196-1]}
5560 @ChgAdded{Version=[5],Text=[@Defn{extensions to Ada 2012}@b{Correction:}
5561 Replace_Element is now defined such that it can be used
5562 concurrently so long as it operates on different elements. This allows
5563 some container operations to be used in parallel without separate
5564 synchronization.]}
5565 @end{Extend2012}
5566
5567 @begin{DiffWord2012}
5568 @ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0110-1]}
5569 @ChgAdded{Version=[4],Text=[@b<Corrigendum:> Clarified that tampering checks
5570 precede all other checks made by a subprogram (but come after those associated
5571 with the call).]}
5572
5573 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
5574 @ChgAdded{Version=[5],Text=[Added contracts to this container. This includes
5575 describing some of the semantics with pre- and postconditions, rather than
5576 English text. Note that the preconditions can be Suppressed (see
5577 @RefSecNum{Suppressing Checks}).]}
5578 @end{DiffWord2012}
5579
5580
5581 @LabeledAddedSubclause{Version=[2],Name=[The Generic Package Containers.Hashed_Sets]}
5582
5583 @begin{StaticSem}
5584
5585 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
5586 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library
5587 package Containers.Hashed_Sets has the following declaration:]}
5588 @begin{Example}
5589 @ChgRef{Version=[2],Kind=[AddedNormal]}
5590 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0084-1],ARef=[AI05-0212-1]}
5591 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5592 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[@key[with] Ada.Iterator_Interfaces;
5593 ],Old=[]}@key{generic}
5594 @key{type} Element_Type @key{is private};
5595 @key{with function} Hash (Element : Element_Type) @key{return} Hash_Type;
5596 @key{with function} Equivalent_Elements (Left, Right : Element_Type)
5597 @key{return} Boolean;
5598 @key{with function} "=" (Left, Right : Element_Type) @key{return} Boolean @key{is} <>;
5599 @key{package} Ada.Containers.Hashed_Sets@Chg{Version=[5],New=[],Old=[ @key{is}]}@ChildUnit{Parent=[Ada.Containers],Child=[Hashed_Sets]}@Chg{Version=[5],New=[
5600 @key[with] Preelaborate, Remote_Types,
5601 Nonblocking, Global => @key[null] @key[is]],Old=[
5602 @key{pragma} Preelaborate(Hashed_Sets);@Chg{Version=[3],New=[
5603 @key{pragma} Remote_Types(Hashed_Sets);],Old=[]}]}]}
5604
5605 @begin{Discussion}
5606 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
5607 @ChgAdded{Version=[5],Text=[For discussion on the reasons and meaning of
5608 the specifications of the Global and Nonblocking aspects in this generic
5609 package, see the notes on the equivalent operations in the specification
5610 of the Containers.Vectors package (see
5611 @RefSecNum{The Generic Package Containers.Vectors}).]}
5612 @end{Discussion}
5613
5614 @ChgRef{Version=[2],Kind=[AddedNormal]}
5615 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]}
5616 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0111-1],ARef=[AI12-0112-1],ARef=[AI12-0212-1],ARef=[AI12-0339-1]}
5617 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Set} @key{is tagged private}@Chg{Version=[3],New=[
5618 @key[with] Constant_Indexing => Constant_Reference,
5619 Default_Iterator => Iterate,
5620 Iterator_Element => Element_Type],Old=[]}@Chg{Version=[5],New=[,
5621 Iterator_View => Stable.Set,
5622 Aggregate => (Empty => Empty,
5623 Add_Unnamed => Include),
5624 Stable_Properties => (Length,
5625 Tampering_With_Cursors_Prohibited),
5626 Default_Initial_Condition =>
5627 Length (Set) = 0 @key{and then}
5628 (@key{not} Tampering_With_Cursors_Prohibited (Set))],Old=[]};
5629 @key{pragma} Preelaborable_Initialization(Set);]}
5630
5631 @begin{Discussion}
5632 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
5633 @ChgAdded{Version=[5],Text=[Unlike a Vector, the Stable_Properties of a
5634 Hashed_Set do not include the Capacity. If we had included it, some of the
5635 otherwise shared definitions would need different postconditions for
5636 Hashed_Sets and Ordered_Sets. If we were starting these containers from
5637 scratch, we probably would have approached the sharing of definitions
5638 differently so that we could avoid issues like this, but a major
5639 reorganization of this existing material would be too much change.]}
5640 @end{Discussion}
5641
5642 @ChgRef{Version=[2],Kind=[AddedNormal]}
5643 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private};
5644 @key{pragma} Preelaborable_Initialization(Cursor);]}
5645
5646 @ChgRef{Version=[2],Kind=[AddedNormal]}
5647 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{Empty_Set} : @key{constant} Set;]}
5648
5649 @ChgRef{Version=[2],Kind=[AddedNormal]}
5650 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]}
5651
5652 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
5653 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5654 @ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
5655 @key[with] Nonblocking, Global => (@key[in all], @key[use null])],Old=[]};]}
5656
5657 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5658 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Has_Element} (Container : Set; Position : Cursor)
5659 @key{return} Boolean
5660 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
5661
5662 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
5663 @ChgAdded{Version=[3],Text=[ @key[package] @AdaPackDefn{Set_Iterator_Interfaces} @key[is new]
5664 Ada.Iterator_Interfaces (Cursor, Has_Element);]}
5665
5666 @ChgRef{Version=[2],Kind=[AddedNormal]}
5667 @ChgAdded{Version=[2],Text=[ @key{function} "=" (Left, Right : Set) @key{return} Boolean;]}
5668
5669 @ChgRef{Version=[2],Kind=[AddedNormal]}
5670 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Sets} (Left, Right : Set) @key{return} Boolean;]}
5671
5672 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5673 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Tampering_With_Cursors_Prohibited}
5674 (Container : Set) @key{return} Boolean
5675 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
5676
5677 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0339-1]}
5678 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Empty} (Capacity : Count_Type := @RI{implementation-defined})
5679 @key[return] Set
5680 @key[with] Post =>
5681 Capacity (Empty'Result) >= Capacity @key[and then]
5682 @key[not] Tampering_With_Cursors_Prohibited (Empty'Result) @key[and then]
5683 Length (Empty'Result) = 0;]}
5684
5685 @ChgRef{Version=[2],Kind=[AddedNormal]}
5686 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5687 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{To_Set} (New_Item : Element_Type) @key{return} Set@Chg{Version=[5],New=[
5688 @key[with] Post => Length (To_Set'Result) = 1 @key{and then}
5689 @key{not} Tampering_with_Cursors_Prohibited (To_Set'Result)],Old=[]};]}
5690
5691 @ChgRef{Version=[2],Kind=[AddedNormal]}
5692 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5693 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Capacity} (Container : Set) @key{return} Count_Type@Chg{Version=[5],New=[
5694 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
5695
5696 @ChgRef{Version=[2],Kind=[AddedNormal]}
5697 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5698 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reserve_Capacity} (Container : @key{in out} Set;
5699 Capacity : @key{in} Count_Type)@Chg{Version=[5],New=[
5700 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
5701 @key[or else raise] Program_Error,
5702 Post => Container.Capacity >= Capacity],Old=[]};]}
5703
5704 @ChgRef{Version=[2],Kind=[AddedNormal]}
5705 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5706 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Length} (Container : Set) @key{return} Count_Type@Chg{Version=[5],New=[
5707 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
5708
5709 @ChgRef{Version=[2],Kind=[AddedNormal]}
5710 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5711 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Empty} (Container : Set) @key{return} Boolean@Chg{Version=[5],New=[
5712 @key[with] Nonblocking, Global => (@key[null], @key[use null]),
5713 Post => Is_Empty'Result = (Length (Container) = 0)],Old=[]};]}
5714
5715 @ChgRef{Version=[2],Kind=[AddedNormal]}
5716 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5717 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Clear} (Container : @key{in out} Set)@Chg{Version=[5],New=[
5718 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
5719 @key[or else raise] Program_Error,
5720 Post => Capacity (Container) = Capacity (Container)'Old @key{and then}
5721 Length (Container) = 0],Old=[]};]}
5722
5723 @ChgRef{Version=[2],Kind=[AddedNormal]}
5724 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5725 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Position : Cursor) @key{return} Element_Type@Chg{Version=[5],New=[
5726 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
5727 Nonblocking => Element_Type'Nonblocking,
5728 Global => (@key{in all}, @key{use} Element_Type)],Old=[]};]}
5729
5730 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5731 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Element} (Container : Set;
5732 Position : Cursor) @key{return} Element_Type
5733 @key{with} Pre => (Position /= No_Element
5734 @key{or else raise} Constraint_Error) @key{and then}
5735 (Has_Element (Container, Position)
5736 @key{or else raise} Program_Error),
5737 Nonblocking => Element_Type'Nonblocking,
5738 Global => (@key{null}, @key{use} Element_Type);]}
5739
5740 @ChgRef{Version=[2],Kind=[AddedNormal]}
5741 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5742 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} Set;
5743 Position : @key{in} Cursor;
5744 New_item : @key{in} Element_Type)@Chg{Version=[5],New=[
5745 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
5746 @key{or else raise} Program_Error) @key{and then}
5747 (Position /= No_Element
5748 @key{or else raise} Constraint_Error) @key{and then}
5749 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
5750
5751 @ChgRef{Version=[2],Kind=[AddedNormal]}
5752 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5753 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element}
5754 (Position : @key{in} Cursor;
5755 Process : @key{not null access procedure} (Element : @key{in} Element_Type))@Chg{Version=[5],New=[
5756 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
5757 Global => @key{in all}],Old=[]};]}
5758
5759 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5760 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Query_Element}
5761 (Container : @key{in} Set;
5762 Position : @key{in} Cursor;
5763 Process : @key{not null access procedure} (Element : @key{in} Element_Type))
5764 @key{with} Pre => (Position /= No_Element
5765 @key{or else raise} Constraint_Error) @key{and then}
5766 (Has_Element (Container, Position)
5767 @key{or else raise} Program_Error);]}
5768
5769 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
5770 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5771 @ChgAdded{Version=[3],Text=[ @key[type] Constant_Reference_Type
5772 (Element : @key[not null access constant] Element_Type) @key[is private]
5773 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
5774 Nonblocking, Global => @key[in out synchronized],
5775 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
5776
5777 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
5778 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5779 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Set;
5780 Position : @key[in] Cursor)
5781 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
5782 @key[with] Pre => (Position /= No_Element
5783 @key[or else raise] Constraint_Error) @key[and then]
5784 (Has_Element (Container, Position)
5785 @key[or else raise] Program_Error),
5786 Post => Tampering_With_Cursors_Prohibited (Container),
5787 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
5788
5789 @ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]}
5790 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5791 @ChgAdded{Version=[3],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} Set; Source : @key{in} Set)@Chg{Version=[5],New=[
5792 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Target)
5793 @key[or else raise] Program_Error,
5794 Post => Length (Source) = Length (Target) @key[and then]
5795 Capacity (Target) >= Length (Source)],Old=[]};]}
5796
5797 @ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]}
5798 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
5799 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Copy} (Source : Set; Capacity : Count_Type := 0)
5800 @key[return] Set@Chg{Version=[5],New=[
5801 @key[with] Pre => Capacity = 0 @key[or else] Capacity >= Length (Source)
5802 @key[or else raise] Capacity_Error,
5803 Post =>
5804 Length (Copy'Result) = Length (Source) @key[and then]
5805 @key[not] Tampering_With_Cursors_Prohibited (Copy'Result) @key[and then]
5806 Copy'Result.Capacity = (if Capacity = 0 then
5807 Length (Source) else Capacity)],Old=[]};]}
5808
5809 @ChgRef{Version=[2],Kind=[AddedNormal]}
5810 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5811 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Move} (Target : @key{in out} Set;
5812 Source : @key{in out} Set)@Chg{Version=[5],New=[
5813 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
5814 @key{or else raise} Program_Error) @key{and then}
5815 (@key{not} Tampering_With_Cursors_Prohibited (Source)
5816 @key{or else raise} Program_Error),
5817 Post => (@key{if} Target = Source @key{then} True
5818 @key{else}
5819 Length (Target) = Length (Source'Old) @key{and then}
5820 Length (Source) = 0)],Old=[]};]}
5821
5822 @ChgRef{Version=[2],Kind=[AddedNormal]}
5823 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5824 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Set;
5825 New_Item : @key{in} Element_Type;
5826 Position : @key{out} Cursor;
5827 Inserted : @key{out} Boolean)@Chg{Version=[5],New=[
5828 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
5829 @key{or else raise} Program_Error) @key{and then}
5830 (Length (Container) <= Count_Type'Last - 1
5831 @key{or else raise} Constraint_Error),
5832 Post => (@key{declare}
5833 Original_Length : @key{constant} Count_Type :=
5834 Length (Container)'Old;
5835 @key{begin}
5836 Has_Element (Container, Position) @key{and then}
5837 (@key{if} Inserted then
5838 Length (Container) = Original_Length + 1
5839 @key{else}
5840 Length (Container) = Original_Length)) @key{and then}
5841 Capacity (Container) >= Length (Container)],Old=[]};]}
5842
5843 @ChgRef{Version=[2],Kind=[AddedNormal]}
5844 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5845 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Set;
5846 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
5847 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
5848 @key{or else raise} Program_Error) @key{and then}
5849 (Length (Container) <= Count_Type'Last - 1
5850 @key{or else raise} Constraint_Error),
5851 Post => Length (Container) = Length (Container)'Old + 1 @key{and then}
5852 Capacity (Container) >= Length (Container)],Old=[]};]}
5853
5854 @ChgRef{Version=[2],Kind=[AddedNormal]}
5855 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5856 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Include} (Container : @key{in out} Set;
5857 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
5858 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
5859 @key{or else raise} Program_Error) @key{and then}
5860 (Length (Container) <= Count_Type'Last - 1
5861 @key{or else raise} Constraint_Error),
5862 Post => (@key{declare}
5863 Original_Length : @key{constant} Count_Type :=
5864 Length (Container)'Old;
5865 @key{begin}
5866 Length (Container)
5867 @key{in} Original_Length | Original_Length + 1) @key{and then}
5868 Capacity (Container) >= Length (Container)],Old=[]};]}
5869
5870 @ChgRef{Version=[2],Kind=[AddedNormal]}
5871 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5872 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace} (Container : @key{in out} Set;
5873 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
5874 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
5875 @key{or else raise} Program_Error,
5876 Post => Length (Container) = Length (Container)'Old],Old=[]};]}
5877
5878 @ChgRef{Version=[2],Kind=[AddedNormal]}
5879 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5880 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Exclude} (Container : @key{in out} Set;
5881 Item : @key{in} Element_Type)@Chg{Version=[5],New=[
5882 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
5883 @key{or else raise} Program_Error,
5884 Post => (@key{declare}
5885 Original_Length : @key{constant} Count_Type :=
5886 Length (Container)'Old;
5887 @key{begin}
5888 Length (Container) @key{in}
5889 Original_Length - 1 | Original_Length)],Old=[]};]}
5890
5891 @ChgRef{Version=[2],Kind=[AddedNormal]}
5892 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5893 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Set;
5894 Position : @key{in out} Cursor)@Chg{Version=[5],New=[
5895 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
5896 @key{or else raise} Program_Error) @key{and then}
5897 (Position /= No_Element
5898 @key{or else raise} Constraint_Error) @key{and then}
5899 (Has_Element (Container, Position)
5900 @key{or else raise} Program_Error),
5901 Post => Length (Container) = Length (Container)'Old - 1 @key{and then}
5902 Position = No_Element],Old=[]};]}
5903
5904 @ChgRef{Version=[2],Kind=[AddedNormal]}
5905 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5906 @ChgAdded{Version=[2],Text=[ @key{procedure} Union (Target : @key{in out} Set;
5907 Source : @key{in} Set)@Chg{Version=[5],New=[
5908 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Target)
5909 @key{or else raise} Program_Error,
5910 Post => Length (Target) <= Length (Target)'Old + Length (Source)],Old=[]};]}
5911
5912 @ChgRef{Version=[2],Kind=[AddedNormal]}
5913 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5914 @ChgAdded{Version=[2],Text=[ @key{function} Union (Left, Right : Set) @key{return} Set@Chg{Version=[5],New=[
5915 @key{with} Post => Length (Union'Result) <= Length (Left) + Length (Right) @key{and then}
5916 @key{not} Tampering_With_Cursors_Prohibited (Union'Result)],Old=[]};]}
5917
5918 @ChgRef{Version=[2],Kind=[AddedNormal]}
5919 @ChgAdded{Version=[2],Text=[ @key{function} "@key{or}" (Left, Right : Set) @key{return} Set @key{renames} Union;]}
5920
5921 @ChgRef{Version=[2],Kind=[AddedNormal]}
5922 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5923 @ChgAdded{Version=[2],Text=[ @key{procedure} Intersection (Target : @key{in out} Set;
5924 Source : @key{in} Set)@Chg{Version=[5],New=[
5925 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Target)
5926 @key{or else raise} Program_Error,
5927 Post => Length (Target) <= Length (Target)'Old + Length (Source)],Old=[]};]}
5928
5929 @ChgRef{Version=[2],Kind=[AddedNormal]}
5930 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5931 @ChgAdded{Version=[2],Text=[ @key{function} Intersection (Left, Right : Set) @key{return} Set@Chg{Version=[5],New=[
5932 @key{with} Post => Length (Intersection'Result) <= Length (Left) + Length (Right) @key{and then}
5933 @key{not} Tampering_With_Cursors_Prohibited (Intersection'Result)],Old=[]};]}
5934
5935 @ChgRef{Version=[2],Kind=[AddedNormal]}
5936 @ChgAdded{Version=[2],Text=[ @key{function} "@key{and}" (Left, Right : Set) @key{return} Set @key{renames} Intersection;]}
5937
5938 @ChgRef{Version=[2],Kind=[AddedNormal]}
5939 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5940 @ChgAdded{Version=[2],Text=[ @key{procedure} Difference (Target : @key{in out} Set;
5941 Source : @key{in} Set)@Chg{Version=[5],New=[
5942 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Target)
5943 @key{or else raise} Program_Error,
5944 Post => Length (Target) <= Length (Target)'Old + Length (Source)],Old=[]};]}
5945
5946 @ChgRef{Version=[2],Kind=[AddedNormal]}
5947 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5948 @ChgAdded{Version=[2],Text=[ @key{function} Difference (Left, Right : Set) @key{return} Set@Chg{Version=[5],New=[
5949 @key{with} Post => Length (Difference'Result) <= Length (Left) + Length (Right) @key{and then}
5950 @key{not} Tampering_With_Cursors_Prohibited (Difference'Result)],Old=[]};]}
5951
5952 @ChgRef{Version=[2],Kind=[AddedNormal]}
5953 @ChgAdded{Version=[2],Text=[ @key{function} "-" (Left, Right : Set) @key{return} Set @key{renames} Difference;]}
5954
5955 @ChgRef{Version=[2],Kind=[AddedNormal]}
5956 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5957 @ChgAdded{Version=[2],Text=[ @key{procedure} Symmetric_Difference (Target : @key{in out} Set;
5958 Source : @key{in} Set)@Chg{Version=[5],New=[
5959 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Target)
5960 @key{or else raise} Program_Error,
5961 Post => Length (Target) <= Length (Target)'Old + Length (Source)],Old=[]};]}
5962
5963 @ChgRef{Version=[2],Kind=[AddedNormal]}
5964 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5965 @ChgAdded{Version=[2],Text=[ @key{function} Symmetric_Difference (Left, Right : Set) @key{return} Set@Chg{Version=[5],New=[
5966 @key{with} Post => Length (Symmetric_Difference'Result) <= Length (Left) + Length (Right) @key{and then}
5967 @key{not} Tampering_With_Cursors_Prohibited (Symmetric_Difference'Result)],Old=[]};]}
5968
5969 @ChgRef{Version=[2],Kind=[AddedNormal]}
5970 @ChgAdded{Version=[2],Text=[ @key{function} "@key{xor}" (Left, Right : Set) @key{return} Set
5971 @key{renames} Symmetric_Difference;]}
5972
5973 @ChgRef{Version=[2],Kind=[AddedNormal]}
5974 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Overlap} (Left, Right : Set) @key{return} Boolean;]}
5975
5976 @ChgRef{Version=[2],Kind=[AddedNormal]}
5977 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Subset} (Subset : Set;
5978 Of_Set : Set) @key{return} Boolean;]}
5979
5980 @ChgRef{Version=[2],Kind=[AddedNormal]}
5981 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5982 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First} (Container : Set) @key{return} Cursor@Chg{Version=[5],New=[
5983 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
5984 Post => (@key{if not} Is_Empty (Container)
5985 @key{then} Has_Element (Container, First'Result)
5986 @key{else} First'Result = No_Element)],Old=[]};]}
5987
5988 @ChgRef{Version=[2],Kind=[AddedNormal]}
5989 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
5990 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Next} (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
5991 @key{with} Nonblocking, Global => (@key{in all}, @key{use null}),
5992 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
5993 @key{else} True)],Old=[]};]}
5994
5995 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
5996 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Next} (Container : Set;
5997 Position : Cursor) @key{return} Cursor
5998 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
5999 Pre => Position = No_Element @key{or else}
6000 Has_Element (Container, Position)
6001 @key{or else raise} Program_Error,
6002 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
6003 @key{elsif} Next'Result = No_Element @key{then}
6004 Position = Last (Container)
6005 @key{else} Has_Element (Container, Next'Result));]}
6006
6007 @ChgRef{Version=[2],Kind=[AddedNormal]}
6008 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6009 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Next} (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
6010 @key{with} Nonblocking, Global => (@key{in all}, @key{use null})],Old=[]};]}
6011
6012 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
6013 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Next} (Container : @key{in} Set;
6014 Position : @key{in out} Cursor)
6015 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
6016 Pre => Position = No_Element @key{or else}
6017 Has_Element (Container, Position)
6018 @key{or else raise} Program_Error,
6019 Post => (@key{if} Position /= No_Element
6020 @key{then} Has_Element (Container, Position));]}
6021
6022 @ChgRef{Version=[2],Kind=[AddedNormal]}
6023 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6024 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Set;
6025 Item : Element_Type)
6026 @key{return} Cursor@Chg{Version=[5],New=[
6027 @key{with} Post => (@key{if} Find'Result = No_Element @key{then} True
6028 @key{else} Has_Element (Container, Find'Result))],Old=[]};]}
6029
6030 @ChgRef{Version=[2],Kind=[AddedNormal]}
6031 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Set;
6032 Item : Element_Type) @key{return} Boolean;]}
6033
6034 @ChgRef{Version=[2],Kind=[AddedNormal]}
6035 @ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0212-1]}
6036 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]}]}
6037
6038 @ChgRef{Version=[2],Kind=[AddedNormal]}
6039 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6040 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Elements} (Left, Right : Cursor)
6041 @key{return} Boolean@Chg{Version=[5],New=[
6042 @key{with} Pre => (Left /= No_Element @key{and then} Right /= No_Element)
6043 @key{or else raise} Constraint_Error,
6044 Global => @key{in all}],Old=[]};]}
6045
6046 @ChgRef{Version=[2],Kind=[AddedNormal]}
6047 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6048 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Elements} (Left : Cursor;
6049 Right : Element_Type)
6050 @key{return} Boolean@Chg{Version=[5],New=[
6051 @key{with} Pre => Left /= No_Element @key{or else raise} Constraint_Error,
6052 Global => @key{in all}],Old=[]};]}
6053
6054 @ChgRef{Version=[2],Kind=[AddedNormal]}
6055 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6056 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Elements} (Left : Element_Type;
6057 Right : Cursor)
6058 @key{return} Boolean@Chg{Version=[5],New=[
6059 @key{with} Pre => Right /= No_Element @key{or else raise} Constraint_Error,
6060 Global => @key{in all}],Old=[]};]}
6061
6062 @ChgRef{Version=[2],Kind=[AddedNormal]}
6063 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6064 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Iterate}
6065 (Container : @key{in} Set;
6066 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
6067 @key{with} Allows_Exit],Old=[]};]}
6068
6069 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
6070 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1],ARef=[AI12-0266-1]}
6071 @ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] Set)
6072 @key[return] Set_Iterator_Interfaces.@Chg{Version=[5],New=[Parallel_Iterator],Old=[Forward_Iterator]}'Class@Chg{Version=[5],New=[
6073 @key[with] Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
6074
6075 @ChgRef{Version=[2],Kind=[AddedNormal]}
6076 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6077 @ChgAdded{Version=[2],Text=[ @key{generic}
6078 @key{type} Key_Type (<>) @key{is private};
6079 @key{with function} Key (Element : Element_Type) @key{return} Key_Type;
6080 @key{with function} Hash (Key : Key_Type) @key{return} Hash_Type;
6081 @key{with function} Equivalent_Keys (Left, Right : Key_Type)
6082 @key{return} Boolean;
6083 @key{package} @AdaPackDefn{Generic_Keys}@Chg{Version=[5],New=[
6084 @key[with] Nonblocking, Global => @key[null]],Old=[]} @key{is}]}
6085
6086 @ChgRef{Version=[2],Kind=[AddedNormal]}
6087 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6088 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Key} (Position : Cursor) @key{return} Key_Type@Chg{Version=[5],New=[
6089 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
6090 Global => @key{in all}],Old=[]};]}
6091
6092 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
6093 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Key} (Container : Set;
6094 Position : Cursor) @key{return} Key_Type
6095 @key{with} Pre => (Position = No_Element
6096 @key{or else raise} Constraint_Error) @key{and then}
6097 (Has_Element (Container, Position)
6098 @key{or else raise} Program_Error);]}
6099
6100 @ChgRef{Version=[2],Kind=[AddedNormal]}
6101 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Container : Set;
6102 Key : Key_Type)
6103 @key{return} Element_Type;]}
6104
6105 @ChgRef{Version=[2],Kind=[AddedNormal]}
6106 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6107 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace} (Container : @key{in out} Set;
6108 Key : @key{in} Key_Type;
6109 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
6110 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
6111 @key{or else raise} Program_Error,
6112 Post => Length (Container) = Length (Container)'Old],Old=[]};]}
6113
6114 @ChgRef{Version=[2],Kind=[AddedNormal]}
6115 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6116 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Exclude} (Container : @key{in out} Set;
6117 Key : @key{in} Key_Type)@Chg{Version=[5],New=[
6118 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
6119 @key{or else raise} Program_Error,
6120 Post => (@key{declare}
6121 Original_Length : @key{constant} Count_Type :=
6122 Length (Container)'Old;
6123 @key{begin}
6124 Length (Container)
6125 @key{in} Original_Length - 1 | Original_Length)],Old=[]};]}
6126
6127 @ChgRef{Version=[2],Kind=[AddedNormal]}
6128 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6129 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Set;
6130 Key : @key{in} Key_Type)@Chg{Version=[5],New=[
6131 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
6132 @key{or else raise} Program_Error,
6133 Post => Length (Container) = Length (Container)'Old - 1],Old=[]};]}
6134
6135 @ChgRef{Version=[2],Kind=[AddedNormal]}
6136 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6137 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Set;
6138 Key : Key_Type)
6139 @key{return} Cursor@Chg{Version=[5],New=[
6140 @key{with} Post => (@key{if} Find'Result = No_Element @key{then} True
6141 @key{else} Has_Element (Container, Find'Result))],Old=[]};]}
6142
6143 @ChgRef{Version=[2],Kind=[AddedNormal]}
6144 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Set;
6145 Key : Key_Type)
6146 @key{return} Boolean;]}
6147
6148 @ChgRef{Version=[2],Kind=[AddedNormal]}
6149 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6150 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element_Preserving_Key}
6151 (Container : @key{in out} Set;
6152 Position : @key{in} Cursor;
6153 Process : @key{not null access procedure}
6154 (Element : @key{in out} Element_Type))@Chg{Version=[5],New=[
6155 @key{with} Pre => (Position /= No_Element @key{or else}
6156 @key{raise} Constraint_Error) @key{and then}
6157 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
6158
6159 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
6160 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6161 @ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Reference_Type}
6162 (Element : @key[not null access] Element_Type) @key[is private]
6163 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
6164 Nonblocking, Global => @key[in out synchronized],
6165 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
6166
6167 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
6168 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6169 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference_Preserving_Key} (Container : @key[aliased in out] Set;
6170 Position : @key[in] Cursor)
6171 @key[return] Reference_Type@Chg{Version=[5],New=[
6172 @key[with] Pre => (Position /= No_Element
6173 @key[or else raise] Constraint_Error) @key[and then]
6174 (Has_Element (Container, Position)
6175 @key[or else raise] Program_Error),
6176 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
6177
6178 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
6179 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6180 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Set;
6181 Key : @key[in] Key_Type)
6182 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
6183 @key[with] Pre => Find (Container, Key) /= No_Element @key[or else]
6184 @key[raise] Constraint_Error,
6185 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
6186
6187 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
6188 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6189 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference_Preserving_Key} (Container : @key[aliased in out] Set;
6190 Key : @key[in] Key_Type)
6191 @key[return] Reference_Type@Chg{Version=[5],New=[
6192 @key[with] Pre => Find (Container, Key) /= No_Element @key[or else]
6193 @key[raise] Constraint_Error,
6194 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
6195
6196 @ChgRef{Version=[2],Kind=[AddedNormal]}
6197 @ChgAdded{Version=[2],Text=[ @key{end} Generic_Keys;]}
6198
6199 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
6200 @ChgAdded{Version=[5],Text=[ @key{package} @AdaPackDefn{Stable} @key{is}]}
6201
6202 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1],ARef=[AI12-0339-1]}
6203 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Set} (Base : @key{not null access} Hashed_Sets.Set) @key{is}
6204 @key{tagged limited private}
6205 @key{with} Constant_Indexing => Constant_Reference,
6206 Default_Iterator => Iterate,
6207 Iterator_Element => Element_Type,
6208 Aggregate => (Empty => Empty,
6209 Add_Unnamed => Include),
6210 Stable_Properties => (Length),
6211 Global => @key[null],
6212 Default_Initial_Condition => Length (Set) = 0;
6213 @key{pragma} Preelaborable_Initialization(Set);]}
6214
6215 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
6216 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private};
6217 @key{pragma} Preelaborable_Initialization(Cursor);]}
6218
6219 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
6220 @ChgAdded{Version=[5],Text=[ @AdaObjDefn{Empty_Set} : @key{constant} Set;]}
6221
6222 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
6223 @ChgAdded{Version=[5],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]}
6224
6225 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
6226 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean
6227 @key{with} Nonblocking, Global => (@key{in all}, @key{use null});]}
6228
6229 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
6230 @ChgAdded{Version=[5],Text=[ @key{package} @AdaPackDefn{Set_Iterator_Interfaces} @key[is new]
6231 Ada.Iterator_Interfaces (Cursor, Has_Element);]}
6232
6233 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
6234 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} Hashed_Sets.Set;
6235 Source : @key{in} Set)
6236 @key{with} Post => Length (Source) = Length (Target);]}
6237
6238 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
6239 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Copy} (Source : Hashed_Sets.Set) @key{return} Set
6240 @key{with} Post => Length (Copy'Result) = Length (Source);]}
6241
6242 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
6243 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Constant_Reference_Type}
6244 (Element : @key{not null access constant} Element_Type) @key{is private}
6245 @key{with} Implicit_Dereference => Element,
6246 Nonblocking, Global => (@key{null}, @key{use null}),
6247 Default_Initial_Condition => (@key{raise} Program_Error);]}
6248
6249 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
6250 @ChgAdded{Version=[5],Text=[ -- @examcom{Additional subprograms as described in the text}
6251 -- @examcom{are declared here.}]}
6252
6253 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
6254 @ChgAdded{Version=[5],Text=[ @key{private}]}
6255
6256 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
6257 @ChgAdded{Version=[5],Text=[ ... -- @Examcom{not specified by the language}]}
6258
6259 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
6260 @ChgAdded{Version=[5],Text=[ @key{end} Stable;]}
6261
6262 @ChgRef{Version=[2],Kind=[AddedNormal]}
6263 @ChgAdded{Version=[2],Text=[@key{private}]}
6264
6265 @ChgRef{Version=[2],Kind=[AddedNormal]}
6266 @ChgAdded{Version=[2],Text=[ ... -- @RI[not specified by the language]]}
6267
6268 @ChgRef{Version=[2],Kind=[AddedNormal]}
6269 @ChgAdded{Version=[2],Text=[@key{end} Ada.Containers.Hashed_Sets;]}
6270
6271 @end{Example}
6272
6273 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6274 @ChgAdded{Version=[2],Text=[@Defn2{Term=[capacity],Sec=[of a hashed set]}
6275 An object of type Set contains an expandable hash
6276 table, which is used to provide direct access to elements. The @i<capacity> of
6277 an object of type Set is the maximum number of elements that can be inserted
6278 into the hash table prior to it being automatically expanded.]}
6279
6280 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6281 @ChgAdded{Version=[2],Text=[@Defn2{Term=[equivalent element],Sec=[of a hashed set]}
6282 Two elements @i<E1> and @i<E2> are defined to be @i<equivalent> if
6283 Equivalent_Elements (@i<E1>, @i<E2>) returns True.]}
6284
6285 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6286 @ChgAdded{Version=[2],Text=[The actual function for the generic formal function
6287 Hash is expected to return the same value each time it is called with a
6288 particular element value. For any two equivalent elements, the actual for Hash
6289 is expected to return the same value. If the actual for Hash behaves in some
6290 other manner, the behavior of this package is unspecified. Which subprograms of
6291 this package call Hash, and how many times they call it, is
6292 unspecified.@PDefn{unspecified}]}
6293
6294 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6295 @ChgAdded{Version=[2],Text=[The actual function for the generic formal function
6296 Equivalent_Elements is expected to return the same value each time it is called
6297 with a particular pair of Element values. It should define an equivalence
6298 relationship, that is, be reflexive, symmetric, and transitive. If the actual
6299 for Equivalent_Elements behaves in some other manner, the behavior of this
6300 package is unspecified. Which subprograms of this package call
6301 Equivalent_Elements, and how many times they call it, is
6302 unspecified.@PDefn{unspecified}]}
6303
6304 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0044-1]}
6305 @ChgAdded{Version=[3],Text=[If the actual function for the generic formal
6306 function "=" returns True for any pair of nonequivalent elements, then the
6307 behavior of the container function "=" is unspecified.@PDefn{unspecified}]}
6308
6309 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6310 @ChgAdded{Version=[2],Text=[If the value of an element stored in a set is
6311 changed other than by an operation in this package such that at least one of
6312 Hash or Equivalent_Elements give different results, the behavior of this
6313 package is unspecified.@PDefn{unspecified}]}
6314
6315 @begin{Discussion}
6316 @ChgRef{Version=[2],Kind=[AddedNormal]}
6317 @ChgAdded{Version=[2],Text=[See @RefSec{The Generic Package Containers.Hashed_Maps}
6318 for a suggested implementation, and for justification of the restrictions
6319 regarding Hash and Equivalent_Elements. Note that sets only need to store
6320 elements, not key/element pairs.]}
6321 @end{Discussion}
6322
6323 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6324 @ChgAdded{Version=[2],Text=[@Defn2{Term=[first element],Sec=[of a hashed set]}
6325 @Defn2{Term=[last element],Sec=[of a hashed set]}
6326 @Defn2{Term=[successor element],Sec=[of a hashed set]}
6327 Which elements are the first element and the last
6328 element of a set, and which element is the successor of a given element, are
6329 unspecified, other than the general semantics described in
6330 @RefSecNum{Sets}.@PDefn{unspecified}]}
6331
6332 @begin{DescribeCode}
6333
6334 @begin{Example}
6335 @ChgRef{Version=[5],Kind=[Added]}
6336 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Empty (Capacity : Count_Type := @RI{implementation-defined})
6337 @key[return] Set
6338 @key[with] Post =>
6339 Capacity (Empty'Result) >= Capacity @key[and then]
6340 @key[not] Tampering_With_Cursors_Prohibited (Empty'Result) @key[and then]
6341 Length (Empty'Result) = 0;]}
6342 @end{Example}
6343
6344 @ChgRef{Version=[2],Kind=[Added],ARef=[AI12-0339-1]}
6345 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns an empty set.]}
6346
6347 @begin{Example}
6348 @ChgRef{Version=[2],Kind=[AddedNormal]}
6349 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6350 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Capacity (Container : Set) @key{return} Count_Type@Chg{Version=[5],New=[
6351 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
6352 @end{Example}
6353
6354 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6355 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the capacity of Container.]}
6356
6357 @begin{Example}
6358 @ChgRef{Version=[2],Kind=[AddedNormal]}
6359 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6360 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reserve_Capacity (Container : @key{in out} Set;
6361 Capacity : @key{in} Count_Type)@Chg{Version=[5],New=[
6362 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
6363 @key[or else raise] Program_Error,
6364 Post => Container.Capacity >= Capacity],Old=[]};]}
6365 @end{Example}
6366
6367 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6368 @ChgAdded{Version=[2],Text=[Reserve_Capacity allocates a new hash table such
6369 that the length of the resulting set can become at least the value Capacity
6370 without requiring an additional call to Reserve_Capacity, and is large enough
6371 to hold the current length of Container. Reserve_Capacity then rehashes the
6372 elements in Container onto the new hash table. It replaces the old hash table
6373 with the new hash table, and then deallocates the old hash table. Any exception
6374 raised during allocation is propagated and Container is not modified.]}
6375
6376 @ChgRef{Version=[2],Kind=[AddedNormal]}
6377 @ChgRef{Version=[5],Kind=[Deleted],ARef=[AI12-0112-1]}
6378 @ChgAdded{Version=[2],Type=[Trailing],
6379 Text=[@Chg{Version=[5],New=[],Old=[Reserve_Capacity tampers with the
6380 cursors of Container.]}]}
6381
6382 @begin{Reason}
6383 @ChgRef{Version=[2],Kind=[AddedNormal]}
6384 @ChgAdded{Version=[2],Type=[Trailing],Text=[Reserve_Capacity tampers with the
6385 cursors, as rehashing probably will change the relationships of the elements
6386 in Container.]}
6387 @end{Reason}
6388
6389 @begin{Example}
6390 @ChgRef{Version=[2],Kind=[AddedNormal]}
6391 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6392 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Clear (Container : @key{in out} Set)@Chg{Version=[5],New=[
6393 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
6394 @key[or else raise] Program_Error,
6395 Post => Capacity (Container) = Capacity (Container)'Old @key{and then}
6396 Length (Container) = 0],Old=[]};]}
6397 @end{Example}
6398
6399 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6400 @ChgAdded{Version=[2],Type=[Trailing],Text=[In addition to the semantics
6401 described in @RefSecNum{Sets}, Clear does not affect the capacity of
6402 Container.]}
6403
6404 @begin{Example}
6405 @ChgRef{Version=[3],Kind=[Added]}
6406 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6407 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[procedure] Assign (Target : @key[in out] Set; Source : @key[in] Set)@Chg{Version=[5],New=[
6408 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Target)
6409 @key[or else raise] Program_Error,
6410 Post => Length (Source) = Length (Target) @key[and then]
6411 Capacity (Target) >= Length (Source)],Old=[]};]}
6412 @end{Example}
6413
6414 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0248-1]}
6415 @ChgAdded{Version=[3],Type=[Trailing],Text=[In addition to the semantics
6416 described in @RefSecNum{Sets}, if the length of Source is greater than the
6417 capacity of Target, Reserve_Capacity (Target, Length (Source)) is called
6418 before assigning any elements.]}
6419
6420 @begin{Example}
6421 @ChgRef{Version=[3],Kind=[Added]}
6422 @ChgRef{Version=[5],Kind=[RevisedAdded]}
6423 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Copy (Source : Set; Capacity : Count_Type := 0)
6424 @key[return] Set@Chg{Version=[5],New=[
6425 @key[with] Pre => Capacity = 0 @key[or else] Capacity >= Length (Source)
6426 @key[or else raise] Capacity_Error,
6427 Post =>
6428 Length (Copy'Result) = Length (Source) @key[and then]
6429 @key[not] Tampering_With_Cursors_Prohibited (Copy'Result) @key[and then]
6430 Copy'Result.Capacity = (if Capacity = 0 then
6431 Length (Source) else Capacity)],Old=[]};]}
6432 @end{Example}
6433
6434 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
6435 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6436 @ChgAdded{Version=[3],Type=[Trailing],Text=[Returns a set whose elements are
6437 initialized from the elements of Source.@Chg{Version=[5],New=[],Old=[ If
6438 Capacity is 0, then the set capacity
6439 is the length of Source; if Capacity is equal to or greater than the length of
6440 Source, the set capacity is at least the specified value. Otherwise, the
6441 operation propagates Capacity_Error.]}]}
6442
6443 @begin{Example}
6444 @ChgRef{Version=[2],Kind=[AddedNormal]}
6445 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6446 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Insert (Container : @key{in out} Set;
6447 New_Item : @key{in} Element_Type;
6448 Position : @key{out} Cursor;
6449 Inserted : @key{out} Boolean)@Chg{Version=[5],New=[
6450 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
6451 @key{or else raise} Program_Error) @key{and then}
6452 (Length (Container) <= Count_Type'Last - 1
6453 @key{or else raise} Constraint_Error),
6454 Post => (@key{declare}
6455 Original_Length : @key{constant} Count_Type :=
6456 Length (Container)'Old;
6457 @key{begin}
6458 Has_Element (Container, Position) @key{and then}
6459 (@key{if} Inserted then
6460 Length (Container) = Original_Length + 1
6461 @key{else}
6462 Length (Container) = Original_Length)) @key{and then}
6463 Capacity (Container) >= Length (Container)],Old=[]};]}
6464 @end{Example}
6465
6466 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6467 @ChgAdded{Version=[2],Type=[Trailing],Text=[In addition to the semantics
6468 described in @RefSecNum{Sets}, if Length (Container) equals Capacity
6469 (Container), then Insert first calls Reserve_Capacity to increase the capacity
6470 of Container to some larger value.]}
6471
6472 @begin{Example}
6473 @ChgRef{Version=[2],Kind=[AddedNormal]}
6474 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First (Container : Set) @key{return} Cursor;]}
6475 @end{Example}
6476
6477 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6478 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Length (Container) = 0, then
6479 First returns No_Element. Otherwise, First returns a cursor that designates the
6480 first hashed element in Container.]}
6481
6482 @begin{Example}
6483 @ChgRef{Version=[2],Kind=[AddedNormal]}
6484 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6485 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Elements (Left, Right : Cursor)
6486 @key{return} Boolean@Chg{Version=[5],New=[
6487 @key{with} Pre => (Left /= No_Element @key{and then} Right /= No_Element)
6488 @key{or else raise} Constraint_Error,
6489 Global => @key{in all}],Old=[]};]}
6490 @end{Example}
6491
6492 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6493 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Equivalent_Elements
6494 (Element (Left), Element (Right)).]}
6495
6496 @begin{Example}
6497 @ChgRef{Version=[2],Kind=[AddedNormal]}
6498 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6499 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Elements (Left : Cursor;
6500 Right : Element_Type) @key{return} Boolean@Chg{Version=[5],New=[
6501 @key{with} Pre => Left /= No_Element @key{or else raise} Constraint_Error,
6502 Global => @key{in all}],Old=[]};]}
6503 @end{Example}
6504
6505 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6506 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Equivalent_Elements
6507 (Element (Left), Right).]}
6508
6509 @begin{Example}
6510 @ChgRef{Version=[2],Kind=[AddedNormal]}
6511 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6512 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Equivalent_Elements (Left : Element_Type;
6513 Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
6514 @key{with} Pre => Right /= No_Element @key{or else raise} Constraint_Error,
6515 Global => @key{in all}],Old=[]};]}
6516 @end{Example}
6517
6518 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6519 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Equivalent_Elements (Left, Element (Right)).]}
6520
6521 @begin{Example}
6522 @ChgRef{Version=[3],Kind=[Added]}
6523 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1],ARef=[AI12-0266-1]}
6524 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Set)
6525 @key[return] Set_Iterator_Interfaces.@Chg{Version=[5],New=[Parallel_Iterator],Old=[Forward_Iterator]}'Class@Chg{Version=[5],New=[
6526 @key[with] Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
6527 @end{Example}
6528
6529 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]}
6530 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0266-1]}
6531 @ChgAdded{Version=[3],Type=[Trailing],Text=[Iterate returns
6532 an iterator object (see @RefSecNum{User-Defined Iterator Types}) that
6533 will generate a value for a loop parameter
6534 (see @RefSecNum{Generalized Loop Iteration}) designating
6535 each element in Container, starting with the first element and moving the cursor
6536 according to the successor relation@Chg{Version=[5],New=[ when used as a forward
6537 iterator, and processing all nodes concurrently when used as a parallel
6538 iterator],Old=[]}.
6539 Tampering with the cursors of Container is prohibited while
6540 the iterator object exists (in particular, in
6541 the @nt{sequence_of_statements} of the @nt{loop_statement} whose
6542 @nt{iterator_specification} denotes this object). The iterator object needs
6543 finalization.]}
6544
6545 @end{DescribeCode}
6546
6547 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6548 @ChgAdded{Version=[2],Text=[For any element @i{E}, the actual function for the
6549 generic formal function Generic_Keys.Hash is expected to be such that Hash
6550 (@i{E}) = Generic_Keys.Hash (Key (@i{E})). If the actuals for Key or
6551 Generic_Keys.Hash behave in some other manner, the behavior of Generic_Keys is
6552 unspecified. Which subprograms of Generic_Keys call Generic_Keys.Hash, and how
6553 many times they call it, is unspecified.@PDefn{unspecified}]}
6554
6555 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6556 @ChgAdded{Version=[2],Text=[For any two elements @i{E1} and @i{E2}, the boolean
6557 values Equivalent_Elements (@i{E1}, @i{E2}) and Equivalent_Keys (Key (@i{E1}),
6558 Key (@i{E2})) are expected to be equal. If the actuals for Key or
6559 Equivalent_Keys behave in some other manner, the behavior of Generic_Keys is
6560 unspecified. Which subprograms of Generic_Keys call Equivalent_Keys, and how
6561 many times they call it, is unspecified.@PDefn{unspecified}]}
6562
6563 @end{StaticSem}
6564
6565 @begin{ImplAdvice}
6566
6567 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6568 @ChgAdded{Version=[2],Text=[If @i<N> is the length of a set, the
6569 average time complexity of the subprograms
6570 Insert, Include, Replace, Delete, Exclude and Find that take an element
6571 parameter should be @i{O}(log @i<N>). The average time complexity of the
6572 subprograms that take a cursor parameter should be @i{O}(1). The average time
6573 complexity of Reserve_Capacity should be @i{O}(@i<N>).]}
6574 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
6575 Text=[The average time complexity of the Insert, Include, Replace, Delete, Exclude and
6576 Find operations of Containers.Hashed_Sets that take an element parameter
6577 should be @i{O}(log @i<N>). The average time complexity of the subprograms
6578 of Containers.Hashed_Sets that take a cursor parameter should be @i{O}(1). The
6579 average time complexity of Containers.@!Hashed_Sets.@!Reserve_Capacity should be
6580 @i{O}(@i<N>).]}]}
6581 @end{ImplAdvice}
6582
6583 @begin{ImplNote}
6584 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6585 @ChgAdded{Version=[2],Text=[See @RefSec{The Generic Package Containers.Hashed_Maps}
6586 for implementation notes regarding some of the operations of this package.]}
6587 @end{ImplNote}
6588
6589 @begin{Extend95}
6590 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6591 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
6592 The generic package Containers.Hashed_Sets is new.]}
6593 @end{Extend95}
6594
6595 @begin{Incompatible2005}
6596 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
6597 @ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Subprograms Assign and Copy
6598 are added to Containers.Hashed_Sets. If an instance of Containers.Hashed_Sets
6599 is referenced in a @nt{use_clause}, and an entity @i<E> with the same
6600 @nt{defining_identifier} as a new entity in Containers.Hashed_Sets is
6601 defined in a package that is also referenced in a @nt{use_clause}, the
6602 entity @i<E> may no longer be use-visible, resulting in errors. This should
6603 be rare and is easily fixed if it does occur.]}
6604 @end{Incompatible2005}
6605
6606 @begin{Extend2005}
6607 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]}
6608 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
6609 Added iterator and indexing support to make hashed set containers more
6610 convenient to use.]}
6611 @end{Extend2005}
6612
6613 @begin{DiffWord2005}
6614 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]}
6615 @ChgAdded{Version=[3],Text=[@b<Correction:> Added wording to require
6616 the formal function be such that equal elements are also equivalent.]}
6617
6618 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0084-1]}
6619 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a pragma
6620 Remote_Types so that containers can be used in distributed programs.]}
6621 @end{DiffWord2005}
6622
6623 @begin{Incompatible2012}
6624 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1],ARef=[AI12-0112-1],ARef=[AI12-0339-1]}
6625 @ChgAdded{Version=[5],Text=[@Defn{incompatibilities with Ada 2012}A number of
6626 new subprograms, types, and even a nested package were added to
6627 Containers.Hashed_Sets to better support contracts and stable views. If an
6628 instance of Containers.Hashed_Sets
6629 is referenced in a @nt{use_clause}, and an entity @i<E> with the same
6630 @nt{defining_identifier} as a new entity in Containers.Hashed_Sets is
6631 defined in a package that is also referenced in a @nt{use_clause}, the
6632 entity @i<E> may no longer be use-visible, resulting in errors. This should
6633 be rare and is easily fixed if it does occur.]}
6634 @end{Incompatible2012}
6635
6636 @begin{Extend2012}
6637 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0212-1]}
6638 @ChgAdded{Version=[5],Text=[@Defn{extensions to Ada 2012}Sets now support
6639 positional container aggregates, so @nt{aggregate} syntax can be used to
6640 create Sets.]}
6641
6642 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0266-1]}
6643 @ChgAdded{Version=[5],Text=[The iterator for the
6644 container now can return a parallel iterator which can be used to
6645 process the container in parallel.]}
6646 @end{Extend2012}
6647
6648 @begin{DiffWord2012}
6649 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
6650 @ChgAdded{Version=[5],Text=[Added contracts to this container. This includes
6651 describing some of the semantics with pre- and postconditions, rather than
6652 English text. Note that the preconditions can be Suppressed (see
6653 @RefSecNum{Suppressing Checks}).]}
6654 @end{DiffWord2012}
6655
6656
6657 @LabeledAddedSubclause{Version=[2],Name=[The Generic Package Containers.Ordered_Sets]}
6658
6659 @begin{StaticSem}
6660
6661 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
6662 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library
6663 package Containers.Ordered_Sets has the following declaration:]}
6664 @begin{Example}
6665 @ChgRef{Version=[2],Kind=[AddedNormal]}
6666 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0084-1],ARef=[AI05-0212-1]}
6667 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6668 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[@key[with] Ada.Iterator_Interfaces;
6669 ],Old=[]}@key{generic}
6670 @key{type} Element_Type @key{is private};
6671 @key{with function} "<" (Left, Right : Element_Type) @key{return} Boolean @key{is} <>;
6672 @key{with function} "=" (Left, Right : Element_Type) @key{return} Boolean @key{is} <>;
6673 @key{package} Ada.Containers.Ordered_Sets@Chg{Version=[5],New=[],Old=[ @key{is}]}@ChildUnit{Parent=[Ada.Containers],Child=[Ordered_Sets]}@Chg{Version=[5],New=[
6674 @key[with] Preelaborate, Remote_Types,
6675 Nonblocking, Global => @key[null] @key[is]],Old=[
6676 @key{pragma} Preelaborate(Ordered_Sets);@Chg{Version=[3],New=[
6677 @key{pragma} Remote_Types(Ordered_Sets);],Old=[]}]}]}
6678
6679 @begin{Discussion}
6680 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
6681 @ChgAdded{Version=[5],Text=[For discussion on the reasons and meaning of
6682 the specifications of the Global and Nonblocking aspects in this generic
6683 package, see the notes on the equivalent operations in the specification
6684 of the Containers.Vectors package (see
6685 @RefSecNum{The Generic Package Containers.Vectors}).]}
6686 @end{Discussion}
6687
6688 @ChgRef{Version=[2],Kind=[AddedNormal]}
6689 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Elements} (Left, Right : Element_Type) @key{return} Boolean;]}
6690
6691 @ChgRef{Version=[2],Kind=[AddedNormal]}
6692 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]}
6693 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0111-1],ARef=[AI12-0112-1],ARef=[AI12-0212-1],ARef=[AI12-0339-1]}
6694 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Set} @key{is tagged private}@Chg{Version=[3],New=[
6695 @key[with] Constant_Indexing => Constant_Reference,
6696 Default_Iterator => Iterate,
6697 Iterator_Element => Element_Type],Old=[]}@Chg{Version=[5],New=[,
6698 Iterator_View => Stable.Set,
6699 Aggregate => (Empty => Empty,
6700 Add_Unnamed => Include),
6701 Stable_Properties => (Length,
6702 Tampering_With_Cursors_Prohibited),
6703 Default_Initial_Condition =>
6704 Length (Set) = 0 @key{and then}
6705 (@key{not} Tampering_With_Cursors_Prohibited (Set))],Old=[]};
6706 @key{pragma} Preelaborable_Initialization(Set);]}
6707
6708 @ChgRef{Version=[2],Kind=[AddedNormal]}
6709 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private};
6710 @key{pragma} Preelaborable_Initialization(Cursor);]}
6711
6712 @ChgRef{Version=[2],Kind=[AddedNormal]}
6713 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{Empty_Set} : @key{constant} Set;]}
6714
6715 @ChgRef{Version=[2],Kind=[AddedNormal]}
6716 @ChgAdded{Version=[2],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]}
6717
6718 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
6719 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6720 @ChgAdded{Version=[3],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
6721 @key[with] Nonblocking, Global => (@key[in all], @key[use null])],Old=[]};]}
6722
6723 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
6724 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Has_Element} (Container : Set; Position : Cursor)
6725 @key{return} Boolean
6726 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
6727
6728 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
6729 @ChgAdded{Version=[3],Text=[ @key[package] @AdaPackDefn{Set_Iterator_Interfaces} @key[is new]
6730 Ada.Iterator_Interfaces (Cursor, Has_Element);]}
6731
6732 @ChgRef{Version=[2],Kind=[AddedNormal]}
6733 @ChgAdded{Version=[2],Text=[ @key{function} "=" (Left, Right : Set) @key{return} Boolean;]}
6734
6735 @ChgRef{Version=[2],Kind=[AddedNormal]}
6736 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Sets} (Left, Right : Set) @key{return} Boolean;]}
6737
6738 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
6739 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Tampering_With_Cursors_Prohibited}
6740 (Container : Set) @key{return} Boolean
6741 @key[with] Nonblocking, Global => (@key[null], @key[use null]);]}
6742
6743 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0339-1]}
6744 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Empty} @key{return} Set
6745 @key[is] (Empty_Set)
6746 @key[with] Post =>
6747 @key[not] Tampering_With_Cursors_Prohibited (Empty'Result) @key[and then]
6748 Length (Empty'Result) = 0;]}
6749
6750 @ChgRef{Version=[2],Kind=[AddedNormal]}
6751 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6752 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{To_Set} (New_Item : Element_Type) @key{return} Set@Chg{Version=[5],New=[
6753 @key[with] Post => Length (To_Set'Result) = 1 @key{and then}
6754 @key{not} Tampering_with_Cursors_Prohibited (To_Set'Result)],Old=[]};]}
6755
6756 @ChgRef{Version=[2],Kind=[AddedNormal]}
6757 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6758 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Length} (Container : Set) @key{return} Count_Type@Chg{Version=[5],New=[
6759 @key[with] Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
6760
6761 @ChgRef{Version=[2],Kind=[AddedNormal]}
6762 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6763 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Empty} (Container : Set) @key{return} Boolean@Chg{Version=[5],New=[
6764 @key[with] Nonblocking, Global => (@key[null], @key[use null]),
6765 Post => Is_Empty'Result = (Length (Container) = 0)],Old=[]};]}
6766
6767 @ChgRef{Version=[2],Kind=[AddedNormal]}
6768 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6769 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Clear} (Container : @key{in out} Set)@Chg{Version=[5],New=[
6770 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Container)
6771 @key[or else raise] Program_Error,
6772 Post => Length (Container) = 0],Old=[]};]}
6773
6774 @ChgRef{Version=[2],Kind=[AddedNormal]}
6775 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6776 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Position : Cursor) @key{return} Element_Type@Chg{Version=[5],New=[
6777 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
6778 Nonblocking => Element_Type'Nonblocking,
6779 Global => (@key{in all}, @key{use} Element_Type)],Old=[]};]}
6780
6781 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
6782 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Element} (Container : Set;
6783 Position : Cursor) @key{return} Element_Type
6784 @key{with} Pre => (Position /= No_Element
6785 @key{or else raise} Constraint_Error) @key{and then}
6786 (Has_Element (Container, Position)
6787 @key{or else raise} Program_Error),
6788 Nonblocking => Element_Type'Nonblocking,
6789 Global => (@key{null}, @key{use} Element_Type);]}
6790
6791 @ChgRef{Version=[2],Kind=[AddedNormal]}
6792 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6793 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace_Element} (Container : @key{in out} Set;
6794 Position : @key{in} Cursor;
6795 New_item : @key{in} Element_Type)@Chg{Version=[5],New=[
6796 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
6797 @key{or else raise} Program_Error) @key{and then}
6798 (Position /= No_Element
6799 @key{or else raise} Constraint_Error) @key{and then}
6800 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
6801
6802 @ChgRef{Version=[2],Kind=[AddedNormal]}
6803 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6804 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Query_Element}
6805 (Position : @key{in} Cursor;
6806 Process : @key{not null access procedure} (Element : @key{in} Element_Type))@Chg{Version=[5],New=[
6807 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
6808 Global => @key{in all}],Old=[]};]}
6809
6810 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
6811 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Query_Element}
6812 (Container : @key{in} Set;
6813 Position : @key{in} Cursor;
6814 Process : @key{not null access procedure} (Element : @key{in} Element_Type))
6815 @key{with} Pre => (Position /= No_Element
6816 @key{or else raise} Constraint_Error) @key{and then}
6817 (Has_Element (Container, Position)
6818 @key{or else raise} Program_Error);]}
6819
6820 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
6821 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6822 @ChgAdded{Version=[3],Text=[ @key[type] Constant_Reference_Type
6823 (Element : @key[not null access constant] Element_Type) @key[is private]
6824 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
6825 Nonblocking, Global => @key[in out synchronized],
6826 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
6827
6828 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
6829 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6830 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Set;
6831 Position : @key[in] Cursor)
6832 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
6833 @key[with] Pre => (Position /= No_Element
6834 @key[or else raise] Constraint_Error) @key[and then]
6835 (Has_Element (Container, Position)
6836 @key[or else raise] Program_Error),
6837 Post => Tampering_With_Cursors_Prohibited (Container),
6838 Nonblocking, Global => (@key[null], @key[use null])],Old=[]};]}
6839
6840 @ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]}
6841 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6842 @ChgAdded{Version=[3],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} Set; Source : @key{in} Set)@Chg{Version=[5],New=[
6843 @key[with] Pre => @key[not] Tampering_With_Cursors_Prohibited (Target)
6844 @key[or else raise] Program_Error,
6845 Post => Length (Source) = Length (Target)],Old=[]};]}
6846
6847 @ChgRef{Version=[3],Kind=[Added],Aref=[AI05-0001-1]}
6848 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
6849 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Copy} (Source : Set) @key[return] Set@Chg{Version=[5],New=[
6850 @key[with] Post => Length (Copy'Result) = Length (Source) @key[and then]
6851 @key[not] Tampering_With_Cursors_Prohibited (Copy'Result)],Old=[]};]}
6852
6853 @ChgRef{Version=[2],Kind=[AddedNormal]}
6854 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6855 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Move} (Target : @key{in out} Set;
6856 Source : @key{in out} Set)@Chg{Version=[5],New=[
6857 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Target)
6858 @key{or else raise} Program_Error) @key{and then}
6859 (@key{not} Tampering_With_Cursors_Prohibited (Source)
6860 @key{or else raise} Program_Error),
6861 Post => (@key{if} Target = Source @key{then} True
6862 @key{else}
6863 Length (Target) = Length (Source'Old) @key{and then}
6864 Length (Source) = 0)],Old=[]};]}
6865
6866 @ChgRef{Version=[2],Kind=[AddedNormal]}
6867 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6868 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Set;
6869 New_Item : @key{in} Element_Type;
6870 Position : @key{out} Cursor;
6871 Inserted : @key{out} Boolean)@Chg{Version=[5],New=[
6872 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
6873 @key{or else raise} Program_Error) @key{and then}
6874 (Length (Container) <= Count_Type'Last - 1
6875 @key{or else raise} Constraint_Error),
6876 Post => (@key{declare}
6877 Original_Length : @key{constant} Count_Type :=
6878 Length (Container)'Old;
6879 @key{begin}
6880 Has_Element (Container, Position) @key{and then}
6881 (@key{if} Inserted then
6882 Length (Container) = Original_Length + 1
6883 @key{else}
6884 Length (Container) = Original_Length))],Old=[]};]}
6885
6886 @ChgRef{Version=[2],Kind=[AddedNormal]}
6887 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6888 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Insert} (Container : @key{in out} Set;
6889 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
6890 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
6891 @key{or else raise} Program_Error) @key{and then}
6892 (Length (Container) <= Count_Type'Last - 1
6893 @key{or else raise} Constraint_Error),
6894 Post => Length (Container) = Length (Container)'Old + 1],Old=[]};]}
6895
6896 @ChgRef{Version=[2],Kind=[AddedNormal]}
6897 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6898 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Include} (Container : @key{in out} Set;
6899 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
6900 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
6901 @key{or else raise} Program_Error) @key{and then}
6902 (Length (Container) <= Count_Type'Last - 1
6903 @key{or else raise} Constraint_Error),
6904 Post => (@key{declare}
6905 Original_Length : @key{constant} Count_Type :=
6906 Length (Container)'Old;
6907 @key{begin}
6908 Length (Container)
6909 @key{in} Original_Length | Original_Length + 1)],Old=[]};]}
6910
6911 @ChgRef{Version=[2],Kind=[AddedNormal]}
6912 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6913 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace} (Container : @key{in out} Set;
6914 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
6915 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
6916 @key{or else raise} Program_Error,
6917 Post => Length (Container) = Length (Container)'Old],Old=[]};]}
6918
6919 @ChgRef{Version=[2],Kind=[AddedNormal]}
6920 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6921 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Exclude} (Container : @key{in out} Set;
6922 Item : @key{in} Element_Type)@Chg{Version=[5],New=[
6923 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
6924 @key{or else raise} Program_Error,
6925 Post => (@key{declare}
6926 Original_Length : @key{constant} Count_Type :=
6927 Length (Container)'Old;
6928 @key{begin}
6929 Length (Container)
6930 @key{in} Original_Length - 1 | Original_Length)],Old=[]};]}
6931
6932 @ChgRef{Version=[2],Kind=[AddedNormal]}
6933 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6934 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Set;
6935 Item : @key{in} Element_Type)@Chg{Version=[5],New=[
6936 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
6937 @key{or else raise} Program_Error,
6938 Post => Length (Container) = Length (Container)'Old - 1],Old=[]};]}
6939
6940 @ChgRef{Version=[2],Kind=[AddedNormal]}
6941 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6942 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Set;
6943 Position : @key{in out} Cursor)@Chg{Version=[5],New=[
6944 @key{with} Pre => (@key{not} Tampering_With_Cursors_Prohibited (Container)
6945 @key{or else raise} Program_Error) @key{and then}
6946 (Position /= No_Element
6947 @key{or else raise} Constraint_Error) @key{and then}
6948 (Has_Element (Container, Position)
6949 @key{or else raise} Program_Error),
6950 Post => Length (Container) = Length (Container)'Old - 1 @key{and then}
6951 Position = No_Element],Old=[]};]}
6952
6953 @ChgRef{Version=[2],Kind=[AddedNormal]}
6954 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6955 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_First} (Container : @key{in out} Set)@Chg{Version=[5],New=[
6956 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
6957 @key{or else raise} Program_Error,
6958 Post => (@key{declare}
6959 Original_Length : @key{constant} Count_Type :=
6960 Length (Container)'Old;
6961 @key{begin}
6962 (@key{if} Original_Length = 0 @key{then} Length (Container) = 0
6963 @key{else} Length (Container) = Original_Length - 1))],Old=[]};]}
6964
6965 @ChgRef{Version=[2],Kind=[AddedNormal]}
6966 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6967 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete_Last} (Container : @key{in out} Set)@Chg{Version=[5],New=[
6968 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
6969 @key{or else raise} Program_Error,
6970 Post => (@key{declare}
6971 Original_Length : @key{constant} Count_Type :=
6972 Length (Container)'Old;
6973 @key{begin}
6974 (@key{if} Original_Length = 0 @key{then} Length (Container) = 0
6975 @key{else} Length (Container) = Original_Length - 1))],Old=[]};]}
6976
6977 @ChgRef{Version=[2],Kind=[AddedNormal]}
6978 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6979 @ChgAdded{Version=[2],Text=[ @key{procedure} Union (Target : @key{in out} Set;
6980 Source : @key{in} Set)@Chg{Version=[5],New=[
6981 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Target)
6982 @key{or else raise} Program_Error,
6983 Post => Length (Target) <= Length (Target)'Old + Length (Source)],Old=[]};]}
6984
6985 @ChgRef{Version=[2],Kind=[AddedNormal]}
6986 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6987 @ChgAdded{Version=[2],Text=[ @key{function} Union (Left, Right : Set) @key{return} Set@Chg{Version=[5],New=[
6988 @key{with} Post => Length (Union'Result) <= Length (Left) + Length (Right) @key{and then}
6989 @key{not} Tampering_With_Cursors_Prohibited (Union'Result)],Old=[]};]}
6990
6991 @ChgRef{Version=[2],Kind=[AddedNormal]}
6992 @ChgAdded{Version=[2],Text=[ @key{function} "@key{or}" (Left, Right : Set) @key{return} Set @key{renames} Union;]}
6993
6994 @ChgRef{Version=[2],Kind=[AddedNormal]}
6995 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
6996 @ChgAdded{Version=[2],Text=[ @key{procedure} Intersection (Target : @key{in out} Set;
6997 Source : @key{in} Set)@Chg{Version=[5],New=[
6998 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Target)
6999 @key{or else raise} Program_Error,
7000 Post => Length (Target) <= Length (Target)'Old + Length (Source)],Old=[]};]}
7001
7002 @ChgRef{Version=[2],Kind=[AddedNormal]}
7003 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7004 @ChgAdded{Version=[2],Text=[ @key{function} Intersection (Left, Right : Set) @key{return} Set@Chg{Version=[5],New=[
7005 @key{with} Post => Length (Intersection'Result) <= Length (Left) + Length (Right) @key{and then}
7006 @key{not} Tampering_With_Cursors_Prohibited (Intersection'Result)],Old=[]};]}
7007
7008 @ChgRef{Version=[2],Kind=[AddedNormal]}
7009 @ChgAdded{Version=[2],Text=[ @key{function} "@key{and}" (Left, Right : Set) @key{return} Set @key{renames} Intersection;]}
7010
7011 @ChgRef{Version=[2],Kind=[AddedNormal]}
7012 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7013 @ChgAdded{Version=[2],Text=[ @key{procedure} Difference (Target : @key{in out} Set;
7014 Source : @key{in} Set)@Chg{Version=[5],New=[
7015 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Target)
7016 @key{or else raise} Program_Error,
7017 Post => Length (Target) <= Length (Target)'Old + Length (Source)],Old=[]};]}
7018
7019 @ChgRef{Version=[2],Kind=[AddedNormal]}
7020 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7021 @ChgAdded{Version=[2],Text=[ @key{function} Difference (Left, Right : Set) @key{return} Set@Chg{Version=[5],New=[
7022 @key{with} Post => Length (Difference'Result) <= Length (Left) + Length (Right) @key{and then}
7023 @key{not} Tampering_With_Cursors_Prohibited (Difference'Result)],Old=[]};]}
7024
7025 @ChgRef{Version=[2],Kind=[AddedNormal]}
7026 @ChgAdded{Version=[2],Text=[ @key{function} "-" (Left, Right : Set) @key{return} Set @key{renames} Difference;]}
7027
7028 @ChgRef{Version=[2],Kind=[AddedNormal]}
7029 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7030 @ChgAdded{Version=[2],Text=[ @key{procedure} Symmetric_Difference (Target : @key{in out} Set;
7031 Source : @key{in} Set)@Chg{Version=[5],New=[
7032 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Target)
7033 @key{or else raise} Program_Error,
7034 Post => Length (Target) <= Length (Target)'Old + Length (Source)],Old=[]};]}
7035
7036 @ChgRef{Version=[2],Kind=[AddedNormal]}
7037 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7038 @ChgAdded{Version=[2],Text=[ @key{function} Symmetric_Difference (Left, Right : Set) @key{return} Set@Chg{Version=[5],New=[
7039 @key{with} Post => Length (Symmetric_Difference'Result) <= Length (Left) + Length (Right) @key{and then}
7040 @key{not} Tampering_With_Cursors_Prohibited (Symmetric_Difference'Result)],Old=[]};]}
7041
7042 @ChgRef{Version=[2],Kind=[AddedNormal]}
7043 @ChgAdded{Version=[2],Text=[ @key{function} "@key{xor}" (Left, Right : Set) @key{return} Set @key{renames}
7044 Symmetric_Difference;]}
7045
7046 @ChgRef{Version=[2],Kind=[AddedNormal]}
7047 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Overlap} (Left, Right : Set) @key{return} Boolean;]}
7048
7049 @ChgRef{Version=[2],Kind=[AddedNormal]}
7050 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Is_Subset} (Subset : Set;
7051 Of_Set : Set) @key{return} Boolean;]}
7052
7053 @ChgRef{Version=[2],Kind=[AddedNormal]}
7054 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7055 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First} (Container : Set) @key{return} Cursor@Chg{Version=[5],New=[
7056 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
7057 Post => (@key{if not} Is_Empty (Container)
7058 @key{then} Has_Element (Container, First'Result)
7059 @key{else} First'Result = No_Element)],Old=[]};]}
7060
7061 @ChgRef{Version=[2],Kind=[AddedNormal]}
7062 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7063 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{First_Element} (Container : Set)
7064 @key{return} Element_Type@Chg{Version=[5],New=[
7065 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
7066
7067 @ChgRef{Version=[2],Kind=[AddedNormal]}
7068 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7069 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last} (Container : Set) @key{return} Cursor@Chg{Version=[5],New=[
7070 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
7071 Post => (@key{if} not Is_Empty (Container)
7072 @key{then} Has_Element (Container, Last'Result)
7073 @key{else} Last'Result = No_Element)],Old=[]};]}
7074
7075 @ChgRef{Version=[2],Kind=[AddedNormal]}
7076 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7077 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Last_Element} (Container : Set)
7078 @key{return} Element_Type@Chg{Version=[5],New=[
7079 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
7080
7081 @ChgRef{Version=[2],Kind=[AddedNormal]}
7082 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7083 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Next} (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
7084 @key{with} Nonblocking, Global => (@key{in all}, @key{use null}),
7085 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
7086 @key{else} True)],Old=[]};]}
7087
7088 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
7089 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Next} (Container : Set;
7090 Position : Cursor) @key{return} Cursor
7091 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
7092 Pre => Position = No_Element @key{or else}
7093 Has_Element (Container, Position)
7094 @key{or else raise} Program_Error,
7095 Post => (@key{if} Position = No_Element @key{then} Next'Result = No_Element
7096 @key{elsif} Next'Result = No_Element @key{then}
7097 Position = Last (Container)
7098 @key{else} Has_Element (Container, Next'Result));]}
7099
7100 @ChgRef{Version=[2],Kind=[AddedNormal]}
7101 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7102 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Next} (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
7103 @key{with} Nonblocking, Global => (@key{in all}, @key{use null})],Old=[]};]}
7104
7105 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
7106 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Next} (Container : @key{in} Set;
7107 Position : @key{in out} Cursor)
7108 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
7109 Pre => Position = No_Element @key{or else}
7110 Has_Element (Container, Position)
7111 @key{or else raise} Program_Error,
7112 Post => (@key{if} Position /= No_Element
7113 @key{then} Has_Element (Container, Position));]}
7114
7115 @ChgRef{Version=[2],Kind=[AddedNormal]}
7116 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7117 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Previous} (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
7118 @key{with} Nonblocking, Global => (@key{in all}, @key{use null}),
7119 Post => (@key{if} Position = No_Element @key{then}
7120 Previous'Result = No_Element
7121 @key{else} True)],Old=[]};]}
7122
7123 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
7124 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Previous} (Container : Set;
7125 Position : Cursor) @key{return} Cursor
7126 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
7127 Pre => Position = No_Element @key{or else}
7128 Has_Element (Container, Position)
7129 @key{or else raise} Program_Error,
7130 Post => (@key{if} Position = No_Element @key{then}
7131 Previous'Result = No_Element
7132 @key{elsif} Previous'Result = No_Element @key{then}
7133 Position = First (Container)
7134 @key{else} Has_Element (Container, Previous'Result));]}
7135
7136 @ChgRef{Version=[2],Kind=[AddedNormal]}
7137 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7138 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Previous} (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
7139 @key{with} Global => (@key{in all}, @key{use null}),
7140 Nonblocking => True],Old=[]};]}
7141
7142 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
7143 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Previous} (Container : @key{in} Set;
7144 Position : @key{in out} Cursor)
7145 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
7146 Pre => Position = No_Element @key{or else}
7147 Has_Element (Container, Position)
7148 @key{or else raise} Program_Error,
7149 Post => (@key{if} Position /= No_Element
7150 @key{then} Has_Element (Container, Position));]}
7151
7152 @ChgRef{Version=[2],Kind=[AddedNormal]}
7153 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7154 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Set;
7155 Item : Element_Type) @key{return} Cursor@Chg{Version=[5],New=[
7156 @key{with} Post => (@key{if} Find'Result = No_Element @key{then} True
7157 @key{else} Has_Element (Container, Find'Result))],Old=[]};]}
7158
7159 @ChgRef{Version=[2],Kind=[AddedNormal]}
7160 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Floor} (Container : Set;
7161 Item : Element_Type) @key{return} Cursor@Chg{Version=[5],New=[
7162 @key{with} Post => (@key{if} Floor'Result = No_Element @key{then} True
7163 @key{else} Has_Element (Container, Floor'Result))],Old=[]};]}
7164
7165 @ChgRef{Version=[2],Kind=[AddedNormal]}
7166 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Ceiling} (Container : Set;
7167 Item : Element_Type) @key{return} Cursor@Chg{Version=[5],New=[
7168 @key{with} Post => (@key{if} Ceiling'Result = No_Element @key{then} True
7169 @key{else} Has_Element (Container, Ceiling'Result))],Old=[]};]}
7170
7171 @ChgRef{Version=[2],Kind=[AddedNormal]}
7172 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Set;
7173 Item : Element_Type) @key{return} Boolean;]}
7174
7175 @ChgRef{Version=[2],Kind=[AddedNormal]}
7176 @ChgRef{Version=[3],Kind=[Deleted],ARef=[AI05-0212-1]}
7177 @ChgAdded{Version=[2],Text=[@Chg{Version=[3],New=[],Old=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean;]}]}
7178
7179
7180 @ChgRef{Version=[2],Kind=[AddedNormal]}
7181 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7182 @ChgAdded{Version=[2],Text=[ @key{function} "<" (Left, Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
7183 @key{with} Pre => (Left /= No_Element @key{and then} Right /= No_Element)
7184 @key{or else raise} Constraint_Error,
7185 Global => @key{in all}],Old=[]};]}
7186
7187 @ChgRef{Version=[2],Kind=[AddedNormal]}
7188 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7189 @ChgAdded{Version=[2],Text=[ @key{function} ">" (Left, Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
7190 @key{with} Pre => (Left /= No_Element @key{and then} Right /= No_Element)
7191 @key{or else raise} Constraint_Error,
7192 Global => @key{in all}],Old=[]};]}
7193
7194 @ChgRef{Version=[2],Kind=[AddedNormal]}
7195 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7196 @ChgAdded{Version=[2],Text=[ @key{function} "<" (Left : Cursor; Right : Element_Type) @key{return} Boolean@Chg{Version=[5],New=[
7197 @key{with} Pre => Left /= No_Element @key{or else raise} Constraint_Error,
7198 Global => @key{in all}],Old=[]};]}
7199
7200 @ChgRef{Version=[2],Kind=[AddedNormal]}
7201 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7202 @ChgAdded{Version=[2],Text=[ @key{function} ">" (Left : Cursor; Right : Element_Type) @key{return} Boolean@Chg{Version=[5],New=[
7203 @key{with} Pre => Left /= No_Element @key{or else raise} Constraint_Error,
7204 Global => @key{in all}],Old=[]};]}
7205
7206 @ChgRef{Version=[2],Kind=[AddedNormal]}
7207 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7208 @ChgAdded{Version=[2],Text=[ @key{function} "<" (Left : Element_Type; Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
7209 @key{with} Pre => Right /= No_Element @key{or else raise} Constraint_Error,
7210 Global => @key{in all}],Old=[]};]}
7211
7212 @ChgRef{Version=[2],Kind=[AddedNormal]}
7213 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7214 @ChgAdded{Version=[2],Text=[ @key{function} ">" (Left : Element_Type; Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
7215 @key{with} Pre => Right /= No_Element @key{or else raise} Constraint_Error,
7216 Global => @key{in all}],Old=[]};]}
7217
7218 @ChgRef{Version=[2],Kind=[AddedNormal]}
7219 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7220 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Iterate}
7221 (Container : @key{in} Set;
7222 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
7223 @key{with} Allows_Exit],Old=[]};]}
7224
7225
7226 @ChgRef{Version=[2],Kind=[AddedNormal]}
7227 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7228 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Reverse_Iterate}
7229 (Container : @key{in} Set;
7230 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
7231 @key{with} Allows_Exit],Old=[]};]}
7232
7233 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
7234 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1],ARef=[AI12-0266-1]}
7235 @ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] Set)
7236 @key[return] Set_Iterator_Interfaces.@Chg{Version=[5],New=[Parallel_Reversible_Iterator],Old=[Reversible_Iterator]}'Class@Chg{Version=[5],New=[
7237 @key[with] Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
7238
7239 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0262-1]}
7240 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
7241 @ChgAdded{Version=[3],Text=[ @key[function] Iterate (Container : @key[in] Set; Start : @key[in] Cursor)
7242 @key[return] Set_Iterator_Interfaces.Reversible_Iterator'Class@Chg{Version=[5],New=[
7243 @key[with] Pre => (Start /= No_Element
7244 @key[or else raise] Constraint_Error) @key[and then]
7245 (Has_Element (Container, Start)
7246 @key[or else raise] Program_Error),
7247 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
7248
7249 @ChgRef{Version=[2],Kind=[AddedNormal]}
7250 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7251 @ChgAdded{Version=[2],Text=[ @key{generic}
7252 @key{type} Key_Type (<>) @key{is private};
7253 @key{with function} Key (Element : Element_Type) @key{return} Key_Type;
7254 @key{with function} "<" (Left, Right : Key_Type)
7255 @key{return} Boolean @key{is} <>;
7256 @key{package} @AdaPackDefn{Generic_Keys}@Chg{Version=[5],New=[
7257 @key[with] Nonblocking, Global => @key[null]],Old=[]} @key{is}]}
7258
7259 @ChgRef{Version=[2],Kind=[AddedNormal]}
7260 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Equivalent_Keys} (Left, Right : Key_Type)
7261 @key{return} Boolean;]}
7262
7263 @ChgRef{Version=[2],Kind=[AddedNormal]}
7264 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7265 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Key} (Position : Cursor) @key{return} Key_Type@Chg{Version=[5],New=[
7266 @key{with} Pre => Position /= No_Element @key{or else raise} Constraint_Error,
7267 Global => @key{in all}],Old=[]};]}
7268
7269 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
7270 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Key} (Container : Set;
7271 Position : Cursor) @key{return} Key_Type
7272 @key{with} Pre => (Position /= No_Element
7273 @key{or else raise} Constraint_Error) @key{and then}
7274 (Has_Element (Container, Position)
7275 @key{or else raise} Program_Error);]}
7276
7277 @ChgRef{Version=[2],Kind=[AddedNormal]}
7278 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Element} (Container : Set;
7279 Key : Key_Type)
7280 @key{return} Element_Type;]}
7281
7282 @ChgRef{Version=[2],Kind=[AddedNormal]}
7283 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7284 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Replace} (Container : @key{in out} Set;
7285 Key : @key{in} Key_Type;
7286 New_Item : @key{in} Element_Type)@Chg{Version=[5],New=[
7287 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
7288 @key{or else raise} Program_Error,
7289 Post => Length (Container) = Length (Container)'Old],Old=[]};]}
7290
7291 @ChgRef{Version=[2],Kind=[AddedNormal]}
7292 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7293 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Exclude} (Container : @key{in out} Set;
7294 Key : @key{in} Key_Type)@Chg{Version=[5],New=[
7295 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
7296 @key{or else raise} Program_Error,
7297 Post => (@key{declare}
7298 Original_Length : @key{constant} Count_Type :=
7299 Length (Container)'Old;
7300 @key{begin}
7301 Length (Container) @key{in} Original_Length - 1 | Original_Length)],Old=[]};]}
7302
7303 @ChgRef{Version=[2],Kind=[AddedNormal]}
7304 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7305 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Delete} (Container : @key{in out} Set;
7306 Key : @key{in} Key_Type)@Chg{Version=[5],New=[
7307 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
7308 @key{or else raise} Program_Error,
7309 Post => Length (Container) = Length (Container)'Old - 1],Old=[]};]}
7310
7311 @ChgRef{Version=[2],Kind=[AddedNormal]}
7312 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7313 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Find} (Container : Set;
7314 Key : Key_Type)
7315 @key{return} Cursor@Chg{Version=[5],New=[
7316 @key{with} Post => (@key{if} Find'Result = No_Element @key{then} True
7317 @key{else} Has_Element (Container, Find'Result))],Old=[]};]}
7318
7319 @ChgRef{Version=[2],Kind=[AddedNormal]}
7320 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7321 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Floor} (Container : Set;
7322 Key : Key_Type)
7323 @key{return} Cursor@Chg{Version=[5],New=[
7324 @key{with} Post => (@key{if} Floor'Result = No_Element @key{then} True
7325 @key{else} Has_Element (Container, Floor'Result))],Old=[]};]}
7326
7327 @ChgRef{Version=[2],Kind=[AddedNormal]}
7328 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7329 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Ceiling} (Container : Set;
7330 Key : Key_Type)
7331 @key{return} Cursor@Chg{Version=[5],New=[
7332 @key{with} Post => (@key{if} Ceiling'Result = No_Element @key{then} True
7333 @key{else} Has_Element (Container, Ceiling'Result))],Old=[]};]}
7334
7335 @ChgRef{Version=[2],Kind=[AddedNormal]}
7336 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Contains} (Container : Set;
7337 Key : Key_Type) @key{return} Boolean;]}
7338
7339 @ChgRef{Version=[2],Kind=[AddedNormal]}
7340 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7341 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Update_Element_Preserving_Key}
7342 (Container : @key{in out} Set;
7343 Position : @key{in} Cursor;
7344 Process : @key{not null access procedure}
7345 (Element : @key{in out} Element_Type))@Chg{Version=[5],New=[
7346 @key{with} Pre => (Position /= No_Element @key{or else}
7347 @key{raise} Constraint_Error) @key{and then}
7348 (Has_Element (Container, Position) @key{or else raise} Program_Error)],Old=[]};]}
7349
7350 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
7351 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
7352 @ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Reference_Type}
7353 (Element : @key[not null access] Element_Type) @key[is private]
7354 @key[with] Implicit_Dereference => Element@Chg{Version=[5],New=[,
7355 Nonblocking, Global => @key[in out synchronized],
7356 Default_Initial_Condition => (@key[raise] Program_Error)],Old=[]};]}
7357
7358 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
7359 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
7360 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference_Preserving_Key} (Container : @key[aliased in out] Set;
7361 Position : @key[in] Cursor)
7362 @key[return] Reference_Type@Chg{Version=[5],New=[
7363 @key[with] Pre => (Position /= No_Element
7364 @key[or else raise] Constraint_Error) @key[and then]
7365 (Has_Element (Container, Position)
7366 @key[or else raise] Program_Error),
7367 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
7368
7369 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
7370 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
7371 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Constant_Reference} (Container : @key[aliased in] Set;
7372 Key : @key[in] Key_Type)
7373 @key[return] Constant_Reference_Type@Chg{Version=[5],New=[
7374 @key[with] Pre => Find (Container, Key) /= No_Element @key[or else]
7375 @key[raise] Constraint_Error,
7376 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
7377
7378 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1]}
7379 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
7380 @ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Reference_Preserving_Key} (Container : @key[aliased in out] Set;
7381 Key : @key[in] Key_Type)
7382 @key[return] Reference_Type@Chg{Version=[5],New=[
7383 @key[with] Pre => Find (Container, Key) /= No_Element @key[or else]
7384 @key[raise] Constraint_Error,
7385 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
7386
7387 @ChgRef{Version=[2],Kind=[AddedNormal]}
7388 @ChgAdded{Version=[2],Text=[ @key{end} Generic_Keys;]}
7389
7390 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
7391 @ChgAdded{Version=[5],Text=[ @key{package} @AdaPackDefn{Stable} @key{is}]}
7392
7393 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1],ARef=[AI12-0339-1]}
7394 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Set} (Base : @key{not null access} Hashed_Sets.Set) @key{is}
7395 @key{tagged limited private}
7396 @key{with} Constant_Indexing => Constant_Reference,
7397 Default_Iterator => Iterate,
7398 Iterator_Element => Element_Type,
7399 Aggregate => (Empty => Empty,
7400 Add_Unnamed => Include),
7401 Stable_Properties => (Length),
7402 Global => @key[null],
7403 Default_Initial_Condition => Length (Set) = 0;
7404 @key{pragma} Preelaborable_Initialization(Set);]}
7405
7406 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
7407 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Cursor} @key{is private};
7408 @key{pragma} Preelaborable_Initialization(Cursor);]}
7409
7410 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
7411 @ChgAdded{Version=[5],Text=[ @AdaObjDefn{Empty_Set} : @key{constant} Set;]}
7412
7413 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
7414 @ChgAdded{Version=[5],Text=[ @AdaObjDefn{No_Element} : @key{constant} Cursor;]}
7415
7416 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
7417 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Has_Element} (Position : Cursor) @key{return} Boolean
7418 @key{with} Nonblocking, Global => (@key{in all}, @key{use null});]}
7419
7420 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
7421 @ChgAdded{Version=[5],Text=[ @key{package} @AdaPackDefn{Set_Iterator_Interfaces} @key[is new]
7422 Ada.Iterator_Interfaces (Cursor, Has_Element);]}
7423
7424 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
7425 @ChgAdded{Version=[5],Text=[ @key{procedure} @AdaSubDefn{Assign} (Target : @key{in out} Hashed_Sets.Set;
7426 Source : @key{in} Set)
7427 @key{with} Post => Length (Source) = Length (Target);]}
7428
7429 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
7430 @ChgAdded{Version=[5],Text=[ @key{function} @AdaSubDefn{Copy} (Source : Hashed_Sets.Set) @key{return} Set
7431 @key{with} Post => Length (Copy'Result) = Length (Source);]}
7432
7433 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
7434 @ChgAdded{Version=[5],Text=[ @key{type} @AdaTypeDefn{Constant_Reference_Type}
7435 (Element : @key{not null access constant} Element_Type) @key{is private}
7436 @key{with} Implicit_Dereference => Element,
7437 Nonblocking, Global => (@key{null}, @key{use null}),
7438 Default_Initial_Condition => (@key{raise} Program_Error);]}
7439
7440 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
7441 @ChgAdded{Version=[5],Text=[ -- @examcom{Additional subprograms as described in the text}
7442 -- @examcom{are declared here.}]}
7443
7444 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
7445 @ChgAdded{Version=[5],Text=[ @key{private}]}
7446
7447 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
7448 @ChgAdded{Version=[5],Text=[ ... -- @Examcom{not specified by the language}]}
7449
7450 @ChgRef{Version=[5],Kind=[Added],ARef=[AI05-0111-1]}
7451 @ChgAdded{Version=[5],Text=[ @key{end} Stable;]}
7452
7453
7454 @ChgRef{Version=[2],Kind=[AddedNormal]}
7455 @ChgAdded{Version=[2],Text=[@key{private}]}
7456
7457 @ChgRef{Version=[2],Kind=[AddedNormal]}
7458 @ChgAdded{Version=[2],Text=[ ... -- @RI[not specified by the language]]}
7459
7460 @ChgRef{Version=[2],Kind=[AddedNormal]}
7461 @ChgAdded{Version=[2],Text=[@key{end} Ada.Containers.Ordered_Sets;]}
7462 @end{Example}
7463
7464 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7465 @ChgAdded{Version=[2],Text=[Two elements @i<E1> and @i<E2> are @i<equivalent>
7466 if both @i<E1> < @i<E2> and @i<E2> < @i<E1> return False, using the generic
7467 formal "<" operator for elements.@Defn2{Term=[equivalent element],Sec=[of an ordered set]}
7468 Function Equivalent_Elements returns True if Left and Right are equivalent,
7469 and False otherwise.]}
7470
7471 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7472 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0044-1]}
7473 @ChgAdded{Version=[2],Text=[The actual function for the generic formal function
7474 "<" on Element_Type values is expected to return the same value each time it is
7475 called with a particular pair of key values. It should define a strict
7476 @Chg{Version=[3],New=[weak ],Old=[]}ordering relationship@Chg{Version=[3],
7477 New=[ (see @RefSecNum{Containers})],Old=[, that is, be irreflexive, asymmetric,
7478 and transitive]}. If the
7479 actual for "<" behaves in some other manner, the behavior of this package is
7480 unspecified. Which subprograms of this package call "<" and how many times they
7481 call it, is unspecified.@PDefn{unspecified}]}
7482
7483 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0044-1]}
7484 @ChgAdded{Version=[3],Text=[If the actual function for the generic formal
7485 function "=" returns True for any pair of nonequivalent elements, then the
7486 behavior of the container function "=" is unspecified.@PDefn{unspecified}]}
7487
7488 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7489 @ChgAdded{Version=[2],Text=[If the value of an element stored in a set is changed
7490 other than by an operation in this package such that at least one of
7491 "<" or "=" give different
7492 results, the behavior of this package is unspecified.@PDefn{unspecified}]}
7493
7494 @begin{Discussion}
7495 @ChgRef{Version=[2],Kind=[AddedNormal]}
7496 @ChgAdded{Version=[2],Text=[See @RefSec{The Generic Package Containers.Ordered_Maps}
7497 for a suggested implementation, and for justification of the restrictions
7498 regarding "<" and "=". Note that sets only need to store elements, not
7499 key/element pairs.]}
7500 @end{Discussion}
7501
7502 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7503 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]}
7504 @ChgAdded{Version=[2],Text=[@Defn2{Term=[first element],Sec=[of an ordered set]}
7505 @Defn2{Term=[last element],Sec=[of an ordered set]}
7506 @Defn2{Term=[successor element],Sec=[of an ordered set]}@Chg{Version=[3],New=[
7507 @Defn2{Term=[predecessor element],Sec=[of an ordered set]}],Old=[]}
7508 The @Chg{Version=[3],New=[@i<first element>],Old=[first element]}
7509 of a nonempty set is the one
7510 which is less than all the other elements in the set.
7511 The @Chg{Version=[3],New=[@i<last element>],Old=[last element]} of a
7512 nonempty set is the one which is greater than all the other elements in the
7513 set. The @Chg{Version=[3],New=[@i<successor>],Old=[successor]}
7514 of an element is the smallest element that is larger than
7515 the given element. The @Chg{Version=[3],New=[@i<predecessor>],Old=[predecessor]}
7516 of an element is the largest element that is
7517 smaller than the given element. All comparisons are done using the generic
7518 formal "<" operator for elements.]}
7519
7520 @begin{DescribeCode}
7521
7522 @begin{Example}
7523 @ChgRef{Version=[3],Kind=[Added]}
7524 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
7525 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Copy (Source : Set) @key[return] Set@Chg{Version=[5],New=[
7526 @key[with] Post => Length (Copy'Result) = Length (Source) @key[and then]
7527 @key[not] Tampering_With_Cursors_Prohibited (Copy'Result)],Old=[]};]}
7528 @end{Example}
7529
7530 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1]}
7531 @ChgAdded{Version=[3],Type=[Trailing],Text=[Returns a set whose
7532 elements are initialized from the corresponding elements of Source.]}
7533
7534 @begin{Example}
7535 @ChgRef{Version=[2],Kind=[AddedNormal]}
7536 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7537 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_First (Container : @key{in out} Set)@Chg{Version=[5],New=[
7538 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
7539 @key{or else raise} Program_Error,
7540 Post => (@key{declare}
7541 Original_Length : @key{constant} Count_Type :=
7542 Length (Container)'Old;
7543 @key{begin}
7544 (@key{if} Original_Length = 0 @key{then} Length (Container) = 0
7545 @key{else} Length (Container) = Original_Length - 1))],Old=[]};]}
7546 @end{Example}
7547
7548
7549 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7550 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
7551 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Delete_First
7552 has no effect. Otherwise@Chg{Version=[3],New=[,],Old=[]}
7553 the element designated by First (Container) is removed
7554 from Container. Delete_First tampers with the cursors of Container.]}
7555
7556 @begin{Example}
7557 @ChgRef{Version=[2],Kind=[AddedNormal]}
7558 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7559 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Delete_Last (Container : @key{in out} Set)@Chg{Version=[5],New=[
7560 @key{with} Pre => @key{not} Tampering_With_Cursors_Prohibited (Container)
7561 @key{or else raise} Program_Error,
7562 Post => (@key{declare}
7563 Original_Length : @key{constant} Count_Type :=
7564 Length (Container)'Old;
7565 @key{begin}
7566 (@key{if} Original_Length = 0 @key{then} Length (Container) = 0
7567 @key{else} Length (Container) = Original_Length - 1))],Old=[]};]}
7568 @end{Example}
7569
7570 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7571 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
7572 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Container is empty, Delete_Last
7573 has no effect. Otherwise@Chg{Version=[3],New=[,],Old=[]}
7574 the element designated by Last (Container) is removed
7575 from Container. Delete_Last tampers with the cursors of Container.]}
7576
7577 @begin{Example}
7578 @ChgRef{Version=[2],Kind=[AddedNormal]}
7579 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7580 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} First_Element (Container : Set)
7581 @key{return} Element_Type@Chg{Version=[5],New=[
7582 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
7583 @end{Example}
7584
7585 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7586 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to
7587 Element (First (Container)).]}
7588
7589 @begin{Example}
7590 @ChgRef{Version=[2],Kind=[AddedNormal]}
7591 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7592 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last (Container : Set) @key{return} Cursor@Chg{Version=[5],New=[
7593 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
7594 Post => (@key{if} not Is_Empty (Container)
7595 @key{then} Has_Element (Container, Last'Result)
7596 @key{else} Last'Result = No_Element)],Old=[]};]}
7597 @end{Example}
7598
7599 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7600 @ChgAdded{Version=[2],Type=[Trailing],Text=[Returns a cursor that designates
7601 the last element in Container. If Container is empty, returns No_Element.]}
7602
7603 @begin{Example}
7604 @ChgRef{Version=[2],Kind=[AddedNormal]}
7605 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7606 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Last_Element (Container : Set)
7607 @key{return} Element_Type@Chg{Version=[5],New=[
7608 @key{with} Pre => (@key{if} Is_Empty (Container) @key{then raise} Constraint_Error)],Old=[]};]}
7609 @end{Example}
7610
7611 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7612 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to
7613 Element (Last (Container)).]}
7614
7615 @begin{Example}
7616 @ChgRef{Version=[2],Kind=[AddedNormal]}
7617 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7618 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Previous (Position : Cursor) @key{return} Cursor@Chg{Version=[5],New=[
7619 @key{with} Nonblocking, Global => (@key{in all}, @key{use null}),
7620 Post => (@key{if} Position = No_Element @key{then}
7621 Previous'Result = No_Element
7622 @key{else} True)],Old=[]};]}
7623 @end{Example}
7624
7625 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7626 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0262-1]}
7627 @ChgAdded{Version=[2],Type=[Trailing],Text=[If Position equals No_Element, then
7628 Previous returns No_Element. Otherwise@Chg{Version=[3],New=[,],Old=[]}
7629 Previous returns a cursor designating
7630 the @Chg{Version=[3],New=[predecessor ],Old=[]}element
7631 @Chg{Version=[3],New=[of],Old=[that precedes]} the one designated by Position.
7632 If Position designates the first element, then Previous returns No_Element.]}
7633
7634 @begin{Example}
7635 @ChgRef{Version=[5],Kind=[Added]}
7636 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{function} Previous (Container : Set;
7637 Position : Cursor) @key{return} Cursor
7638 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
7639 Pre => Position = No_Element @key{or else}
7640 Has_Element (Container, Position)
7641 @key{or else raise} Program_Error,
7642 Post => (@key{if} Position = No_Element @key{then}
7643 Previous'Result = No_Element
7644 @key{elsif} Previous'Result = No_Element @key{then}
7645 Position = First (Container)
7646 @key{else} Has_Element (Container, Previous'Result));]}
7647 @end{Example}
7648
7649 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
7650 @ChgAdded{Version=[5],Type=[Trailing],Text=[Returns a cursor designating the
7651 predecessor of the node designated by Position in Container, if any.]}
7652
7653 @begin{Example}
7654 @ChgRef{Version=[2],Kind=[AddedNormal]}
7655 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7656 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Previous (Position : @key{in out} Cursor)@Chg{Version=[5],New=[
7657 @key{with} Nonblocking, Global => (@key{in all}, @key{use null})],Old=[]};]}
7658 @end{Example}
7659
7660 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7661 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Position := Previous (Position).]}
7662
7663 @begin{Example}
7664 @ChgRef{Version=[5],Kind=[Added]}
7665 @ChgAdded{Version=[5],KeepNext=[T],Text=[@key{procedure} Previous (Container : @key{in} Set;
7666 Position : @key{in out} Cursor)
7667 @key{with} Nonblocking, Global => (@key{null}, @key{use null}),
7668 Pre => Position = No_Element @key{or else}
7669 Has_Element (Container, Position)
7670 @key{or else raise} Program_Error,
7671 Post => (@key{if} Position /= No_Element
7672 @key{then} Has_Element (Container, Position));]}
7673 @end{Example}
7674
7675 @ChgRef{Version=[5],Kind=[Added],ARef=[AI12-0112-1]}
7676 @ChgAdded{Version=[5],Type=[Trailing],Text=[Equivalent to Position :=
7677 Previous (Container, Position).]}
7678
7679 @begin{Example}
7680 @ChgRef{Version=[2],Kind=[AddedNormal]}
7681 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7682 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Floor (Container : Set;
7683 Item : Element_Type) @key{return} Cursor@Chg{Version=[5],New=[
7684 @key{with} Post => (@key{if} Floor'Result = No_Element @key{then} True
7685 @key{else} Has_Element (Container, Floor'Result))],Old=[]};]}
7686 @end{Example}
7687
7688 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7689 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
7690 @ChgAdded{Version=[2],Type=[Trailing],Text=[Floor searches for the last element
7691 which is not greater than Item. If such an element is found, a cursor that
7692 designates it is returned. Otherwise@Chg{Version=[3],New=[,],Old=[]}
7693 No_Element is returned.]}
7694
7695 @begin{Example}
7696 @ChgRef{Version=[2],Kind=[AddedNormal]}
7697 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7698 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Ceiling (Container : Set;
7699 Item : Element_Type) @key{return} Cursor@Chg{Version=[5],New=[
7700 @key{with} Post => (@key{if} Ceiling'Result = No_Element @key{then} True
7701 @key{else} Has_Element (Container, Ceiling'Result))],Old=[]};]}
7702 @end{Example}
7703
7704 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7705 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
7706 @ChgAdded{Version=[2],Type=[Trailing],Text=[Ceiling searches for the first
7707 element which is not less than Item. If such an element is found, a cursor that
7708 designates it is returned. Otherwise@Chg{Version=[3],New=[,],Old=[]}
7709 No_Element is returned.]}
7710
7711 @begin{Example}
7712 @ChgRef{Version=[2],Kind=[AddedNormal]}
7713 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7714 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "<" (Left, Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
7715 @key{with} Pre => (Left /= No_Element @key{and then} Right /= No_Element)
7716 @key{or else raise} Constraint_Error,
7717 Global => @key{in all}],Old=[]};]}
7718 @end{Example}
7719
7720 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7721 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Left) < Element (Right).]}
7722
7723 @begin{Example}
7724 @ChgRef{Version=[2],Kind=[AddedNormal]}
7725 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7726 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} ">" (Left, Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
7727 @key{with} Pre => (Left /= No_Element @key{and then} Right /= No_Element)
7728 @key{or else raise} Constraint_Error,
7729 Global => @key{in all}],Old=[]};]}
7730 @end{Example}
7731
7732 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7733 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Right) < Element (Left).]}
7734
7735 @begin{Example}
7736 @ChgRef{Version=[2],Kind=[AddedNormal]}
7737 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7738 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "<" (Left : Cursor; Right : Element_Type) @key{return} Boolean@Chg{Version=[5],New=[
7739 @key{with} Pre => Left /= No_Element @key{or else raise} Constraint_Error,
7740 Global => @key{in all}],Old=[]};]}
7741 @end{Example}
7742
7743 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7744 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Left) < Right.]}
7745
7746 @begin{Example}
7747 @ChgRef{Version=[2],Kind=[AddedNormal]}
7748 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7749 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} ">" (Left : Cursor; Right : Element_Type) @key{return} Boolean@Chg{Version=[5],New=[
7750 @key{with} Pre => Left /= No_Element @key{or else raise} Constraint_Error,
7751 Global => @key{in all}],Old=[]};]}
7752 @end{Example}
7753
7754 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7755 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Right < Element (Left).]}
7756
7757 @begin{Example}
7758 @ChgRef{Version=[2],Kind=[AddedNormal]}
7759 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7760 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "<" (Left : Element_Type; Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
7761 @key{with} Pre => Right /= No_Element @key{or else raise} Constraint_Error,
7762 Global => @key{in all}],Old=[]};]}
7763 @end{Example}
7764
7765 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7766 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Left < Element (Right).]}
7767
7768 @begin{Example}
7769 @ChgRef{Version=[2],Kind=[AddedNormal]}
7770 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7771 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} ">" (Left : Element_Type; Right : Cursor) @key{return} Boolean@Chg{Version=[5],New=[
7772 @key{with} Pre => Right /= No_Element @key{or else raise} Constraint_Error,
7773 Global => @key{in all}],Old=[]};]}
7774 @end{Example}
7775
7776 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7777 @ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Element (Right) < Left.]}
7778
7779 @begin{Example}
7780 @ChgRef{Version=[2],Kind=[AddedNormal]}
7781 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0112-1]}
7782 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Reverse_Iterate
7783 (Container : @key{in} Set;
7784 Process : @key{not null access procedure} (Position : @key{in} Cursor))@Chg{Version=[5],New=[
7785 @key{with} Allows_Exit],Old=[]};]}
7786 @end{Example}
7787
7788 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7789 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0212-1]}
7790 @ChgAdded{Version=[2],Type=[Trailing],Text=[Iterates over the elements in
7791 Container as per @Chg{Version=[3],New=[procedure ],Old=[]}Iterate,
7792 with the difference that the elements are traversed
7793 in predecessor order, starting with the last element.]}
7794
7795 @begin{Example}
7796 @ChgRef{Version=[3],Kind=[Added]}
7797 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1],ARef=[AI12-0266-1]}
7798 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Set)
7799 @key[return] Set_Iterator_Interfaces.@Chg{Version=[5],New=[Parallel_Reversible_Iterator],Old=[Reversible_Iterator]}'Class@Chg{Version=[5],New=[
7800 @key[with] Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
7801 @end{Example}
7802
7803 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0212-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]}
7804 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0266-1]}
7805 @ChgAdded{Version=[3],Type=[Trailing],Text=[Iterate returns
7806 @Chg{Version=[5],New=[an],Old=[a reversible]}
7807 iterator object (see @RefSecNum{User-Defined Iterator Types}) that
7808 will generate a value for a loop parameter
7809 (see @RefSecNum{Generalized Loop Iteration}) designating
7810 each element in Container, starting with the first element and moving the cursor
7811 according to the successor relation when used as a forward iterator, and
7812 starting with the last element and moving the cursor according to the
7813 predecessor relation when used as a reverse iterator@Chg{Version=[5],New=[, and
7814 processing all nodes concurrently when used as a parallel iterator],Old=[]}.
7815 Tampering with the cursors of Container is prohibited while
7816 the iterator object exists (in particular, in
7817 the @nt{sequence_of_statements} of the @nt{loop_statement} whose
7818 @nt{iterator_specification} denotes this object). The iterator object needs
7819 finalization.]}
7820
7821 @begin{Example}
7822 @ChgRef{Version=[3],Kind=[Added]}
7823 @ChgRef{Version=[5],Kind=[RevisedAdded]}
7824 @ChgAdded{Version=[3],KeepNext=[T],Text=[@key[function] Iterate (Container : @key[in] Set; Start : @key[in] Cursor)
7825 @key[return] Set_Iterator_Interfaces.Reversible_Iterator'Class@Chg{Version=[5],New=[
7826 @key[with] Pre => (Start /= No_Element
7827 @key[or else raise] Constraint_Error) @key[and then]
7828 (Has_Element (Container, Start)
7829 @key[or else raise] Program_Error),
7830 Post => Tampering_With_Cursors_Prohibited (Container)],Old=[]};]}
7831 @end{Example}
7832
7833 @ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0262-1],ARef=[AI05-0265-1],ARef=[AI05-0269-1]}
7834 @ChgRef{Version=[5],Kind=[RevisedAdded],ARef=[AI12-0112-1]}
7835 @ChgAdded{Version=[3],Type=[Trailing],Text=[@Chg{Version=[5],New=[],Old=[If
7836 Start is not No_Element and does
7837 not designate an item in Container, then Program_Error is propagated. If Start
7838 is No_Element, then Constraint_Error is propagated. Otherwise, ]}Iterate returns
7839 a reversible
7840 iterator object (see @RefSecNum{User-Defined Iterator Types}) that
7841 will generate a value for a loop parameter
7842 (see @RefSecNum{Generalized Loop Iteration}) designating
7843 each element in Container, starting with the element designated by Start and
7844 moving the cursor according to the successor relation when used as a forward
7845 iterator, or moving the cursor according to the predecessor relation when used
7846 as a reverse iterator. Tampering with the
7847 cursors of Container is prohibited while the iterator object exists (in
7848 particular, in the @nt{sequence_of_statements} of the @nt{loop_statement} whose
7849 @nt{iterator_specification} denotes this object). The iterator object needs
7850 finalization.]}
7851
7852 @begin{Discussion}
7853 @ChgRef{Version=[3],Kind=[AddedNormal]}
7854 @ChgAdded{Version=[3],Type=[Leading],Text=[Exits are allowed from the loops
7855 created using the iterator objects. In particular, to stop the iteration at a
7856 particular cursor, just add]}
7857 @begin{Example}
7858 @ChgRef{Version=[3],Kind=[AddedNormal]}
7859 @ChgAdded{Version=[3],Text=[@key[exit when] Cur = Stop;]}
7860 @end{Example}
7861 @ChgRef{Version=[3],Kind=[AddedNormal]}
7862 @ChgAdded{Version=[3],Type=[Trailing],Text=[in the body of the loop (assuming
7863 that @exam{Cur} is the loop parameter and @exam{Stop} is the cursor that you
7864 want to stop at).]}
7865 @end{Discussion}
7866 @end{DescribeCode}
7867
7868 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7869 @ChgAdded{Version=[2],Text=[For any two elements @i<E1> and @i<E2>, the
7870 boolean values (@i<E1> < @i<E2>) and (Key(@i<E1>) < Key(@i<E2>)) are expected
7871 to be equal. If the actuals for Key or Generic_Keys."<" behave in some other
7872 manner, the behavior of this package is unspecified. Which subprograms of this
7873 package call Key and Generic_Keys."<", and how many times the functions are
7874 called, is unspecified.@PDefn{unspecified}]}
7875
7876 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7877 @ChgAdded{Version=[2],Text=[In addition to the semantics described in
7878 @RefSecNum{Sets}, the subprograms in package Generic_Keys named
7879 Floor and Ceiling, are equivalent to the corresponding subprograms in the
7880 parent package, with the difference that the
7881 Key subprogram parameter is compared to elements in the container using the
7882 Key and "<" generic formal functions. The function named Equivalent_Keys
7883 in package Generic_Keys returns True if both Left < Right and Right < Left
7884 return False using the generic formal "<" operator, and returns True otherwise.]}
7885
7886 @end{StaticSem}
7887
7888 @begin{ImplAdvice}
7889
7890 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7891 @ChgAdded{Version=[2],Text=[If @i<N> is the length of a set, then the
7892 worst-case time complexity of the Insert, Include, Replace, Delete, Exclude and
7893 Find operations that take an element parameter should be @i{O}((log @i<N>)**2) or
7894 better. The worst-case time complexity of the subprograms that take a cursor
7895 parameter should be @i{O}(1).]}
7896 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
7897 Text=[The worst-case time complexity of the Insert, Include, Replace, Delete, Exclude and
7898 Find operations of Containers.Ordered_Sets that take an element parameter
7899 should be @i{O}((log @i<N>)**2). The worst-case time complexity of the subprograms
7900 of Containers.Ordered_Sets that take a cursor parameter should be @i{O}(1).]}]}
7901 @end{ImplAdvice}
7902
7903 @begin{ImplNote}
7904 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7905 @ChgAdded{Version=[2],Text=[See @RefSec{The Generic Package Containers.Ordered_Maps}
7906 for implementation notes regarding some of the operations of this package.]}
7907 @end{ImplNote}
7908
7909 @begin{Extend95}
7910 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
7911 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
7912 The generic package Containers.Ordered_Sets is new.]}
7913 @end{Extend95}
7914
7915 @begin{Incompatible2005}
7916 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
7917 @ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}Subprograms Assign and Copy
7918 are added to Containers.Ordered_Sets. If an instance of Containers.Ordered_Sets
7919 is referenced in a @nt{use_clause}, and an entity @i<E> with the same
7920 @nt{defining_identifier} as a new entity in Containers.Ordered_Sets is
7921 defined in a package that is also referenced in a @nt{use_clause}, the
7922 entity @i<E> may no longer be use-visible, resulting in errors. This should
7923 be rare and is easily fixed if it does occur.]}
7924 @end{Incompatible2005}
7925
7926 @begin{Extend2005}
7927 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0212-1]}
7928 @ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
7929 Added iterator and indexing support to make ordered set containers more
7930 convenient to use.]}
7931 @end{Extend2005}
7932
7933 @begin{DiffWord2005}
7934 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]}
7935 @ChgAdded{Version=[3],Text=[@b<Correction:> Added wording to
7936 require the formal function be such that equal elements are also
7937 equivalent.]}
7938
7939 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0044-1]}
7940 @ChgAdded{Version=[3],Text=[@b<Correction:> Redefined "<" actuals
7941 to require a strict weak ordering; the old definition allowed
7942 indeterminant comparisons that would not have worked in a container.]}
7943
7944 @ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0084-1]}
7945 @ChgAdded{Version=[3],Text=[@b<Correction:> Added a pragma
7946 Remote_Types so that containers can be used in distributed programs.]}
7947 @end{DiffWord2005}
7948
7949 @begin{Incompatible2012}
7950 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0111-1],ARef=[AI12-0112-1],ARef=[AI12-0339-1]}
7951 @ChgAdded{Version=[5],Text=[@Defn{incompatibilities with Ada 2012}A number of
7952 new subprograms, types, and even a nested package were added to
7953 Containers.Ordered_Sets to better support contracts and stable views. If an
7954 instance of Containers.Ordered_Sets
7955 is referenced in a @nt{use_clause}, and an entity @i<E> with the same
7956 @nt{defining_identifier} as a new entity in Containers.Ordered_Sets is
7957 defined in a package that is also referenced in a @nt{use_clause}, the
7958 entity @i<E> may no longer be use-visible, resulting in errors. This should
7959 be rare and is easily fixed if it does occur.]}
7960 @end{Incompatible2012}
7961
7962 @begin{Extend2012}
7963 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0212-1]}
7964 @ChgAdded{Version=[5],Text=[@Defn{extensions to Ada 2012}Sets now support
7965 positional container aggregates, so @nt{aggregate} syntax can be used to
7966 create Sets.]}
7967
7968 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0266-1]}
7969 @ChgAdded{Version=[5],Text=[The iterator for the
7970 entire container now can return a parallel iterator which can be used to
7971 process the container in parallel.]}
7972 @end{Extend2012}
7973
7974 @begin{DiffWord2012}
7975 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0112-1]}
7976 @ChgAdded{Version=[5],Text=[Added contracts to this container. This includes
7977 describing some of the semantics with pre- and postconditions, rather than
7978 English text. Note that the preconditions can be Suppressed (see
7979 @RefSecNum{Suppressing Checks}).]}
7980 @end{DiffWord2012}
7981
7982