CVS difference for ai05s/ai05-0212-1.txt

Differences between 1.15 and version 1.16
Log of other versions for file ai05s/ai05-0212-1.txt

--- ai05s/ai05-0212-1.txt	2011/06/20 04:55:18	1.15
+++ ai05s/ai05-0212-1.txt	2011/07/30 06:08:02	1.16
@@ -1,4 +1,4 @@
-!standard 7.6(4/1)                                  11-06-18  AI05-0212-1/11
+!standard 7.6(4/1)                                  11-07-29  AI05-0212-1/12
 !standard A.18.2(6/2)
 !standard A.18.2(8/2)
 !standard A.18.2(11/2)
@@ -10,9 +10,64 @@
 !standard A.18.2(225/2)
 !standard A.18.2(226/2)
 !standard A.18.2(230/2)
+!standard A.18.2(240/2)
 !standard A.18.2(252/2)
+!standard A.18.3(5/2)
+!standard A.18.3(6/2)
+!standard A.18.3(9/2)
+!standard A.18.3(17/2)
+!standard A.18.3(44/2)
+!standard A.18.3(46/2)
+!standard A.18.3(69/2)
+!standard A.18.3(86/2)
+!standard A.18.3(139/2)
+!standard A.18.3(140/2)
+!standard A.18.3(144/2)
+!standard A.18.3(157/2)
+!standard A.18.4(18/2)
+!standard A.18.4(41/2)
+!standard A.18.4(72/2)
+!standard A.18.4(73/2)
+!standard A.18.4(80/2)
+!standard A.18.5(2/2)
+!standard A.18.5(3/2)
+!standard A.18.5(6/2)
+!standard A.18.5(17/2)
+!standard A.18.5(33/2)
+!standard A.18.5(37/2)
+!standard A.18.5(61/2)
+!standard A.18.6(2/2)
+!standard A.18.6(4/2)
+!standard A.18.6(7/2)
+!standard A.18.6(16/2)
+!standard A.18.6(43/2)
+!standard A.18.6(51/2)
+!standard A.18.6(94/2)
+!standard A.18.7(19/2)
+!standard A.18.7(36/2)
+!standard A.18.7(83/2)
+!standard A.18.7(84/2)
+!standard A.18.7(96/2)
+!standard A.18.7(101/2)
+!standard A.18.8(2/2)
+!standard A.18.8(3/2)
+!standard A.18.8(6/2)
+!standard A.18.8(17/2)
+!standard A.18.8(45/2)
+!standard A.18.8(49/2)
+!standard A.18.8(58/2)
+!standard A.18.8(85/2)
+!standard A.18.9(2/2)
+!standard A.18.9(4/2)
+!standard A.18.9(7/2)
+!standard A.18.9(16/2)
+!standard A.18.9(53/2)
+!standard A.18.9(61/2)
+!standard A.18.9(73/2)
+!standard A.18.9(113/2)
+!standard A.18.10(0)
 !standard A.18.18(0)
-!standard A.18.33(0)
+!standard A.18.32(0)
 !class Amendment 10-04-26
 !status Amendment 2012 11-06-18
 !status ARG Approved (by Letter Ballot) 9-0-2  11-05-16
@@ -84,8 +139,8 @@
 but including Indefinite_Holders) immediately after Update_Element (with suitable
 substitutions for the names of types):
 
-    type Constant_Reference_Type (Element : not null access constant Element_Type) is
-       private
+    type Constant_Reference_Type
+          (Element : not null access constant Element_Type) is private
        with Implicit_Dereference => Element;
 
     type Reference_Type (Element : not null access Element_Type) is private
@@ -107,7 +162,8 @@
 exception: there is no Reference in package Sets [meta-rule: There is a Constant_Reference
 for each Query_Element; a Reference for each Update_Element]:
 
-    function Constant_Reference (Container : aliased in Vector; Position : in Cursor)
+    function Constant_Reference (Container : aliased in Vector;
+                                 Position  : in Cursor)
        return Constant_Reference_Type;
 
 This function (combined with the Constant_Indexing and Implicit_Dereference
@@ -121,7 +177,8 @@
 if any operation tampers with the elements of Container while the object returned
 by Constant_Reference exists and has not been finalized.
 
-    function Reference (Container : aliased in out Vector; Position : in Cursor)
+    function Reference (Container : aliased in out Vector;
+                        Position  : in Cursor)
        return Reference_Type;
 
 This function (combined with the Variable_Indexing and Implicit_Dereference
@@ -166,9 +223,16 @@
 Program_Error is propagated if any operation tampers with the elements of Container
 while the object returned by Reference exists and has not been finalized.
 
-The element designated by Position is not an empty element after successful
+The element at position Index is not an empty element after successful
 completion of this operation.
 
+Modify A.18.2(240/2):
+
+Reading the value of an empty element by calling Element, Query_Element, Update_Element,
+{Constant_Reference, Reference,} Swap, Is_Sorted, Sort, Merge, "=", Find, or Reverse_Find
+is a bounded error. The implementation may treat the element as having any normal value
+(see 13.9.1) of the element type, or raise Constraint_Error or Program_Error before
+modifying the vector.
 
 Add the following to Ada.Containers.Hashed_Maps and the various other Map containers:
 
@@ -201,7 +265,7 @@
 
 This function (combined with the Implicit_Dereference aspect)
 provides a convenient way to gain read and write access to the individual
-elements of a container starting with an key value.
+elements of a container starting with a cursor.
 
 If Position equals No_Element, then Constraint_Error is propagated; if Position
 does not designate an element in Container, then Program_Error is propagated.
@@ -270,7 +334,8 @@
 After the existing procedure Reverse_Iterate of each container that has Reverse_Iterate,
 add a new function:
 
-   function Iterate (Container : in Vector) return Iterators.Reversible_Iterator'Class;
+   function Iterate (Container : in Vector)
+      return Vector_Iterator_Interfaces.Reversible_Iterator'Class;
 
       Iterate returns a reversible iterator object that will generate a
       loop parameter designating each node in Container, starting with
@@ -288,7 +353,8 @@
 
 After the above routine for various Vector and List containers, add a new function:
 
-   function Iterate (Container : in Vector; Start : in Cursor) return Iterators.Reversible_Iterator'Class;
+   function Iterate (Container : in Vector; Start : in Cursor)
+      return Vector_Iterator_Interfaces.Reversible_Iterator'Class;
 
       If Start is not No_Element and does not designate an item in Container, then Program_Error
       is propagated. If Start is No_Element, the call is equivalent to Iterate (Container).
@@ -303,14 +369,15 @@
       returned object from Iterate needs finalization.
 
       AARM Note: Exits are allowed from the loops created using the iterator objects. In
-      particular, to stop the iteration at a particalar cursor, just add
+      particular, to stop the iteration at a particular cursor, just add
           exit when Cur = Stop;
-      in the body of the loop.
+      in the body of the loop (assuming the Cur is the loop parameter and Stop is the
+      cursor that you want to stop at).
 
 After the existing procedure Iterate of each container that does not have a procedure
 Reverse_Iterate (for example, Hashed_Sets), add a new function:
 
-   function Iterate (Container : in Set) return Iterators.Forward_Iterator'Class;
+   function Iterate (Container : in Set) return Set_Iterator_Interfaces.Forward_Iterator'Class;
 
       Iterate returns an iterator object that will generate a loop parameter
       designating each node in Container, starting with the first node and
@@ -323,7 +390,8 @@
 
 Instead of the above, the Multiway_Tree containers would have:
 
-   function Iterate (Container : in Tree) return Iterators.Forward_Iterator'Class;
+   function Iterate (Container : in Tree)
+      return Tree_Iterator_Interfaces.Forward_Iterator'Class;
 
       Iterate returns an iterator object that will generate a loop parameter
       designating each node in Container, starting with the root node and
@@ -333,9 +401,10 @@
       of Container while the returned object exists. The returned object from
       Iterate needs finalization.
 
-   function Iterate_Subtree (Position : in Cursor) return Iterators.Forward_Iterator'Class;
+   function Iterate_Subtree (Position : in Cursor)
+      return Tree_Iterator_Interfaces.Forward_Iterator'Class;
 
-      Iterate returns an iterator object that will generate a loop parameter
+      Iterate_Subtree returns an iterator object that will generate a loop parameter
       designating each element in the subtree rooted by the node designated by
       Position, starting with the node designated by Position and
       proceeding in a depth-first order. If Position equals No_Element, then Constraint_Error is
@@ -343,11 +412,12 @@
       the sequence_of_statements of the loop_statement whose iterator_specification denotes
       this object) tampers with the cursors of the container in which the node designated by Position
       exists while the returned object exists. The returned
-      object from Iterate needs finalization.
+      object from Iterate_Subtree needs finalization.
 
-   function Iterate_Children (Container : in Tree; Parent : in Cursor) return Iterators.Reversible_Iterator'Class;
+   function Iterate_Children (Container : in Tree; Parent : in Cursor)
+      return Tree_Iterator_Interfaces.Reversible_Iterator'Class;
 
-      Iterate returns a reversible iterator object that will generate a
+      Iterate_Children returns a reversible iterator object that will generate a
       loop parameter designating each child node of Parent. If Parent equals
       No_Element, then Constraint_Error is propagated. If Parent does not designate a node in Container, then
       Program_Error is propagated. Otherwise, when used as a forward iterator,
@@ -358,7 +428,7 @@
       propagated if any operation (in particular, the sequence_of_statements of
       the loop_statement whose iterator_specification denotes this object)
       tampers with the cursors of Container while the returned object exists.
-      The returned object from Iterate needs finalization.
+      The returned object from Iterate_Children needs finalization.
 
 Add the following to the Erroneous Execution section of each (unbounded) container package:
 
@@ -390,9 +460,9 @@
 use of those functions and their associated types.
 
 
-Add a new clause at the end of the containers section: (Currently A.18.33)
+Add a new clause at the end of the containers section: (Currently A.18.32)
 
-A.18.33 Example of Container Use
+A.18.32 Example of Container Use
 
 The following example is an implementation of Dijkstra's shortest path algorithm in
 a directed graph with positive distances. The graph is represented by a map from nodes
@@ -792,302 +862,1200 @@
     Locations.Insert ("Randy", (X => 10, Y => 5));
     Locations.Insert ("Steve", (X | Y => 20));
     Locations.Insert ("John", (X => 50, Y => 100));
+
+we can reference the elements directly via the keys (again we're using the
+Variable_Indexing aspect to simplify the calls):
+
+    if Locations("Randy").X > 10 then ...
+    if Locations("Tucker").all = (X | Y => 0) then ...
+    Locations ("Steve").X := 15;
+    Locations ("John").all := (X | Y => 60);
+
+
+The iterator functions can be used directly in a for loop:
+
+    for C in My_Vector.Iterator loop
+        if My_Vector(C).B then
+            My_Vector(C).Cnt := My_Vector(C).Cnt + 1;
+        end if;
+    end loop;
+
+Note that the Reference and Constant_Reference functions (implicitly called above)
+are very helpful in writing the body of this sort of loop.
+
+When reasonable, the keyword "reverse" is supported with the usual meaning:
+
+    for C in reverse My_Vector.Iterator loop
+
+Containers have the "Iterator" function as their default iterator. This is
+always the iterator that unconditionally iterates the entire contents of the
+container. These iterators can be used with the "of" syntax to directly access
+the elements of a container. This means that the first loop above can be written:
+
+    for E of My_Vector loop
+        if E.B then
+            E.Cnt := E.Cnt + 1;
+        end if;
+    end loop;
+
+Note however that the cursor form is more powerful. For instance, for a Map, the
+default iterator can only access the elements and not the keys, while the cursor
+form can access both. Similarly, for a tree, the element form does not allow the
+loop body to know where in the tree the element exists; the cursor form allows
+querying Depth, Parent, and many other useful functions.
+
+!corrigendum 7.6(4/2)
+
+@drepl
+@xcode<@b<package> Ada.Finalization @b<is>
+    @b<pragma> Preelaborate(Finalization);
+    @b<pragma> Remote_Types(Finalization);>
+@dby
+@xcode<@b<package> Ada.Finalization @b<is>
+    @b<pragma> Pure(Finalization);>
+
+!corrigendum A.18.2(6/2)
+
+@drepl
+@xcode<@b<generic>
+   @b<type> Index_Type @b<is range> <@>;
+   @b<type> Element_Type @b<is private>;
+   @b<with function> "=" (Left, Right : Element_Type)
+      @b<return> Boolean @b<is> <@>;
+@b<package> Ada.Containers.Vectors @b<is>
+   @b<pragma> Preelaborate(Vectors);>
+@dby
+@xcode<@b<with> Ada.Iterator_Interfaces;
+@b<generic>
+   @b<type> Index_Type @b<is range> <@>;
+   @b<type> Element_Type @b<is private>;
+   @b<with function> "=" (Left, Right : Element_Type)
+      @b<return> Boolean @b<is> <@>;
+@b<package> Ada.Containers.Vectors @b<is>
+   @b<pragma> Preelaborate(Vectors);>
+
+!corrigendum A.18.2(8/2)
+
+@drepl
+@xcode<   @b<type> Vector @b<is tagged private>;
+   @b<pragma> Preelaborable_Initialization(Vector);>
+@dby
+@xcode<   @b<type> Vector @b<is tagged private>
+      @b<with> Constant_Indexing =@> Constant_Reference,
+           Variable_Indexing =@> Reference,
+           Default_Iterator  =@> Iterate,
+           Iterator_Element  =@> Element_Type;
+   @b<pragma> Preelaborable_Initialization(Vector);>
+
+!corrigendum A.18.2(11/2)
+
+@dinsa
+@xcode<   No_Element : @b<constant> Cursor;>
+@dinss
+@xcode<   @b<function> Has_Element (Position : Cursor) @b<return> Boolean;
+
+   @b<package> Vector_Iterator_Interfaces @b<is new>
+       Ada.Iterator_Interfaces (Cursor, Has_Element);>
+
+!corrigendum A.18.2(34/2)
+
+@dinsa
+@xcode<   @b<procedure> Update_Element
+      (Container : @b<in out> Vector;
+       Position  : @b<in>     Cursor;
+       Process   : @b<not null access procedure>
+                           (Element : @b<in out> Element_Type));>
+@dinss
+@xcode<   @b<type> Constant_Reference_Type
+         (Element : @b<not null access constant> Element_Type) @b<is private>
+      @b<with> Implicit_Dereference =@> Element;
+
+   @b<type> Reference_Type (Element : @b<not null access> Element_Type) @b<is private>
+      @b<with> Implicit_Dereference =@> Element;
+
+   @b<function> Constant_Reference (Container : @b<aliased in> Vector;
+                                    Index     : @b<in> Index_Type)
+      @b<return> Constant_Reference_Type;
+
+   @b<function> Reference (Container : @b<aliased in out> Vector;
+                           Index     : @b<in> Index_Type)
+      @b<return> Reference_Type;
+
+   @b<function> Constant_Reference (Container : @b<aliased in> Vector;
+                                    Position  : @b<in> Cursor)
+      @b<return> Constant_Reference_Type;
+
+   @b<function> Reference (Container : @b<aliased in out> Vector;
+                           Position  : @b<in> Cursor)
+      @b<return> Reference_Type;>
+
+!corrigendum A.18.2(72/2)
+
+@ddel
+@xcode<   @b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+
+!corrigendum A.18.2(74/2)
+
+@dinsa
+@xcode<   @b<procedure> Reverse_Iterate
+     (Container : @b<in> Vector;
+      Process   : @b<not null access procedure> (Position : @b<in> Cursor));>
+@dinss
+@xcode<   @b<function> Iterate (Container : @b<in> Vector)
+      @b<return> Vector_Iterator_Interfaces.Reversible_Iterator'Class;>
+
+@xcode<   @b<function> Iterate (Container : @b<in> Vector; Start : @b<in> Cursor)
+      @b<return> Vector_Iterator_Interfaces.Reversible_Iterator'Class;>
+
+!corrigendum A.18.2(97/2)
+
+@dinsa
+@xbullet<it replaces one or more elements of @i<V>, that is, it calls the Replace_Element,
+Reverse_Elements, or Swap procedures or the Sort or Merge procedures of an instance
+of Generic_Sorting with @i<V> as a parameter.>
+@dinss
+@xcode<@b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+
+@xindent<Returns True if Position designates an element, and returns False otherwise.>
+
+!corrigendum A.18.2(147/2)
+
+@dinsa
+@xindent<The element designated by Position is not an empty element after successful
+completion of this operation.>
+@dinss
+@xcode<@b<type> Constant_Reference_Type
+      (Element : @b<not null access constant> Element_Type) @b<is private>
+   @b<with> Implicit_Dereference =@> Element;>
+
+@xcode<@b<type> Reference_Type (Element : @b<not null access> Element_Type) @b<is private>
+   @b<with> Implicit_Dereference =@> Element;>
+
+@xindent<Constant_Reference_Type and Reference_Type need finalization.>
+
+@xindent<The default initialization of an object of type Constant_Reference_Type or Reference_Type
+propagates Program_Error.>
+
+@xcode<@b<function> Constant_Reference (Container : @b<aliased in> Vector;
+                                        Index     : @b<in> Index_Type)
+   @b<return> Constant_Reference_Type;>
+
+@xindent<This routine (combined with the Constant_Indexing and Implicit_Dereference
+aspects) provides a convenient way to gain read access to the individual
+elements of a container starting with an index value.>
+
+@xindent<If Index is not in the range First_Index (Container) .. Last_Index (Container),
+then Constraint_Error is propagated. Otherwise, Constant_Reference returns an object
+whose discriminant is an access value that designates the element at position Index.
+Program_Error is propagated if any operation tampers with the elements of Container
+while the object returned by Constant_Reference exists and has not been finalized.>
+
+@xcode<@b<function> Reference (Container : @b<aliased in out> Vector;
+                               Index     : @b<in> Index_Type)
+   @b<return> Reference_Type;>
+
+@xindent<This function (combined with the Variable_Indexing and Implicit_Dereference
+aspects) provides a convenient way to gain read and write access to the
+individual elements of a container starting with an index value.>
+
+@xindent<If Index is not in the range First_Index (Container) .. Last_Index (Container),
+then Constraint_Error is propagated. Otherwise, Reference returns an object whose
+discriminant is an access value that designates the element at position Index.
+Program_Error is propagated if any operation tampers with the elements of Container
+while the object returned by Reference exists and has not been finalized.>
+
+@xindent<The element at position Index is not an empty element after successful
+completion of this operation.>
+
+@xcode<@b<function> Constant_Reference (Container : @b<aliased in> Vector;
+                                        Position  : @b<in> Cursor)
+   @b<return> Constant_Reference_Type;>
+
+@xindent<This function (combined with the Constant_Indexing and Implicit_Dereference
+aspects) provides a convenient way to gain read access to the individual
+elements of a container starting with a cursor.>
+
+@xindent<If Position equals No_Element, then Constraint_Error is propagated; if Position
+does not designate an element in Container, then Program_Error is propagated.
+Otherwise, Constant_Reference returns an object whose discriminant is an access
+value that designates the element designated by Position. Program_Error is propagated
+if any operation tampers with the elements of Container while the object returned
+by Constant_Reference exists and has not been finalized.>
+
+@xcode<@b<function> Reference (Container : @b<aliased in out> Vector;
+                               Position  : @b<in> Cursor)
+   @b<return> Reference_Type;>
+
+@xindent<This function (combined with the Variable_Indexing and Implicit_Dereference
+aspects) provides a convenient way to gain read and write access to the
+individual elements of a container starting with a cursor.>
+
+@xindent<If Position equals No_Element, then Constraint_Error is propagated; if Position
+does not designate an element in Container, then Program_Error is propagated.
+Otherwise, Reference returns an object whose discriminant is an access value
+that designates the element designated by Position. Program_Error is propagated if
+any operation tampers with the elements of Container while the object returned
+by Reference exists and has not been finalized.>
+
+@xindent<The element designated by Position is not an empty element after successful
+completion of this operation.>
+
+!corrigendum A.18.2(225/2)
+
+@ddel
+@xcode<@b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+
+!corrigendum A.18.2(226/2)
+
+@ddel
+@xindent<Returns True if Position designates an element, and returns False otherwise.>
+
+!corrigendum A.18.2(230/2)
+
+@dinsa
+@xindent<Iterates over the elements in Container as per Iterate, except that elements
+are traversed in reverse index order.>
+@dinss
+@xcode<@b<function> Iterate (Container : @b<in> Vector)
+   @b<return> Vector_Iterator_Interfaces.Reversible_Iterator'Class;>
+
+@xindent<Iterate returns a reversible iterator object that will generate a
+loop parameter designating each node in Container, starting with
+the first node and moving the cursor as per the Next function when
+used as a forward iterator, and starting with the last node and moving
+the cursor as per the Previous function when used as a reverse iterator.
+Program_Error is propagated if any operation (in
+particular, the @fa<sequence_of_statements> of the @fa<loop_statement> whose
+@fa<iterator_specification> denotes this object) tampers with the cursors of
+Container while the returned object exists. The returned object from
+Iterate needs finalization.>
+
+@xcode<@b<function> Iterate (Container : @b<in> Vector; Start : @b<in> Cursor)
+   @b<return> Vector_Iterator_Interfaces.Reversible_Iterator'Class;>
+
+@xindent<If Start is not No_Element and does not designate an item in Container, then Program_Error
+is propagated. If Start is No_Element, the call is equivalent to Iterate (Container).
+Otherwise, Iterate returns a reversible iterator object that will generate
+a loop parameter designating each node in Container, starting with the
+node designated by From and moving the cursor as per the Next function
+when used as a forward iterator, or moving the cursor as per the Previous
+function when used as a reverse iterator. Program_Error is propagated if
+any operation (in particular, the @fa<sequence_of_statements> of the
+@fa<loop_statement> whose @fa<iterator_specification> denotes this object) tampers
+with the cursors of Container while the returned object exists. The
+returned object from Iterate needs finalization.>
+
+!corrigendum A.18.2(240/2)
+
+@drepl
+Reading the value of an empty element by calling Element, Query_Element, Update_Element,
+Swap, Is_Sorted, Sort, Merge, "=", Find, or Reverse_Find
+is a bounded error. The implementation may treat the element as having any normal value
+(see 13.9.1) of the element type, or raise Constraint_Error or Program_Error before
+modifying the vector.
+@dby
+Reading the value of an empty element by calling Element, Query_Element, Update_Element,
+Constant_Reference, Reference, Swap, Is_Sorted, Sort, Merge, "=", Find, or Reverse_Find
+is a bounded error. The implementation may treat the element as having any normal value
+(see 13.9.1) of the element type, or raise Constraint_Error or Program_Error before
+modifying the vector.
+
+!corrigendum A.18.2(252/2)
+
+@dinsa
+The result of "=" or Has_Element is unspecified if it is called with an invalid cursor parameter.
+Execution is erroneous if any other subprogram declared in Containers.Vectors is called with an
+invalid cursor parameter.
+@dinst
+Execution is erroneous if the vector associated with the result of a call to
+Reference or Constant_Reference is finalized before the result object returned
+by the call to Reference or Constant_Reference is finalized.
+
+!corrigendum A.18.3(5/2)
+
+@drepl
+@xcode<@b<generic>
+   @b<type> Element_Type @b<is private>;
+   @b<with function> "=" (Left, Right : Element_Type) @b<return> Boolean @b<is> <@>;
+@b<package> Ada.Containers.Doubly_Linked_Lists @b<is>
+   @b<pragma> Preelaborate(Doubly_Linked_Lists);>
+@dby
+@xcode<@b<with> Ada.Iterator_Interfaces;
+@b<generic>
+   @b<type> Element_Type @b<is private>;
+   @b<with function> "=" (Left, Right : Element_Type) @b<return> Boolean @b<is> <@>;
+@b<package> Ada.Containers.Doubly_Linked_Lists @b<is>
+   @b<pragma> Preelaborate(Doubly_Linked_Lists);
+   @b<pragma> Remote_Types(Doubly_Linked_Lists);>
+
+!corrigendum A.18.3(6/2)
+
+@drepl
+@xcode<   @b<type> List @b<is tagged private>;
+   @b<pragma> Preelaborable_Initialization(List);>
+@dby
+@xcode<   @b<type> List @b<is tagged private>
+      @b<with> Constant_Indexing =@> Constant_Reference,
+           Variable_Indexing =@> Reference,
+           Default_Iterator  =@> Iterate,
+           Iterator_Element  =@> Element_Type;
+   @b<pragma> Preelaborable_Initialization(List);>
+
+!corrigendum A.18.3(9/2)
+
+@dinsa
+@xcode<   No_Element : @b<constant> Cursor;>
+@dinss
+@xcode<   @b<function> Has_Element (Position : Cursor) @b<return> Boolean;
+
+   @b<package> List_Iterator_Interfaces @b<is new>
+       Ada.Iterator_Interfaces (Cursor, Has_Element);>
+
+!corrigendum A.18.3(17/2)
+
+@dinsa
+@xcode<   @b<procedure> Update_Element
+       (Container : @b<in out> List;
+        Position  : @b<in>     Cursor;
+        Process   : @b<not null access procedure>
+                           (Element : @b<in out> Element_Type));>
+@dinss
+@xcode<   @b<type> Constant_Reference_Type
+         (Element : @b<not null access constant> Element_Type) @b<is private>
+      @b<with> Implicit_Dereference =@> Element;
+
+   @b<type> Reference_Type (Element : @b<not null access> Element_Type) @b<is private>
+      @b<with> Implicit_Dereference =@> Element;
+
+   @b<function> Constant_Reference (Container : @b<aliased in> List;
+                                    Position  : @b<in> Cursor)
+      @b<return> Constant_Reference_Type;
+
+   @b<function> Reference (Container : @b<aliased in out> List;
+                           Position  : @b<in> Cursor)
+      @b<return> Reference_Type;>
+
+!corrigendum A.18.3(44/2)
+
+@ddel
+@xcode<   @b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+
+!corrigendum A.18.3(46/2)
+
+@dinsa
+@xcode<   @b<procedure> Reverse_Iterate
+     (Container : @b<in> List;
+      Process   : @b<not null access procedure> (Position : @b<in> Cursor));>
+@dinss
+@xcode<   @b<function> Iterate (Container : @b<in> List)
+      @b<return> List_Iterator_Interfaces.Reversible_Iterator'Class;>
+
+@xcode<   @b<function> Iterate (Container : @b<in> List; Start : @b<in> Cursor)
+      @b<return> List_Iterator_Interfaces.Reversible_Iterator'Class;>
+
+!corrigendum A.18.3(69/2)
+
+@dinsa
+@xbullet<it replaces one or more elements of @i<L>, that is, it calls the Replace_Element
+or Swap procedures with @i<L> as a parameter.>
+@dinst
+@xcode<@b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+
+@xindent<Returns True if Position designates an element, and returns False otherwise.>
+
+!corrigendum A.18.3(86/2)
+
+@dinsa
+@xindent<If Element_Type is unconstrained and definite, then the actual Element parameter of
+Process.@b<all> shall be unconstrained.>
+@dinss
+@xcode<@b<type> Constant_Reference_Type
+      (Element : @b<not null access constant> Element_Type) @b<is private>
+   @b<with> Implicit_Dereference =@> Element;>
+
+@xcode<@b<type> Reference_Type (Element : @b<not null access> Element_Type) @b<is private>
+   @b<with> Implicit_Dereference =@> Element;>
+
+@xindent<Constant_Reference_Type and Reference_Type need finalization.>
+
+@xindent<The default initialization of an object of type Constant_Reference_Type or Reference_Type
+propagates Program_Error.>
+
+@xcode<@b<function> Constant_Reference (Container : @b<aliased in> List;
+                                        Position  : @b<in> Cursor)
+   @b<return> Constant_Reference_Type;>
+
+@xindent<This function (combined with the Constant_Indexing and Implicit_Dereference
+aspects) provides a convenient way to gain read access to the individual
+elements of a container starting with a cursor.>
+
+@xindent<If Position equals No_Element, then Constraint_Error is propagated; if Position
+does not designate an element in Container, then Program_Error is propagated.
+Otherwise, Constant_Reference returns an object whose discriminant is an access
+value that designates the element designated by Position. Program_Error is propagated
+if any operation tampers with the elements of Container while the object returned
+by Constant_Reference exists and has not been finalized.>
+
+@xcode<@b<function> Reference (Container : @b<aliased in out> List;
+                               Position  : @b<in> Cursor)
+   @b<return> Reference_Type;>
+
+@xindent<This function (combined with the Variable_Indexing and Implicit_Dereference
+aspects) provides a convenient way to gain read and write access to the
+individual elements of a container starting with a cursor.>
+
+@xindent<If Position equals No_Element, then Constraint_Error is propagated; if Position
+does not designate an element in Container, then Program_Error is propagated.
+Otherwise, Reference returns an object whose discriminant is an access value
+that designates the element designated by Position. Program_Error is propagated if
+any operation tampers with the elements of Container while the object returned
+by Reference exists and has not been finalized.>
+
+!corrigendum A.18.3(139/2)
+
+@ddel
+@xcode<@b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+
+!corrigendum A.18.3(140/2)
+
+@ddel
+@xindent<Returns True if Position designates an element, and returns False otherwise.>
+
+!corrigendum A.18.3(144/2)
+
+@dinsa
+@xindent<Iterates over the elements in Container as per Iterate, except that elements
+are traversed in reverse index order.>
+@dinss
+@xcode<@b<function> Iterate (Container : @b<in> List)
+   @b<return> List_Iterator_Interfaces.Reversible_Iterator'Class;>
+
+@xindent<Iterate returns a reversible iterator object that will generate a
+loop parameter designating each node in Container, starting with
+the first node and moving the cursor as per the Next function when
+used as a forward iterator, and starting with the last node and moving
+the cursor as per the Previous function when used as a reverse iterator.
+Program_Error is propagated if any operation (in
+particular, the @fa<sequence_of_statements> of the @fa<loop_statement> whose
+@fa<iterator_specification> denotes this object) tampers with the cursors of
+Container while the returned object exists. The returned object from
+Iterate needs finalization.>
+
+@xcode<@b<function> Iterate (Container : @b<in> List; Start : @b<in> Cursor)
+   @b<return> List_Iterator_Interfaces.Reversible_Iterator'Class;>
+
+@xindent<If Start is not No_Element and does not designate an item in Container, then Program_Error
+is propagated. If Start is No_Element, the call is equivalent to Iterate (Container).
+Otherwise, Iterate returns a reversible iterator object that will generate
+a loop parameter designating each node in Container, starting with the
+node designated by From and moving the cursor as per the Next function
+when used as a forward iterator, or moving the cursor as per the Previous
+function when used as a reverse iterator. Program_Error is propagated if
+any operation (in particular, the @fa<sequence_of_statements> of the
+@fa<loop_statement> whose @fa<iterator_specification> denotes this object) tampers
+with the cursors of Container while the returned object exists. The
+returned object from Iterate needs finalization.>
+
+!corrigendum A.18.3(157/2)
+
+@dinsa
+The result of "=" or Has_Element is unspecified if it is called with an invalid cursor parameter.
+Execution is erroneous if any other subprogram declared in Containers.Doubly_Linked_Lists is called
+with an invalid cursor parameter.
+@dinst
+Execution is erroneous if the list associated with the result of a call to
+Reference or Constant_Reference is finalized before the result object returned
+by the call to Reference or Constant_Reference is finalized.
+
+
+!corrigendum A.18.4(19/2)
+
+@dinsa
+Execution of the default implementation of the Input, Output, Read, or Write
+attribute of type Cursor raises Program_Error.
+@dinst
+@xcode<@b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+
+@xindent<Returns True if Position designates an element, and returns False otherwise.>
+
+!corrigendum A.18.4(41/2)
+
+@dinsa
+@xindent<If Element_Type is unconstrained and definite, then the actual Element parameter of
+Process.@b<all> shall be unconstrained.>
+@dinst
+@xcode<@b<type> Constant_Reference_Type
+      (Element : @b<not null access constant> Element_Type) @b<is private>
+   @b<with> Implicit_Dereference =@> Element;>
+
+@xcode<@b<type> Reference_Type (Element : @b<not null access> Element_Type) @b<is private>
+   @b<with> Implicit_Dereference =@> Element;>
+
+@xindent<Constant_Reference_Type and Reference_Type need finalization.>
+
+@xindent<The default initialization of an object of type Constant_Reference_Type or Reference_Type
+propagates Program_Error.>
+
+@xcode<@b<function> Constant_Reference (Container : @b<aliased in> Map;
+                             Position  : @b<in> Cursor)
+   @b<return> Constant_Reference_Type;>
+
+@xindent<This function (combined with the Constant_Indexing and Implicit_Dereference
+aspects) provides a convenient way to gain read access to the individual
+elements of a container starting with a cursor.>
+
+@xindent<If Position equals No_Element, then Constraint_Error is propagated; if Position
+does not designate an element in Container, then Program_Error is propagated.
+Otherwise, Constant_Reference returns an object whose discriminant is an access
+value that designates the element designated by Position. Program_Error is propagated
+if any operation tampers with the elements of Container while the object returned
+by Constant_Reference exists and has not been finalized.>
+
+@xcode<@b<function> Reference (Container : @b<aliased in out> Map;
+                    Position  : @b<in> Cursor)
+   @b<return> Reference_Type;>
+
+@xindent<This function (combined with the Variable_Indexing and Implicit_Dereference
+aspects) provides a convenient way to gain read and write access to the
+individual elements of a container starting with a cursor.>
+
+@xindent<If Position equals No_Element, then Constraint_Error is propagated; if Position
+does not designate an element in Container, then Program_Error is propagated.
+Otherwise, Reference returns an object whose discriminant is an access value
+that designates the element designated by Position. Program_Error is propagated if
+any operation tampers with the elements of Container while the object returned
+by Reference exists and has not been finalized.>
+
+@xcode<@b<function> Constant_Reference (Container : @b<aliased in> Map;
+                             Key       : @b<in> Key_Type)
+   @b<return> Constant_Reference_Type;>
+
+@xindent<This function (combined with the Constant_Indexing and Implicit_Dereference
+aspects) provides a convenient way to gain read access to the individual
+elements of a container starting with a key value.>
+
+@xindent<Equivalent to Constant_Reference (Container, Find (Container, Key)).>
+
+@xcode<@b<function> Reference (Container : @b<aliased in out> Map;
+                    Key       : @b<in> Key_Type)
+   @b<return> Reference_Type;>
+
+@xindent<This function (combined with the Variable_Indexing and Implicit_Dereference
+aspects) provides a convenient way to gain read and write access to the
+individual elements of a container starting with a key value.>
+
+@xindent<Equivalent to Reference (Container, Find (Container, Key)).>
+
+!corrigendum A.18.4(72/2)
+
+@ddel
+@xcode<@b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+
+!corrigendum A.18.4(73/2)
+
+@ddel
+@xindent<Returns True if Position designates an element, and returns False otherwise.>
+
+!corrigendum A.18.4(80/2)
+
+@dinsa
+The result of "=" or Has_Element is unspecified if it is called with an invalid cursor parameter.
+Execution is erroneous if any other subprogram declared in Containers.Hashed_Maps or
+Containers.Ordered_Maps is called
+with an invalid cursor parameter.
+@dinst
+Execution is erroneous if the map associated with the result of a call to
+Reference or Constant_Reference is finalized before the result object returned
+by the call to Reference or Constant_Reference is finalized.
+
+
+!corrigendum A.18.5(2/2)
+
+@drepl
+@xcode<@b<generic>
+   @b<type> Key_Type @b<is private>;
+   @b<type> Element_Type @b<is private>;
+   @b<with function> Hash (Key : Key_Type) @b<return> Hash_Type;
+   @b<with function> Equivalent_Keys (Left, Right : Key_Type)
+      @b<return> Boolean;
+   @b<with function> "=" (Left, Right : Element_Type)
+      @b<return> Boolean is <@>;
+@b<package> Ada.Containers.Hashed_Maps @b<is>
+   @b<pragma> Preelaborate(Hashed_Maps);>
+@dby
+@xcode<@b<with> Ada.Iterator_Interfaces;
+@b<generic>
+   @b<type> Key_Type @b<is private>;
+   @b<type> Element_Type @b<is private>;
+   @b<with function> Hash (Key : Key_Type) @b<return> Hash_Type;
+   @b<with function> Equivalent_Keys (Left, Right : Key_Type)
+      @b<return> Boolean;
+   @b<with function> "=" (Left, Right : Element_Type)
+      @b<return> Boolean @b<is> <@>;
+@b<package> Ada.Containers.Hashed_Maps @b<is>
+   @b<pragma> Preelaborate(Hashed_Maps);
+   @b<pragma> Remote_Types(Hashed_Maps);>
+
+!corrigendum A.18.5(3/2)
+
+@drepl
+@xcode<   @b<type> Map @b<is tagged private>;
+   @b<pragma> Preelaborable_Initialization(Map);>
+@dby
+@xcode<   @b<type> Map @b<is tagged private>
+      @b<with> Constant_Indexing =@> Constant_Reference,
+           Variable_Indexing =@> Reference,
+           Default_Iterator  =@> Iterate,
+           Iterator_Element  =@> Element_Type;
+   @b<pragma> Preelaborable_Initialization(Map);>
+
+!corrigendum A.18.5(6/2)
+
+@dinsa
+@xcode<   No_Element : @b<constant> Cursor;>
+@dinss
+@xcode<   @b<function> Has_Element (Position : Cursor) @b<return> Boolean;
+
+   @b<package> Map_Iterator_Interfaces @b<is new>
+       Ada.Iterator_Interfaces (Cursor, Has_Element);>
+
+!corrigendum A.18.5(17/2)
+
+@dinsa
+@xcode<   @b<procedure> Update_Element
+     (Container : @b<in out> Map;
+      Position  : @b<in>     Cursor;
+      Process   : @b<not null access procedure>
+                       (Key     : @b<in>     Key_Type;
+                        Element : @b<in out> Element_Type));>
+@dinss
+@xcode<   @b<type> Constant_Reference_Type
+         (Element : @b<not null access constant> Element_Type) @b<is private>
+      @b<with> Implicit_Dereference =@> Element;
+
+   @b<type> Reference_Type (Element : @b<not null access> Element_Type) @b<is private>
+      @b<with> Implicit_Dereference =@> Element;
+
+   @b<function> Constant_Reference (Container : @b<aliased in> Map;
+                                    Position  : @b<in> Cursor)
+      @b<return> Constant_Reference_Type;
+
+   @b<function> Reference (Container : @b<aliased in out> Map;
+                           Position  : @b<in> Cursor)
+      @b<return> Reference_Type;
+
+   @b<function> Constant_Reference (Container : @b<aliased in> Map;
+                                    Key       : @b<in> Key_Type)
+      @b<return> Constant_Reference_Type;
+
+   @b<function> Reference (Container : @b<aliased in out> Map;
+                           Key       : @b<in> Cursor)
+      @b<return> Reference_Type;>
+
+!corrigendum A.18.5(33/2)
+
+@ddel
+@xcode<   @b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+
+!corrigendum A.18.5(37/2)
+
+@dinsa
+@xcode<   @b<procedure> Iterate
+     (Container : @b<in> Map;
+      Process   : @b<not null access procedure> (Position : @b<in> Cursor));>
+@dinss
+@xcode<   @b<function> Iterate (Container : @b<in> Map)
+      @b<return> Map_Iterator_Interfaces.Forward_Iterator'Class;>
+
+!corrigendum A.18.5(61/2)
+
+@dinsa
+Equivalent to Equivalent_Keys (Left, Key (Right)).
+@dinss
+@xcode<@b<function> Iterate (Container : @b<in> Map)
+   @b<return> Map_Iterator_Interfaces.Forward_Iterator'Class;>
+
+@xindent<Iterate returns an iterator object that will generate a
+loop parameter designating each node in Container, starting with
+the first node and and moving the cursor according to the successor relation.
+Program_Error is propagated if any operation (in
+particular, the @fa<sequence_of_statements> of the @fa<loop_statement> whose
+@fa<iterator_specification> denotes this object) tampers with the cursors of
+Container while the returned object exists. The returned object from
+Iterate needs finalization.>
+
+
+!corrigendum A.18.6(2/2)
+
+@drepl
+@xcode<@b<generic>
+   @b<type> Key_Type @b<is private>;
+   @b<type> Element_Type @b<is private>;
+   @b<with function> "<" (Left, Right : Key_Type) @b<return> Boolean @b<is> <@>;
+   @b<with function> "=" (Left, Right : Element_Type) @b<return> Boolean @b<is> <@>;
+@b<package> Ada.Containers.Ordered_Maps @b<is>
+   @b<pragma> Preelaborate(Ordered_Maps);>
+@dby
+@xcode<@b<with> Ada.Iterator_Interfaces;
+@b<generic>
+   @b<type> Key_Type @b<is private>;
+   @b<type> Element_Type @b<is private>;
+   @b<with function> "<" (Left, Right : Key_Type) @b<return> Boolean @b<is> <@>;
+   @b<with function> "=" (Left, Right : Element_Type) @b<return> Boolean @b<is> <@>;
+@b<package> Ada.Containers.Ordered_Maps @b<is>
+   @b<pragma> Preelaborate(Ordered_Maps);
+   @b<pragma> Remote_Types(Ordered_Maps);>
+
+!corrigendum A.18.6(4/2)
+
+@drepl
+@xcode<   @b<type> Map @b<is tagged private>;
+   @b<pragma> Preelaborable_Initialization(Map);>
+@dby
+@xcode<   @b<type> Map @b<is tagged private>
+      @b<with> Constant_Indexing =@> Constant_Reference,
+           Variable_Indexing =@> Reference,
+           Default_Iterator  =@> Iterate,
+           Iterator_Element  =@> Element_Type;
+   @b<pragma> Preelaborable_Initialization(Map);>
+
+!corrigendum A.18.6(7/2)
+
+@dinsa
+@xcode<   No_Element : @b<constant> Cursor;>
+@dinss
+@xcode<   @b<function> Has_Element (Position : Cursor) @b<return> Boolean;
+
+   @b<package> Map_Iterator_Interfaces @b<is new>
+       Ada.Iterator_Interfaces (Cursor, Has_Element);>
+
+!corrigendum A.18.6(16/2)
+
+@dinsa
+@xcode<   @b<procedure> Update_Element
+     (Container : @b<in out> Map;
+      Position  : @b<in>     Cursor;
+      Process   : @b<not null access procedure>
+                       (Key     : @b<in>     Key_Type;
+                        Element : @b<in out> Element_Type));>
+@dinss
+@xcode<   @b<type> Constant_Reference_Type
+         (Element : @b<not null access constant> Element_Type) @b<is private>
+      @b<with> Implicit_Dereference =@> Element;
+
+   @b<type> Reference_Type (Element : @b<not null access> Element_Type) @b<is private>
+      @b<with> Implicit_Dereference =@> Element;
+
+   @b<function> Constant_Reference (Container : @b<aliased in> Map;
+                                Position  : @b<in> Cursor)
+      @b<return> Constant_Reference_Type;
+
+   @b<function> Reference (Container : @b<aliased in out> Map;
+                       Position  : @b<in> Cursor)
+      @b<return> Reference_Type;
+
+   @b<function> Constant_Reference (Container : @b<aliased in> Map;
+                                Key       : @b<in> Key_Type)
+      @b<return> Constant_Reference_Type;
+
+   @b<function> Reference (Container : @b<aliased in out> Map;
+                       Key       : @b<in> Cursor)
+      @b<return> Reference_Type;>
+
+!corrigendum A.18.6(43/2)
+
+@ddel
+@xcode<   @b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+
+!corrigendum A.18.6(46/2)
+
+@dinsa
+@xcode<   @b<procedure> Reverse_Iterate
+     (Container : @b<in> Map;
+      Process   : @b<not null access procedure> (Position : @b<in> Cursor));>
+@dinss
+@xcode<   @b<function> Iterate (Container : @b<in> Map)
+      @b<return> Map_Iterator_Interfaces.Reversible_Iterator'Class;>
+
+!corrigendum A.18.6(94/2)
+
+@dinsa
+@xindent<Iterates over the elements in Container as per Iterate, except that elements
+are traversed in predecessor order, starting with the last node.>
+@dinss
+@xcode<@b<function> Iterate (Container : @b<in> Map)
+   @b<return> Map_Iterator_Interfaces.Reversible_Iterator'Class;>
+
+@xindent<Iterate returns a reversible iterator object that will generate a
+loop parameter designating each node in Container, starting with
+the first node and moving the cursor according to the successor relation when
+used as a forward iterator, and starting with the last node and moving
+the cursor according to the predecessor relation when used as a reverse iterator.
+Program_Error is propagated if any operation (in
+particular, the @fa<sequence_of_statements> of the @fa<loop_statement> whose
+@fa<iterator_specification> denotes this object) tampers with the cursors of
+Container while the returned object exists. The returned object from
+Iterate needs finalization.>
+
+
+!corrigendum A.18.7(18/2)
+
+@dinsa
+Execution of the default implementation of the Input, Output, Read, or Write
+attribute of type Cursor raises Program_Error.
+@dinst
+@xcode<@b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+
+@xindent<Returns True if Position designates an element, and returns False otherwise.>
+
+!corrigendum A.18.7(36/2)
+
+@dinsa
+@xindent<If Position equals No_Element, then Constraint_Error is propagated.
+Otherwise, Query_Element calls Process.@b<all> with the element designated
+by Position as the argument. Program_Error is propagated if Process.@b<all>
+tampers with the elements of Container. Any exception raised by Process.@b<all>
+is propagated.>
+@dinss
+@xcode<@b<type> Constant_Reference_Type
+      (Element : @b<not null access constant> Element_Type) @b<is private>
+   @b<with> Implicit_Dereference =@> Element;>
+
+@xindent<Constant_Reference_Type needs finalization.>
+
+@xindent<The default initialization of an object of type Constant_Reference_Type 
+propagates Program_Error.>
+
+@xcode<@b<function> Constant_Reference (Container : @b<aliased in> Set;
+                             Position  : @b<in> Cursor)
+   @b<return> Constant_Reference_Type;>
+
+@xindent<This function (combined with the Constant_Indexing and Implicit_Dereference
+aspects) provides a convenient way to gain read access to the individual
+elements of a container starting with a cursor.>
+
+@xindent<If Position equals No_Element, then Constraint_Error is propagated; if Position
+does not designate an element in Container, then Program_Error is propagated.
+Otherwise, Constant_Reference returns an object whose discriminant is an access
+value that designates the element designated by Position. Program_Error is propagated
+if any operation tampers with the elements of Container while the object returned
+by Constant_Reference exists and has not been finalized.>
+
+
+!corrigendum A.18.7(83/2)
+
+@ddel
+@xcode<@b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+
+!corrigendum A.18.7(84/2)
+
+@ddel
+@xindent<Returns True if Position designates an element, and returns False otherwise.>
+
+!corrigendum A.18.7(96/2)
+
+@dinsa
+If Element_Type is unconstrained and definite, then the actual Element
+parameter of Process.@b<all> shall be unconstrained.
+@dinss
+@xcode<@b<type> Reference_Type (Element : @b<not null access> Element_Type) @b<is private>
+   @b<with> Implicit_Dereference =@> Element;>
 
-we can reference the elements directly via the keys (again we're using the
-Variable_Indexing aspect to simplify the calls):
+@xindent<Reference_Type needs finalization.>
 
-    if Locations("Randy").X > 10 then ...
-    if Locations("Tucker").all = (X | Y => 0) then ...
-    Locations ("Steve").X := 15;
-    Locations ("John").all := (X | Y => 60);
+@xindent<The default initialization of an object of type Reference_Type
+propagates Program_Error.>
 
+@xcode<@b<function> Reference_Preserving_Key (Container : @b<aliased in out> Set;
+                                   Position  : @b<in> Cursor)
+   @b<return> Reference_Type;>
 
-The iterator functions can be used directly in a for loop:
+@xindent<This function (combined with the Implicit_Dereference aspect) provides a
+convenient way to gain read and write access to the
+individual elements of a container starting with a cursor.>
 
-    for C in My_Vector.Iterator loop
-        if My_Vector(C).B then
-            My_Vector(C).Cnt := My_Vector(C).Cnt + 1;
-        end if;
-    end loop;
+@xindent<If Position equals No_Element, then Constraint_Error is propagated; if Position
+does not designate an element in Container, then Program_Error is propagated.
+Otherwise, Reference_Preserving_Key uses Key to save the key value @i<K>; then returns
+an object whose discriminant is an access value that designates the element designated
+by Position. Program_Error is propagated if any operation tampers with the elements of
+Container while the object returned by Reference_Preserving_Key exists and has not been
+finalized. When the object returned by Reference_PReserving_Key is finalized, a check
+is made if @i<K> determines the same equivalence class as that for the new element; if not,
+the element is removed from the set and Program_Error is propagated.>
 
-Note that the Reference and Constant_Reference functions (implicitly called above)
-are very helpful in writing the body of this sort of loop.
+@xcode<@b<function> Constant_Reference (Container : @b<aliased in> Set;
+                             Key       : @b<in> Key_Type)
+   @b<return> Constant_Reference_Type;>
 
-When reasonable, the keyword "reverse" is supported with the usual meaning:
+@xindent<This function (combined with the Implicit_Dereference
+aspect) provides a convenient way to gain read access to the individual
+elements of a container starting with a key value.>
 
-    for C in reverse My_Vector.Iterator loop
+@xindent<Equivalent to Constant_Reference (Container, Find (Container, Key)).>
 
-Containers have the "Iterator" function as their default iterator. This is
-always the iterator that unconditionally iterates the entire contents of the
-container. These iterators can be used with the "of" syntax to directly access
-the elements of a container. This means that the first loop above can be written:
+@xcode<@b<function> Reference_Preserving_Key (Container : @b<aliased in out> Set;
+                                   Key       : @b<in> Key_Type)
+   @b<return> Reference_Type;>
 
-    for E of My_Vector loop
-        if E.B then
-            E.Cnt := E.Cnt + 1;
-        end if;
-    end loop;
+@xindent<This function (combined with the Implicit_Dereference
+aspect) provides a convenient way to gain read and write access to the
+individual elements of a container starting with a key value.>
 
-Note however that the cursor form is more powerful. For instance, for a Map, the
-default iterator can only access the elements and not the keys, while the cursor
-form can access both. Similarly, for a tree, the element form does not allow the
-loop body to know where in the tree the element exists; the cursor form allows
-querying Depth, Parent, and many other useful functions.
+@xindent<Equivalent to Reference_Preserving_Key (Container, Find (Container, Key)).>
 
-!corrigendum 7.6(4/2)
+!corrigendum A.18.7(101/2)
 
-@drepl
-@xcode<@b<package> Ada.Finalization @b<is>
-    @b<pragma> Preelaborate(Finalization);
-    @b<pragma> Remote_Types(Finalization);>
-@dby
-@xcode<@b<package> Ada.Finalization @b<is>
-    @b<pragma> Pure(Finalization);>
+@dinsa
+The result of "=" or Has_Element is unspecified if it is called with an invalid cursor
+parameter. Execution is erroneous if any other subprogram declared in Containers.Hashed_Sets
+or Containers.Ordered_Sets is called with an invalid cursor parameter.
+@dinst
+Execution is erroneous if the set associated with the result of a call to
+Reference or Constant_Reference is finalized before the result object returned
+by the call to Reference or Constant_Reference is finalized.
+
 
-!!corrigendum A.18.2(6/2)
+!corrigendum A.18.8(2/2)
 
 @drepl
 @xcode<@b<generic>
-   @b<type> Index_Type @b<is range> <@>;
    @b<type> Element_Type @b<is private>;
-   @b<with function> "=" (Left, Right : Element_Type)
-      @b<return> Boolean @b<is> <@>;
-@b<package> Ada.Containers.Vectors @b<is>
-   @b<pragma> Preelaborate(Vectors);>
+   @b<with function> Hash (Element : Element_Type) @b<return> Hash_Type;
+   @b<with function> Equivalent_Elements (Left, Right : Element_Type)
+                 @b<return> Boolean;
+   @b<with function> "=" (Left, Right : Element_Type) @b<return> Boolean @b<is> <@>;
+@b<package> Ada.Containers.Hashed_Sets @b<is>
+   @b<pragma> Preelaborate(Hashed_Sets);>
 @dby
 @xcode<@b<with> Ada.Iterator_Interfaces;
 @b<generic>
-   @b<type> Index_Type @b<is range> <@>;
    @b<type> Element_Type @b<is private>;
-   @b<with function> "=" (Left, Right : Element_Type)
-      @b<return> Boolean @b<is> <@>;
-@b<package> Ada.Containers.Vectors @b<is>
-   @b<pragma> Preelaborate(Vectors);>
+   @b<with function> Hash (Element : Element_Type) @b<return> Hash_Type;
+   @b<with function> Equivalent_Elements (Left, Right : Element_Type)
+                 @b<return> Boolean;
+   @b<with function> "=" (Left, Right : Element_Type) @b<return> Boolean @b<is> <@>;
+@b<package> Ada.Containers.Hashed_Sets @b<is>
+   @b<pragma> Preelaborate(Hashed_Sets);
+   @b<pragma> Remote_Types(Hashed_Sets);>
 
-!corrigendum A.18.2(8/2)
+!corrigendum A.18.8(3/2)
 
-@drepl
-@xcode<   @b<type> Vector @b<is tagged private>;
-   @b<pragma> Preelaborable_Initialization(Vector);>
 @drepl
-@xcode<   @b<type> Vector @b<is tagged private>
+@xcode<   @b<type> Set @b<is tagged private>;
+   @b<pragma> Preelaborable_Initialization(Set);>
+@dby
+@xcode<   @b<type> Set @b<is tagged private>
       @b<with> Constant_Indexing =@> Constant_Reference,
-           Variable_Indexing =@> Reference,
            Default_Iterator  =@> Iterate,
            Iterator_Element  =@> Element_Type;
-   @b<pragma> Preelaborable_Initialization(Vector);>
+   @b<pragma> Preelaborable_Initialization(Set);>
 
-!corrigendum A.18.2(11/2)
+!corrigendum A.18.8(6/2)
 
 @dinsa
 @xcode<   No_Element : @b<constant> Cursor;>
 @dinss
 @xcode<   @b<function> Has_Element (Position : Cursor) @b<return> Boolean;
 
-   @b<package> Vector_Iterator_Interfaces @b<is new>
+   @b<package> Set_Iterator_Interfaces @b<is new>
        Ada.Iterator_Interfaces (Cursor, Has_Element);>
 
-!corrigendum A.18.2(34/2)
+!corrigendum A.18.8(17/2)
 
 @dinsa
-@xcode<   @b<procedure> Update_Element
-      (Container : @b<in out> Vector;
-       Position  : @b<in>     Cursor;
-       Process   : @b<not null access procedure>
-                           (Element : @b<in out> Element_Type));>
+@xcode<   @b<procedure> Query_Element
+     (Position  : @b<in>     Cursor;
+      Process   : @b<not null access procedure> (Element : @b<in> Element_Type));>
 @dinss
 @xcode<   @b<type> Constant_Reference_Type
          (Element : @b<not null access constant> Element_Type) @b<is private>
       @b<with> Implicit_Dereference =@> Element;
-
-   @b<type> Reference_Type (Element : @b<not null access> Element_Type) @b<is private>
-      @b<with> Implicit_Dereference =@> Element;
-
-   @b<function> Constant_Reference (Container : @b<aliased in> Vector;
-                                    Index     : @b<in> Index_Type)
-      @b<return> Constant_Reference_Type;
-
-   @b<function> Reference (Container : @b<aliased in out> Vector;
-                           Index     : @b<in> Index_Type)
-      @b<return> Reference_Type;
-
-   @b<function> Constant_Reference (Container : @b<aliased in> Vector;
-                                    Position  : @b<in> Cursor)
-      @b<return> Constant_Reference_Type;
 
-   @b<function> Reference (Container : @b<aliased in out> Vector;
-                           Position  : @b<in> Cursor)
-      @b<return> Reference_Type;>
+   @b<function> Constant_Reference (Container : @b<aliased in> Set;
+                                Position  : @b<in> Cursor)
+      @b<return> Constant_Reference_Type;>
 
-!corrigendum A.18.2(72/2)
+!corrigendum A.18.8(45/2)
 
 @ddel
 @xcode<   @b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
 
-!corrigendum A.18.2(74/2)
+!corrigendum A.18.9(49/2)
 
 @dinsa
-@xcode<   @b<procedure> Reverse_Iterate
-     (Container : @b<in> Vector;
+@xcode<   @b<procedure> Iterate
+     (Container : @b<in> Set;
       Process   : @b<not null access procedure> (Position : @b<in> Cursor));>
-@inss
-@xcode<   @b<function> Iterate (Container : @b<in> Vector)
-      @b<return> Iterators.Reversible_Iterator'Class;>
-
-@xcode<   @b<function> Iterate (Container : @b<in> Vector; Start : @b<in> Cursor)
-      @b<return> Iterators.Reversible_Iterator'Class;>
+@dinss
+@xcode<   @b<function> Iterate (Container : @b<in> Set)
+      @b<return> Set_Iterator_Interfaces.Forward_Iterator'Class;>
 
-!corrigendum A.18.2(97/2)
+!corrigendum A.18.8(58/2)
 
 @dinsa
-@xbullet<it replaces one or more elements of @i<V>, that is, it calls the Replace_Element,
-Reverse_Elements, or Swap procedures or the Sort or Merge procedures of an instance
-of Generic_Sorting with @i<V> as a parameter.>
+@xcode<   @b<procedure> Update_Element_Preserving_Key
+     (Container : @b<in out> Set;
+      Position  : @b<in>     Cursor;
+      Process   : @b<not null access procedure>
+                       (Key     : @b<in>     Key_Type;
+                        Element : @b<in out> Element_Type));>
 @dinss
-@xcode<@b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+@xcode<      @b<type> Reference_Type (Element : @b<not null access> Element_Type) @b<is private>
+         @b<with> Implicit_Dereference =@> Element;
 
-@xindent<Returns True if Position designates an element, and returns False otherwise.>
+      @b<function> Reference_Preserving_Key (Container : @b<aliased in out> Set;
+                                         Position  : @b<in> Cursor)
+         @b<return> Reference_Type;
+
+      @b<function> Constant_Reference (Container : @b<aliased in> Set;
+                                   Key       : @b<in> Key_Type)
+         @b<return> Constant_Reference_Type;
+
+      @b<function> Reference_Preserving_Key (Container : @b<aliased in out> Set;
+                                         Key       : @b<in> Cursor)
+         @b<return> Reference_Type;>
 
-!corrigendum A.18.2(147/2)
+!corrigendum A.18.8(85/2)
 
 @dinsa
-@xindent<The element designated by Position is not an empty element after successful
-completion of this operation.>
+Equivalent to Equivalent_Elements (Left, Element (Right)).
 @dinss
-@xcode<@b<type> Constant_Reference_Type
-      (Element : @b<not null access constant> Element_Type) @b<is private>
-   @b<with> Implicit_Dereference =@> Element;>
+@xcode<@b<function> Iterate (Container : @b<in> Set)
+   @b<return> Map_Iterator_Interfaces.Forward_Iterator'Class;>
 
-@xcode<@b<type> Reference_Type (Element : @b<not null access> Element_Type) @b<is private>
-   @b<with> Implicit_Dereference =@> Element;>
-
-@xindent<Constant_Reference_Type and Reference_Type need finalization.>
-
-@xindent<The default initialization of an object of type Constant_Reference_Type or Reference_Type
-propagates Program_Error.>
+@xindent<Iterate returns an iterator object that will generate a
+loop parameter designating each element in Container, starting with
+the first element and and moving the cursor according to the successor relation.
+Program_Error is propagated if any operation (in
+particular, the @fa<sequence_of_statements> of the @fa<loop_statement> whose
+@fa<iterator_specification> denotes this object) tampers with the cursors of
+Container while the returned object exists. The returned object from
+Iterate needs finalization.>
 
-@xcode<@b<function> Constant_Reference (Container : @b<aliased in> Vector;
-                                        Index     : @b<in> Index_Type)
-   @b<return> Constant_Reference_Type;>
 
-@xindent<This routine (combined with the Constant_Indexing and Implicit_Dereference
-aspects) provides a convenient way to gain read access to the individual
-elements of a container starting with an index value.>
+!corrigendum A.18.9(2/2)
 
-@xindent<If Index is not in the range First_Index (Container) .. Last_Index (Container),
-then Constraint_Error is propagated. Otherwise, Constant_Reference returns an object
-whose discriminant is an access value that designates the element at position Index.
-Program_Error is propagated if any operation tampers with the elements of Container
-while the object returned by Constant_Reference exists and has not been finalized.>
+@drepl
+@xcode<@b<generic>
+   @b<type> Element_Type @b<is private>;
+   @b<with function> "<" (Left, Right : Element_Type) @b<return> Boolean @b<is> <@>;
+   @b<with function> "=" (Left, Right : Element_Type) @b<return> Boolean @b<is> <@>;
+@b<package> Ada.Containers.Ordered_Sets @b<is>
+   @b<pragma> Preelaborate(Ordered_Sets);>
+@dby
+@xcode<@b<with> Ada.Iterator_Interfaces;
+@b<generic>
+   @b<type> Element_Type @b<is private>;
+   @b<with function> "<" (Left, Right : Element_Type) @b<return> Boolean @b<is> <@>;
+   @b<with function> "=" (Left, Right : Element_Type) @b<return> Boolean @b<is> <@>;
+@b<package> Ada.Containers.Ordered_Sets @b<is>
+   @b<pragma> Preelaborate(Ordered_Sets);
+   @b<pragma> Remote_Types(Ordered_Sets);>
 
-@xcode<@b<function> Reference (Container : @b<aliased in out> Vector;
-                               Index     : @b<in> Index_Type)
-   @b<return> Reference_Type;>
+!corrigendum A.18.9(4/2)
 
-@xindent<This function (combined with the Variable_Indexing and Implicit_Dereference
-aspects) provides a convenient way to gain read and write access to the
-individual elements of a container starting with an index value.>
+@drepl
+@xcode<   @b<type> Set @b<is tagged private>;
+   @b<pragma> Preelaborable_Initialization(Set);>
+@dby
+@xcode<   @b<type> Set @b<is tagged private>
+      @b<with> Constant_Indexing =@> Constant_Reference,
+           Default_Iterator  =@> Iterate,
+           Iterator_Element  =@> Element_Type;
+   @b<pragma> Preelaborable_Initialization(Set);>
 
-@xindent<If Index is not in the range First_Index (Container) .. Last_Index (Container),
-then Constraint_Error is propagated. Otherwise, Reference returns an object whose
-discriminant is an access value that designates the element at position Index.
-Program_Error is propagated if any operation tampers with the elements of Container
-while the object returned by Reference exists and has not been finalized.>
+!corrigendum A.18.9(7/2)
 
-@xindent<The element designated by Position is not an empty element after successful
-completion of this operation.>
+@dinsa
+@xcode<   No_Element : @b<constant> Cursor;>
+@dinss
+@xcode<   @b<function> Has_Element (Position : Cursor) @b<return> Boolean;
 
-@xcode<@b<function> Constant_Reference (Container : @b<aliased in> Vector;
-                                        Position  : @b<in> Cursor)
-   @b<return> Constant_Reference_Type;>
+   @b<package> Set_Iterator_Interfaces @b<is new>
+       Ada.Iterator_Interfaces (Cursor, Has_Element);>
 
-@xindent<This function (combined with the Constant_Indexing and Implicit_Dereference
-aspects) provides a convenient way to gain read access to the individual
-elements of a container starting with a cursor.>
+!corrigendum A.18.9(16/2)
 
-@xindent<If Position equals No_Element, then Constraint_Error is propagated; if Position
-does not designate an element in Container, then Program_Error is propagated.
-Otherwise, Constant_Reference returns an object whose discriminant is an access
-value that designates the element designated by Position. Program_Error is propagated
-if any operation tampers with the elements of Container while the object returned
-by Constant_Reference exists and has not been finalized.>
+@dinsa
+@xcode<   @b<procedure> Query_Element
+     (Position  : @b<in>     Cursor;
+      Process   : @b<not null access procedure> (Element : @b<in> Element_Type));>
+@dinss
+@xcode<   @b<type> Constant_Reference_Type
+         (Element : @b<not null access constant> Element_Type) @b<is private>
+      @b<with> Implicit_Dereference =@> Element;
 
-@xcode<@b<function> Reference (Container : @b<aliased in out> Vector;
-                               Position  : @b<in> Cursor)
-   @b<return> Reference_Type;>
+   @b<function> Constant_Reference (Container : @b<aliased in> Set;
+                                Position  : @b<in> Cursor)
+      @b<return> Constant_Reference_Type;>
 
-@xindent<This function (combined with the Variable_Indexing and Implicit_Dereference
-aspects) provides a convenient way to gain read and write access to the
-individual elements of a container starting with a cursor.>
+!corrigendum A.18.9(53/2)
 
-@xindent<If Position equals No_Element, then Constraint_Error is propagated; if Position
-does not designate an element in Container, then Program_Error is propagated.
-Otherwise, Reference returns an object whose discriminant is an access value
-that designates the element designated by Position. Program_Error is propagated if
-any operation tampers with the elements of Container while the object returned
-by Reference exists and has not been finalized.>
+@ddel
+@xcode<   @b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
 
-@xindent<The element designated by Position is not an empty element after successful
-completion of this operation.>
+!corrigendum A.18.9(61/2)
 
-!corrigendum A.18.2(225/2)
+@dinsa
+@xcode<   @b<procedure> Reverse_Iterate
+     (Container : @b<in> Set;
+      Process   : @b<not null access procedure> (Position : @b<in> Cursor));>
+@dinss
+@xcode<   @b<function> Iterate (Container : @b<in> Set)
+      @b<return> Set_Iterator_Interfaces.Reversible_Iterator'Class;>
 
-@ddel
-@xcode<@b<function> Has_Element (Position : Cursor) @b<return> Boolean;>
+!corrigendum A.18.9(73/2)
 
-!corrigendum A.18.2(226/2)
+@dinsa
+@xcode<   @b<procedure> Update_Element_Preserving_Key
+     (Container : @b<in out> Set;
+      Position  : @b<in>     Cursor;
+      Process   : @b<not null access procedure>
+                       (Key     : @b<in>     Key_Type;
+                        Element : @b<in out> Element_Type));>
+@dinss
+@xcode<      @b<type> Reference_Type (Element : @b<not null access> Element_Type) @b<is private>
+         @b<with> Implicit_Dereference =@> Element;
 
-@ddel
-@xindent<Returns True if Position designates an element, and returns False otherwise.>
+      @b<function> Reference_Preserving_Key (Container : @b<aliased in out> Set;
+                                       Position  : @b<in> Cursor)
+         @b<return> Reference_Type;
+
+      @b<function> Constant_Reference (Container : @b<aliased in> Set;
+                                   Key       : @b<in> Key_Type)
+         @b<return> Constant_Reference_Type;
+
+      @b<function> Reference_Preserving_Key (Container : @b<aliased in out> Set;
+                                       Key       : @b<in> Cursor)
+         @b<return> Reference_Type;>
 
-!corrigendum A.18.2(230/2)
+!corrigendum A.18.9(113/2)
 
 @dinsa
 @xindent<Iterates over the elements in Container as per Iterate, except that elements
-are traversed in reverse index order.>
+are traversed in predecessor order, starting with the last element.>
 @dinss
-@xcode<@b<function> Iterate (Container : @b<in> Vector)
-   @b<return> Iterators.Reversible_Iterator'Class;>
+@xcode<@b<function> Iterate (Container : @b<in> Set)
+   @b<return> Map_Iterator_Interfaces.Reversible_Iterator'Class;>
 
 @xindent<Iterate returns a reversible iterator object that will generate a
-loop parameter designating each node in Container, starting with
-the first node and moving the cursor as per the Next function when
-used as a forward iterator, and starting with the last node and moving
-the cursor as per the Previous function when used as a reverse iterator.
+loop parameter designating each element in Container, starting with
+the first element and moving the cursor according to the successor relation when
+used as a forward iterator, and starting with the last element and moving
+the cursor according to the predecessor relation when used as a reverse iterator.
 Program_Error is propagated if any operation (in
 particular, the @fa<sequence_of_statements> of the @fa<loop_statement> whose
 @fa<iterator_specification> denotes this object) tampers with the cursors of
 Container while the returned object exists. The returned object from
 Iterate needs finalization.>
 
-@xcode<@b<function> Iterate (Container : @b<in> Vector; Start : @b<in> Cursor)
-   @b<return> Iterators.Reversible_Iterator'Class;>
-
-@xindent<If Start is not No_Element and does not designate an item in Container, then Program_Error
-is propagated. If Start is No_Element, the call is equivalent to Iterate (Container).
-Otherwise, Iterate returns a reversible iterator object that will generate
-a loop parameter designating each node in Container, starting with the
-node designated by From and moving the cursor as per the Next function
-when used as a forward iterator, or moving the cursor as per the Previous
-function when used as a reverse iterator. Program_Error is propagated if
-any operation (in particular, the @fa<sequence_of_statements> of the
-@fa<loop_statement> whose @fa<iterator_specification> denotes this object) tampers
-with the cursors of Container while the returned object exists. The
-returned object from Iterate needs finalization.>
-
-!corrigendum A.18.2(252/2)
-
-@dinsa
-The result of "=" or Has_Element is unspecified if it is called with an invalid cursor parameter.
-Execution is erroneous if any other subprogram declared in Containers.Vectors is called with an
-invalid cursor parameter.
-@dinst
-Execution is erroneous if the vector associated with the result of a call to
-Reference or Constant_Reference is finalized before the result object returned
-by the call to Reference or Constant_Reference is finalized.
 
+!corrigendum A.18.10(0)
 
+@dinsc
 
+Force a conflict; the real text is in the conflict file.
 
 
 !corrigendum A.18.18(0)
@@ -1096,7 +2064,7 @@
 
 Force a conflict; the real text is in the conflict file.
 
-!corrigendum A.18.33(0)
+!corrigendum A.18.32(0)
 
 @dinsc
 
@@ -2110,7 +3078,8 @@
 > only text that specifies what cursors are returned, and in what order.
 > That had better be specified somewhere! If you have a better
 > suggestion that includes that text (which I don't want to have to
-> reorganize or reword, because that is very likely to be full of errors), I'd be glad to hear it.
+> reorganize or reword, because that is very likely to be full of errors), I'd be glad
+> to hear it.
 
 I was suggesting using the term "container element iterator" which is defined in
 the Iterator AI.  I see no reason to repeat the definition of an container
@@ -2310,5 +3279,45 @@
 defined individually for each container, that hardly is "one place". And if we
 did define the sequence separately from the iterators, that is only going to
 save about one sentence total in the RM. Is that really worth it??
+
+****************************************************************
+
+From: Randy Brukardt
+Sent: Thursday, July 28, 2011  1:43 AM
+
+I was explaining how empty elements work to Christoph Grein and noticed that the
+bounded error for the reading of empty elements was not updated to include the
+creation of a reference to an empty element.
+
+Since Reference is just a better version of Update_Element, and
+Constant_Reference is just a better version of Query_Element, we ought to be
+using the same rules for both (and Update_Element and Query_Element are in this
+bounded error).
+
+This seems absolutely necessary, as in the indefinite container case, the
+element has no tag/bounds/discriminants. How one could create a reference to
+something with no bounds or tag or discriminants escapes me. And assigning
+something into a reference to such an object and magically have an object with
+the right bounds/tag/discriminants appear doesn't seem any more possible.
+
+It's annoying that something like:
+
+   Cont(1) := 10;
+
+is a bounded error if the element (1) is an empty element, but that is already
+true for the Ada 2005 containers (using Update_Element) and it doesn't seem
+possible to avoid it without putting major constraints on the implementation (or
+making the indefinite version much more different).
+
+Of course, it is easy to avoid creating an empty element (don't use
+Insert_Space), so this is not a major hardship.
+
+So, Reference and Constant_Reference should be added to the list of routines in
+A.18.2(240/2).
+
+P.S. Reading an empty element is a bounded error so that it isn't required to
+have an "Is_Empty" bit with every element of a definite type. That seemed like
+overkill, especially for small elements like characters. If no exception is
+raised, the element must have a normal (but possibly invalid) value.
 
 ****************************************************************

Questions? Ask the ACAA Technical Agent