CVS difference for ais/ai-20302.txt

Differences between 1.7 and version 1.8
Log of other versions for file ais/ai-20302.txt

--- ais/ai-20302.txt	2004/07/27 23:01:10	1.7
+++ ais/ai-20302.txt	2004/07/31 04:19:42	1.8
@@ -1,4 +1,4 @@
-!standard A.17                                       04-06-29  AI95-00302-03/05
+!standard A.17                                       04-07-30  AI95-00302-03/05
 !class amendment 04-01-14
 !comment Date is provisional.
 !status work item 04-01-14
@@ -286,16 +286,16 @@
 
    type Hash_Type is mod <Implementation-Defined>;
 
-   type Size_Type is range 0 .. <implementation-defined>;
+   type Count_Type is range 0 .. <implementation-defined>;
 
 end Ada.Containers;
 
-Hash_Type represents the range of the result of a hash function. Size_Type
-represents the (potential or actual) size (number of elements) of a container.
+Hash_Type represents the range of the result of a hash function. Count_Type
+represents the (potential or actual) number of elements of a container.
 
 Implementation Advice
 
-Hash_Type'Modulus should be at least 2**32. Size_Type'Last should be at least
+Hash_Type'Modulus should be at least 2**32. Count_Type'Last should be at least
 2**31-1.
 
 AARM Note: This is not a requirement so that these types can be declared
@@ -311,7 +311,7 @@
 to its elements.
 
 A vector container object manages an unconstrained internal array, which
-expands as necessary as items are inserted. The *size* of a vector
+expands as necessary as items are inserted. The *capacity* of a vector
 corresponds to the total length of the internal array, and the *length*
 of a vector corresponds to the number of active elements in the internal
 array.
@@ -350,7 +350,7 @@
 
    subtype Index_Subtype is Index_Type;
 
-   type Vector is private;
+   type Vector is tagged private;
 
    type Cursor is private;
 
@@ -358,11 +358,11 @@
 
    No_Element : constant Cursor;
 
-   function To_Vector (Count : Size_Type) return Vector;
+   function To_Vector (Count : Count_Type) return Vector;
 
    function To_Vector
      (New_Item : Element_Type;
-      Count    : Size_Type) return Vector;
+      Count    : Count_Type) return Vector;
 
    function "&" (Left, Right : Vector) return Vector;
 
@@ -376,12 +376,12 @@
 
    function "=" (Left, Right : Vector) return Boolean;
 
-   function Size (Container : Vector) return Size_Type;
+   function Capacity (Container : Vector) return Count_Type;
 
-   procedure Resize (Container : in out Vector;
-                     Size      : in     Size_Type);
+   procedure Set_Capacity (Container : in out Vector;
+                           Count     : in     Count_Type);
 
-   function Length (Container : Vector) return Size_Type;
+   function Length (Container : Vector) return Count_Type;
 
    function Is_Empty (Container : Vector) return Boolean;
 
@@ -398,14 +398,14 @@
 
    function Element (Position : Cursor) return Element_Type;
 
-   generic
-      with procedure Process (Element : in out Element_Type) is <>;
-   procedure Generic_Update_by_Index (Container : in Vector;
-                                      Index     : in Index_Type'Base);
-
-   generic
-      with procedure Process (Element : in out Element_Type) is <>;
-   procedure Generic_Update (Position : in Cursor);
+   procedure Update_Element
+       (Container : in Vector;
+        Index     : in Index_Type'Base;
+        Process   : not null access procedure (Element : in out Element_Type));
+
+   procedure Update_Element
+       (Position : in Cursor;
+        Process : not null access procedure (Element : in out Element_Type));
 
    procedure Replace_Element (Container : in Vector;
                               Index     : in Index_Type'Base;
@@ -436,58 +436,58 @@
    procedure Insert (Container : in out Vector;
                      Before    : in     Index_Type'Base;
                      New_Item  : in     Element_Type;
-                     Count     : in     Size_Type := 1);
+                     Count     : in     Count_Type := 1);
 
    procedure Insert (Container : in out Vector;
                      Before    : in     Cursor;
                      New_Item  : in     Element_Type;
-                     Count     : in     Size_Type := 1);
+                     Count     : in     Count_Type := 1);
 
    procedure Insert (Container : in out Vector;
                      Before    : in     Cursor;
                      New_Item  : in     Element_Type;
                      Position  :    out Cursor;
-                     Count     : in     Size_Type := 1);
+                     Count     : in     Count_Type := 1);
 
    procedure Prepend (Container : in out Vector;
                       New_Item  : in     Vector);
 
    procedure Prepend (Container : in out Vector;
                       New_Item  : in     Element_Type;
-                      Count     : in     Size_Type := 1);
+                      Count     : in     Count_Type := 1);
 
    procedure Append (Container : in out Vector;
                      New_Item  : in     Vector);
 
    procedure Append (Container : in out Vector;
                      New_Item  : in     Element_Type;
-                     Count     : in     Size_Type := 1);
+                     Count     : in     Count_Type := 1);
 
    procedure Insert_Space (Container : in out Vector;
                            Before    : in     Index_Type'Base;
-                           Count     : in     Size_Type := 1);
+                           Count     : in     Count_Type := 1);
 
    procedure Insert_Space (Container : in out Vector;
                            Before    : in     Cursor;
                            Position  :    out Cursor;
-                           Count     : in     Size_Type := 1);
+                           Count     : in     Count_Type := 1);
 
    procedure Set_Length (Container : in out Vector;
-                         Length    : in     Size_Type);
+                         Length    : in     Count_Type);
 
    procedure Delete (Container : in out Vector;
                      Index     : in     Index_Type'Base;
-                     Count     : in     Size_Type := 1);
+                     Count     : in     Count_Type := 1);
 
    procedure Delete (Container : in out Vector;
                      Position  : in out Cursor;
-                     Count     : in     Size_Type := 1);
+                     Count     : in     Count_Type := 1);
 
    procedure Delete_First (Container : in out Vector;
-                           Count     : in     Size_Type := 1);
+                           Count     : in     Count_Type := 1);
 
    procedure Delete_Last (Container : in out Vector;
-                          Count     : in     Size_Type := 1);
+                          Count     : in     Count_Type := 1);
 
    function First_Index (Container : Vector) return Index_Type;
 
@@ -549,14 +549,14 @@
 
    function Has_Element (Position : Cursor) return Boolean;
 
-   generic
-      with procedure Process (Position : in Cursor) is <>;
-   procedure Generic_Iteration (Container : in Vector);
+   procedure Iteration
+       (Container : in Vector;
+        Process : not null access procedure (Element : in out Element_Type));
+
+   procedure Reverse_Iteration
+       (Container : in Vector;
+        Process : not null access procedure (Element : in out Element_Type));
 
-   generic
-      with procedure Process (Position : in Cursor) is <>;
-   procedure Generic_Reverse_Iteration (Container : in Vector);
-
 private
 
    ... -- not specified by the language
@@ -574,7 +574,7 @@
 Cursor is not otherwise initialized, it will be initialized to the same
 value as No_Element.
 
-function To_Vector (Count : Size_Type) return Vector;
+function To_Vector (Count : Count_Type) return Vector;
 
 Returns a vector with a length of Count. The vector is filled with empty
 elements.
@@ -582,7 +582,7 @@
 
 function To_Vector
   (New_Item : Element_Type;
-   Count    : Size_Type) return Vector;
+   Count    : Count_Type) return Vector;
 
 Returns a vector with a length of Count, and elements initialized to the
 value New_Item.
@@ -619,39 +619,44 @@
 during evaluation of element equality are propagated.
 
 
-function Size (Container : Vector) return Size_Type;
+function Capacity (Container : Vector) return Count_Type;
 
 Returns the length of the internal array.
 
 
-procedure  Resize (Container : in out Vector;
-                  Size      : in     Size_Type);
+procedure  Set_Capacity (Container : in out Vector;
+                         Count     : in     Count_Type);
 
-If Size (Container) is equal to or greater than Size, the operation does
-nothing. Otherwise Resize sets the size of Container to a value which is
-at least the value Size, expanding the internal array to hold Size elements.
-Expansion will require allocation, and possibly copying and deallocation of
-elements. Any exceptions raised by these operations are propagated, leaving
-the container with at least the original Size, Length, and elements.
+If Length (Container) > Count, Constraint_Error is raised. Otherwise,
+Set_Capacity sets the capacity of Container to a value which is at least the
+value Count, expanding (or contracting) the internal array to hold at least
+Count elements. Expansion or contraction will require allocation, and possibly
+copying and deallocation of elements. Any exceptions raised by these operations
+are propagated, leaving the container with at least the original Length and
+elements.
 
 AARM Notes
 
 Expanding the internal array can be done by allocating a new, longer array,
 copying the elements, and deallocating the original array. This may raise
 Storage_Error, or cause an exception from a controlled subprogram. We require
-that a failed Resize does not lose any elements if an exception occurs, but
-we do not require a specific order of evaluations or copying.
+that a failed Set_Capacity does not lose any elements if an exception occurs,
+but we do not require a specific order of evaluations or copying.
 
 This routine is used to preallocate the internal array to the specified
-size such that future Inserts do not require memory allocation overhead.
+capacity such that future Inserts do not require memory allocation overhead.
 Therefore, the implementation should allocate the needed memory to make that
 true at this point, even though the visible semantics could be preserved by
 waiting until the memory is needed. This doesn't apply to the indefinite
 element container, because elements will have to be allocated individually.
 
+The implementation does not have to contract the internal array if the
+capacity is reduced, as any capacity greater than or equal to the specified
+capacity is allowed.
+
 End AARM Notes
 
-function Length (Container : Vector) return Size_Type;
+function Length (Container : Vector) return Count_Type;
 
 The Length function returns the number of active elements in Container.
 
@@ -663,7 +668,7 @@
 
 procedure Clear (Container : in out Vector);
 
-Sets the length of Vector to 0. Its size does not change.
+Sets the length of Vector to 0. Its capacity does not change.
 
 
 function To_Cursor (Container : Vector;
@@ -702,15 +707,15 @@
 Returns the element designated by Position. If Position equals No_Element,
 then Constraint_Error is propagated.
 
-generic
-   with procedure Process (Element : in out Element_Type) is <>;
-procedure Generic_Update_by_Index (Container : in Vector;
-                                   Index     : in Index_Type'Base);
+procedure Update_Element
+    (Container : in Vector;
+     Index     : in Index_Type'Base;
+     Process   : not null access procedure (Element : in out Element_Type));
 
 If Index is not in the range First_Index (Container) .. Last_Index (Container),
-then Constraint_Error is propagated. Otherwise, it calls the generic actual
-bound to Process with the element at position Index as the parameter. Any
-exceptions raised by Process are propagated.
+then Constraint_Error is propagated. Otherwise, it calls Process.all with the
+element at position Index as the parameter. Any exceptions raised by Process
+are propagated.
 
 If Element_Type is unconstrained and definite, then the Element parameter
 shall be unconstrained.
@@ -726,15 +731,14 @@
 use this procedure to replace empty elements may fail. Use Replace_Element
 to do that reliably.
 
-generic
-    with procedure Process (Element : in out Element_Type) is <>;
-procedure Generic_Update (Position : in Cursor);
+procedure Update_Element
+   (Position : in Cursor;
+    Process : not null access procedure (Element : in out Element_Type));
+
+Calls Process.all with the element designated by Position as the parameter. If
+Position equals No_Element, then Constraint_Error is propagated. Any exceptions
+raised by Process are propagated.
 
-Calls the generic actual bound to Process with the element designated by
-Position as the parameter. If Position equals No_Element, then
-Constraint_Error is propagated. Any exceptions raised by Process are
-propagated.
-
 If Element_Type is unconstrained and definite, then the Element parameter
 shall be unconstrained.
 
@@ -760,19 +764,19 @@
 designated by Position is not an empty element after successful completion of
 this operation.
 
-AARM Note: Replace_Element, Generic_Update, and Generic_Update_by_Index are
-the only ways that an element can change from empty to non-empty.
+AARM Note: Replace_Element and Update_Element are the only ways that an element
+can change from empty to non-empty.
 
 
 procedure Assign (Target : in out Vector;
                   Source : in     Vector);
 
 If Target denotes the same object as Source, then the operation has no
-effect. Otherwise, Assign first calls Clear (Target), then Resize (Target,
-Length (Source)). It then assigns the active elements of Source to the
-corresponding positions in Target, and then sets the length of Target to
-the length of Source. Any exceptions raised during element assignment
-are propagated.
+effect. Otherwise, Assign first calls Clear (Target), then
+Set_Capacity (Target, Length (Source)). It then assigns the active elements
+of Source to the corresponding positions in Target, and then sets the length
+of Target to the length of Source. Any exceptions raised during element
+assignment are propagated.
 
 
 procedure Move (Target : in out Vector;
@@ -780,17 +784,18 @@
 
 If Target denotes the same object as Source, then the operation has no
 effect. If Length (Target) is greater than 0, then it raises Constraint_Error.
-Otherwise, the internal array is removed from Source (making its size 0) and
-moved to Target (making its size the original size of Source). The length of
-Target is set to the length of Source, and the length of Source is set to 0.
+Otherwise, the internal array is removed from Source (making its capacity 0)
+and moved to Target (making its capacity the original capacity of Source). The
+length of Target is set to the length of Source, and the length of Source is
+set to 0.
 
 AARM Note:
 
-If Size (Target) /= 0, the previous internal array may need to be deallocated.
-We don't mention this explicitly, because it is covered by the "no memory
-loss" Implementation Requirement. If the deallocation raises an exception,
-the implementation should leave both Vectors in a consistent state (usually
-empty for Target and the original state for Source).
+If Capacity (Target) /= 0, the previous internal array may need to be
+deallocated. We don't mention this explicitly, because it is covered by the
+"no memory loss" Implementation Requirement. If the deallocation raises an
+exception, the implementation should leave both Vectors in a consistent state
+(usually empty for Target and the original state for Source).
 
 
 procedure Insert (Container : in out Vector;
@@ -804,16 +809,17 @@
 not in the range First_Index (Container) .. Index_Type'Succ (Last_Index
 (Container)), then Constraint_Error is propagated.
 
-If the current vector size is less than or equal to the new length, Resize
-(Container, NL) is called to increase the vector size. Then Insert slides the
-elements in the range Before .. Last_Index (Container) up by Length(New_Item)
-positions, and then copies the elements of New_Item to the positions starting
-at Before. Any exceptions raised during the copying are propagated.
+If the current vector capacity is less than or equal to the new length,
+Set_Capacity (Container, NL) is called to increase the vector capacity. Then
+Insert slides the elements in the range Before .. Last_Index (Container) up by
+Length(New_Item) positions, and then copies the elements of New_Item to the
+positions starting at Before. Any exceptions raised during the copying are
+propagated.
 
 AARM Note
 
 Moving the elements does not necessarily involve copying. Similarly, since
-Resize does not require the copying of elements, it does not need to be
+Set_Capacity does not require the copying of elements, it does not need to be
 explicitly called (the implementation can combine the operations if it wishes
 to). [Note to reviewers: I didn't want to duplicate the messy wording and notes
 about exceptions not losing anything.]
@@ -846,7 +852,7 @@
 procedure Insert (Container : in out Vector;
                   Before    : in     Index_Type'Base;
                   New_Item  : in     Element_Type;
-                  Count     : in     Size_Type := 1);
+                  Count     : in     Count_Type := 1);
 
 Equivalent to Insert (Container, Before, To_Vector (New_Item, Count));
 
@@ -854,7 +860,7 @@
 procedure Insert (Container : in out Vector;
                   Before    : in     Cursor;
                   New_Item  : in     Element_Type;
-                  Count     : in     Size_Type := 1);
+                  Count     : in     Count_Type := 1);
 
 Equivalent to Insert (Container, Before, To_Vector (New_Item, Count));
 
@@ -863,21 +869,21 @@
                   Before    : in     Cursor;
                   New_Item  : in     Element_Type;
                   Position  :    out Cursor;
-                  Count     : in     Size_Type := 1);
+                  Count     : in     Count_Type := 1);
 
 Equivalent to Insert (Container, Before, To_Vector (New_Item, Count), Position);
 
 
 procedure Prepend (Container : in out Vector;
                    New_Item  : in     Vector;
-                   Count     : in     Size_Type := 1);
+                   Count     : in     Count_Type := 1);
 
 Equivalent to Insert (Container, Index_Type'First, New_Item).
 
 
 procedure Prepend (Container : in out Vector;
                    New_Item  : in     Element_Type;
-                   Count     : in     Size_Type := 1);
+                   Count     : in     Count_Type := 1);
 
 Equivalent to Insert (Container, Index_Type'First, New_Item, Count).
 
@@ -891,7 +897,7 @@
 
 procedure Append (Container : in out Vector;
                   New_Item  : in     Element_Type;
-                  Count     : in     Size_Type := 1);
+                  Count     : in     Count_Type := 1);
 
 Equivalent to Insert (Container, Index_Type'Succ (Last_Index (Container)),
 New_Item, Count).
@@ -899,7 +905,7 @@
 
 procedure Insert_Space (Container : in out Vector;
                         Before    : in     Index_Type'Base;
-                        Count     : in     Size_Type := 1);
+                        Count     : in     Count_Type := 1);
 
 Equivalent to Insert (Container, Before, New_Item, Count), with the
 difference that the inserted elements are empty elements.
@@ -908,7 +914,7 @@
 procedure Insert_Space (Container : in out Vector;
                         Before    : in     Cursor;
                         Position  :    out Cursor;
-                        Count     : in     Size_Type := 1);
+                        Count     : in     Count_Type := 1);
 
 Create a temporary (call it Temp_Index) and set it to
 Index_Type'Succ (Last_Index (Container)) if Before equals No_Element, and
@@ -918,16 +924,16 @@
 
 
 procedure Set_Length (Container : in out Vector;
-                      Length    : in     Size_Type);
+                      Length    : in     Count_Type);
 
-Calls Resize (Length), then sets the length of the Container to Length.
-If Length is greater than the original length of Container, the added
-elements are empty elements.
+Calls Set_Capacity (Container, Length), then sets the length of the Container
+to Length. If Length is greater than the original length of Container, the
+added elements are empty elements.
 
 
 procedure Delete (Container : in out Vector;
                   Index     : in     Index_Type'Base;
-                  Count     : in     Size_Type := 1);
+                  Count     : in     Count_Type := 1);
 
 If Count is 0, the operation has no effect. If Index does not specify a
 value in the range First_Index (Container) .. Last_Index (Container), then
@@ -940,18 +946,18 @@
 
 procedure Delete (Container : in out Vector;
                   Position  : in out Cursor;
-                  Count     : in     Size_Type := 1);
+                  Count     : in     Count_Type := 1);
 
 If Count is 0, the operation has no effect. Otherwise is equivalent to
 Delete (Container, To_Index (Position), Count).
 
 procedure Delete_First (Container : in out Vector;
-                        Count     : in     Size_Type := 1);
+                        Count     : in     Count_Type := 1);
 
 Equivalent to Delete (Container, Index_Type'First, Count).
 
 procedure Delete_Last (Container : in out Vector;
-                       Count     : in     Size_Type := 1);
+                       Count     : in     Count_Type := 1);
 
 If Length (Container) < Count then is equivalent to
 Delete (Container, Index_Type'First, Count); otherwise
@@ -959,6 +965,8 @@
 Index_Type'Val(Index_Type'Pos(Last_Index(Container)) - Count + 1), Count).
 
 
+function First_Index (Container : Vector) return Index_Type'Base;
+
 Returns the value Index_Type'First.
 
 AARM Note: We'd rather call this "First", but then calling most routines in
@@ -976,7 +984,7 @@
 
 function Last_Index (Container : Vector) return Index_Type'Base;
 
-Returns the position of the last element in Vector.
+Returns the position of the last element in Container.
 
 
 function Last (Container : Vector) return Cursor;
@@ -1011,7 +1019,7 @@
    with function "<" (Left, Right : Element_Type) return Boolean is <>;
 procedure Generic_Sort (Container : in Vector);
 
-Reorders the elements of Vector such that the elements are
+Reorders the elements of Container such that the elements are
 sorted smallest first as determined by the generic formal "<" operator
 provided. Any exceptions raised during evalution of "<" are propagated.
 
@@ -1109,20 +1117,19 @@
 AARM Note: To Be Honest: This function may not detect cursors that
 designate deleted elements; such cursors are invalid (see below) and any
 use of them (including in this routine) is erroneous.
-
-generic
-  with procedure Process (Position : in Cursor) is <>;
-procedure Generic_Iteration (Container : in Vector);
 
-Invokes the actual subprogram bound to Process with a cursor that
-designates each element in Container, in index order. Any exceptions raised
-during Process are propagated.
-
-generic
-  with procedure Process (Position : in Cursor) is <>;
-procedure Generic_Reverse_Iteration (Container : in Vector);
+procedure Iteration
+   (Container : in Vector;
+    Process : not null access procedure (Element : in out Element_Type));
+
+Invokes Process.all with a cursor that designates each element in Container, in
+index order. Any exceptions raised during Process are propagated.
+
+procedure Reverse_Iteration
+   (Container : in Vector;
+    Process : not null access procedure (Element : in out Element_Type));
 
-Iterates over the nodes in Container as per Generic_Iteration, except
+Iterates over the nodes in Container as per Iteration, except
 that elements are traversed in reverse order.
 
 
@@ -1135,17 +1142,17 @@
 the Implementation Requirements are met. These would require all instantiations
 to occur at the library level. We certainly do not want to require magic
 for nested container instantiations, while not giving similar capabilities to
-users. We've made this a legality rule to enhance portability. This rule can
+users. We've made this a legality rule to enhance portability. This rule will
 be dropped if AI-344 or some other solution to nested controlled types is
 adopted.
 
 Bounded (Run-Time) Errors
 
-Reading the value of an empty element by calling Element, Generic_Update,
-Generic_Update_By_Index, Generic_Sort, "=", Find, or Reverse_Find is a bounded
-error. The implementation may treat the element as having any valid value of
-the element type, or raise Constraint_Error or Program_Error before modifying
-the vector.
+Reading the value of an empty element by calling Element, Update_Element,
+Generic_Sort, "=", Find, or Reverse_Find is a bounded error. The
+implementation may treat the element as having any valid value of the
+element type, or raise Constraint_Error or Program_Error before modifying the
+vector.
 
 AARM Notes: For instance, a default initialized element could be returned. Or
 some previous value of an element. But returning random junk is not allowed
@@ -1283,7 +1290,7 @@
 package Ada.Containers.Doubly_Linked_Lists is
    pragma Preelaborate (Doubly_Linked_Lists);
 
-   type List is private;
+   type List is tagged private;
 
    type Cursor is private;
 
@@ -1303,9 +1310,9 @@
    function Element (Position : Cursor)
       return Element_Type;
 
-   generic
-      with procedure Process (Element : in out Element_Type) is <>;
-   procedure Generic_Update (Position : in Cursor);
+   procedure Update_Element
+       (Position : in Cursor;
+        Process : not null access procedure (Element : in out Element_Type));
 
    procedure Replace_Element (Position : in Cursor;
                               By       : in Element_Type);
@@ -1315,46 +1322,38 @@
 
    procedure Prepend (Container : in out List;
                       New_Item  : in     Element_Type;
-                      Count     : in     Size_Type := 1);
+                      Count     : in     Count_Type := 1);
 
    procedure Append (Container : in out List;
                      New_Item  : in     Element_Type;
-                     Count     : in     Size_Type := 1);
+                     Count     : in     Count_Type := 1);
 
    procedure Insert (Container : in out List;
                      Before    : in     Cursor;
                      New_Item  : in     Element_Type;
-                     Count     : in     Size_Type := 1);
+                     Count     : in     Count_Type := 1);
 
    procedure Insert (Container : in out List;
                      Before    : in     Cursor;
                      New_Item  : in     Element_Type;
                      Position  :    out Cursor;
-                     Count     : in     Size_Type := 1);
+                     Count     : in     Count_Type := 1);
 
    procedure Insert (Container : in out List;
                      Before    : in     Cursor;
                      Position  :    out Cursor;
-                     Count     : in     Size_Type := 1);
+                     Count     : in     Count_Type := 1);
 
    procedure Delete (Container : in out List;
                      Position  : in out Cursor;
-                     Count     : in     Size_Type := 1);
+                     Count     : in     Count_Type := 1);
 
    procedure Delete_First (Container : in out List;
-                           Count     : in     Size_Type := 1);
+                           Count     : in     Count_Type := 1);
 
    procedure Delete_Last (Container : in out List;
-                          Count     : in     Size_Type := 1);
+                          Count     : in     Count_Type := 1);
 
-   procedure Delete (Container : in out List;
-                     Item      : in     Element_Type);
-
-   generic
-      with function Predicate (Element : Element_Type)
-         return Boolean is <>;
-   procedure Generic_Delete (Container : in out List);
-
    generic
       with function "<" (Left, Right : Element_Type)
          return Boolean is <>;
@@ -1402,25 +1401,11 @@
                   Position  : Cursor := No_Element)
       return Cursor;
 
-   generic
-      with function Predicate (Element : Element_Type)
-         return Boolean is <>;
-   function Generic_Find (Container : List;
-                          Position  : Cursor := No_Element)
-      return Cursor;
-
    function Reverse_Find (Container : List;
                           Item      : Element_Type;
                           Position  : Cursor := No_Element)
       return Cursor;
 
-   generic
-      with function Predicate (Element : Element_Type)
-         return Boolean is <>;
-   function Generic_Reverse_Find (Container : List;
-                                  Position  : Cursor := No_Element)
-      return Cursor;
-
    function Next (Position : Cursor) return Cursor;
 
    function Previous (Position : Cursor) return Cursor;
@@ -1431,13 +1416,13 @@
 
    function Has_Element (Position : Cursor) return Boolean;
 
-   generic
-      with procedure Process (Position : in Cursor) is <>;
-   procedure Generic_Iteration (Container : in List);
-
-   generic
-      with procedure Process (Position : in Cursor) is <>;
-   procedure Generic_Reverse_Iteration (Container : in List);
+   procedure Iteration
+       (Container : in List;
+        Process : not null access procedure (Element : in out Element_Type));
+
+   procedure Reverse_Iteration
+       (Container : in List;
+        Process : not null access procedure (Element : in out Element_Type));
 
 private
 
@@ -1475,16 +1460,16 @@
 
 function Element (Position : Cursor) return Element_Type;
 
-Returns the element stored on the node designated by Cursor. If
+Returns the element stored on the node designated by Position. If
 Position equals No_Element, then Constraint_Error is propagated.
 
-generic
-   with procedure Process (Element : in out Element_Type) is <>;
-procedure Generic_Update (Position : in Cursor);
+procedure Update_Element
+   (Position : in Cursor;
+    Process : not null access procedure (Element : in out Element_Type));
 
 If Position equals No_Element, then Constraint_Error is propagated. Otherwise,
-Generic_Update invokes the generic actual procedure bound to Process
-with the element on node designated by Position as the argument.
+Update_Element invokes Process.all with the element on node designated by
+Position as the argument.
 
 If Element_Type is unconstrained and definite, then the Element parameter
 shall be unconstrained.
@@ -1516,7 +1501,7 @@
 procedure Insert (Container : in out List;
                   Before    : in     Cursor;
                   New_Item  : in     Element_Type;
-                  Count     : in     Size_Type := 1);
+                  Count     : in     Count_Type := 1);
 
 Insert allocates Count new nodes whose element is initialized to the value
 New_Item, and inserts them prior to the node designated by Before. If
@@ -1528,7 +1513,7 @@
                   Before    : in     Cursor;
                   New_Item  : in     Element_Type;
                   Position  :    out Cursor;
-                  Count     : in     Size_Type := 1);
+                  Count     : in     Count_Type := 1);
 
 Insert allocates Count new nodes whose element is initialized to the value
 New_Item, and inserts them prior to the node designated by Before. If
@@ -1540,7 +1525,7 @@
 procedure Insert (Container : in out List;
                   Before    : in     Cursor;
                   Position  :    out Cursor;
-                  Count     : in     Size_Type := 1);
+                  Count     : in     Count_Type := 1);
 
 Allocates Count new nodes with elements initialized with any implicit initial
 values for any part (as for an object_declaration with no initialization
@@ -1552,7 +1537,7 @@
 
 procedure Delete (Container : in out List;
                   Position  : in out Cursor;
-                  Count     : in     Size_Type := 1);
+                  Count     : in     Count_Type := 1);
 
 If Position equals No_Element, the operation has no effect. Otherwise
 Delete removes Count nodes starting at the node designated by Position
@@ -1561,34 +1546,20 @@
 storage are propagated.
 
 procedure Delete_First (Container : in out List;
-                        Count     : in     Size_Type := 1);
+                        Count     : in     Count_Type := 1);
 
 If Length(Container) >= Count, Delete_First removes the first Count nodes from
 Container; otherwise, all of the nodes in Container are removed. Any exceptions
 raised during deallocation of storage are propagated.
 
 procedure Delete_Last (Container : in out List;
-                       Count     : in     Size_Type := 1);
+                       Count     : in     Count_Type := 1);
 
 If Length(Container) >= Count, Delete_Last removes the last Count nodes from
 Container; otherwise, all of the nodes in Container are removed. Any exceptions
 raised during deallocation of storage are propagated.
 
-procedure Delete (Container : in out List;
-                  Item      : in     Element_Type);
-
-Equivalent to Generic_Delete instantiated with a predicate function
-implemented in terms of the equality operator for Element_Type.
-
 generic
-   with function Predicate (Element : Element_Type)
-      return Boolean is <>;
-procedure Generic_Delete (Container : in out List);
-
-Deletes each element in Container for which the generic formal function
-Predicate returns True.
-
-generic
    with function "<" (Left, Right : Element_Type) return Boolean is <>;
 procedure Generic_Sort (Container : in out List);
 
@@ -1699,19 +1670,6 @@
 No_Element, then the search begins at the first node. If no element is
 found that matches Item, then Find returns the value No_Element.
 
-generic
-   with function Predicate (Element : Element_Type)
-      return Boolean is <>;
-function Generic_Find (Container : List;
-                       Position  : Cursor := No_Element)
-   return Cursor;
-
-Searches the nodes of Container for an element for which the generic
-formal Predicate function returns True. The search starts at the node
-designated by Position. If Position equals No_Element, then the search
-begins at the first node. If no element is found for which Predicate
-returns True, then Generic_Find returns the value No_Element.
-
 function Reverse_Find (Container : List;
                        Item      : Element_Type;
                        Position  : Cursor := No_Element)
@@ -1723,20 +1681,6 @@
 element is found that matches Item, then Find returns the value
 No_Element.
 
-generic
-   with function Predicate (Element : Element_Type)
-      return Boolean is <>;
-function Generic_Reverse_Find (Container : List;
-                               Position  : Cursor := No_Element)
-   return Cursor;
-
-Searches the nodes of Container in reverse for an element for which the
-generic formal Predicate function returns True. The search starts at
-the node designated by Position. If Position equals No_Element, then
-the search begins at the last node. If no element is found for which
-Predicate returns True, then Generic_Reverse_Find returns the value
-No_Element.
-
 function Next (Position : Cursor) return Cursor;
 
 If Position equals No_Element or designates the last node of the container,
@@ -1760,20 +1704,19 @@
 AARM Note: To Be Honest: This function may not detect cursors that
 designate deleted elements; such cursors are invalid (see below) and any
 use of them (including in this routine) is erroneous.
-
-generic
-   with procedure Process (Position : in Cursor) is <>;
-procedure Generic_Iteration (Container : in List);
 
-Invokes the actual subprogram bound to Process with a cursor that
-designates each node in Container. Any exceptions raised during Process
-are propagated.
-
-generic
-   with procedure Process (Position : in Cursor) is <>;
-procedure Generic_Reverse_Iteration (Container : in List);
+procedure Iteration
+   (Container : in List;
+    Process : not null access procedure (Element : in out Element_Type));
+
+Invokes Process.all with a cursor that designates each node in Container. Any
+exceptions raised during Process are propagated.
+
+procedure Reverse_Iteration
+   (Container : in List;
+    Process : not null access procedure (Element : in out Element_Type));
 
-Iterates over the nodes in Container as per Generic_Iteration, except
+Iterates over the nodes in Container as per Iteration, except
 that elements are traversed in reverse order.
 
 Erroneous Execution
@@ -1855,9 +1798,11 @@
    type Key_Type is private;
 
    type Element_Type is private;
+
+   with function Hash (Key : Key_Type) return Hash_Type;
 
-   with function Hash (Key : Key_Type)
-      return Hash_Type is <>;
+   with function "=" (Left, Right : Key_Type)
+      return Boolean is <>;
 
    with function Is_Equal_Key (Left, Right : Key_Type)
       return Boolean is "=";
@@ -1868,7 +1813,7 @@
 package Ada.Containers.Hashed_Maps is
    pragma Preelaborate (Hashed_Maps);
 
-   type Map is private;
+   type Map is tagged private;
 
    type Cursor is private;
 
@@ -1878,7 +1823,7 @@
 
    function "=" (Left, Right : Map) return Boolean;
 
-   function Length (Container : Map) return Size_Type;
+   function Length (Container : Map) return Count_Type;
 
    function Is_Empty (Container : Map) return Boolean;
 
@@ -1887,9 +1832,9 @@
    function Element (Position : Cursor)
       return Element_Type;
 
-   generic
-      with procedure Process (Element : in out Element_Type) is <>;
-   procedure Generic_Update (Position : in Cursor);
+   procedure Update_Element
+      (Position : in Cursor;
+       Process : not null access procedure (Element : in out Element_Type));
 
    procedure Replace_Element (Position : in Cursor;
                               By       : in Element_Type);
@@ -1930,10 +1875,10 @@
                      Key       : Key_Type)
       return Element_Type;
 
-   function Size (Container : Map) return Size_Type;
+   function Capacity (Container : Map) return Count_Type;
 
-   procedure Resize (Container : in out Map;
-                     Size      : in     Size_Type);
+   procedure Set_Capacity (Container : in out Map;
+                           Capacity      : in     Count_Type);
 
    function First (Container : Map)
       return Cursor;
@@ -1957,9 +1902,9 @@
                           Right : Cursor)
       return Boolean;
 
-   generic
-      with procedure Process (Position : in Cursor) is <>;
-   procedure Generic_Iteration (Container : in Map);
+   procedure Iteration
+       (Container : in Map;
+        Process : not null access procedure (Element : in out Element_Type));
 
 private
 
@@ -1968,9 +1913,9 @@
 end Ada.Containers.Hashed_Maps;
 
 An object of type Map contains an expandable hash table, which is used to
-provide direct access to elements. The *size* of an object of type Map is the
-maximum number of elements that can be inserted into the hash table prior to it
-being automatically expanded ("resized"). The *length* of an object of type Map
+provide direct access to elements. The *capacity* of an object of type Map is
+the maximum number of elements that can be inserted into the hash table prior
+to it being automatically expanded. The *length* of an object of type Map
 object is the number of elements it contains. If an object of type Map is not
 otherwise initialized, it will be initialized with a length of 0.
 
@@ -1985,7 +1930,7 @@
 it is too small, with linked lists hanging off of each bucket.
 Note that in that implementation a cursor needs a back pointer to the Map
 object to implement iteration; that could either be in the nodes, or
-in the cursor object. To provide an average O(1) access time, size would
+in the cursor object. To provide an average O(1) access time, capacity would
 typically equal the number of buckets in such an implementation, so
 that the average bucket linked list length would be no more than 1.0.
 
@@ -2036,17 +1981,23 @@
 
 If Left and Right denote the same map Map object, then the function returns
 immediately the value True. If Left and Right have different lengths, then the
-function returns the value False. Otherwise, it compares elements (and *only*
-elements -- keys do not participate in the computation of Map equality) in
-canonical order using the generic formal equality operator for elements. Any
-exception raised during evaluation of element equality is propagated.
+function returns the value False. Otherwise, for each key K in Left, the
+function returns False if:
+  * K is not present in Right (using the generic formal equality operator for
+    keys); or
+  * the element associated with K in Left is not equivalent to the element
+    associated with K in Right (using the generic formal equality operator for
+    elements).
+If the function has not returned a result after checking all of the keys, the
+function returns True. Any exception raised during evaluation of key or element
+equality is propagated.
 
 The function Length returns the number of key/element pairs in Map.
 
 The function Is_Empty is equivalent to Length (Container) = 0.
 
-Clear removes all the elements from Map. The size of Map is not affected. Any
-exceptions raised during deallocation of storage propagated.
+Clear removes all the elements from Map. The capacity of Map is not affected.
+Any exceptions raised during deallocation of storage propagated.
 
 
 function Element (Position : Cursor) return Element_Type;
@@ -2054,13 +2005,13 @@
 If Position equals No_Element, then Constraint_Error is propagated.
 Otherwise, this operation returns the element designated by Position.
 
-generic
-   with procedure Process (Element : in out Element_Type) is <>;
-procedure Generic_Update (Position : in Cursor);
+procedure Update_Element
+   (Position : in Cursor;
+    Process : not null access procedure (Element : in out Element_Type));
 
 If Position equals No_Element, then Constraint_Error is propagated. Otherwise,
-Generic_Update invokes the generic actual procedure bound to Process
-with the element designated by Position as the argument.
+Update_Element invokes Process.all with the element designated by Position as
+the argument.
 
 procedure Replace_Element (Position : in Cursor;
                            By       : in Element_Type);
@@ -2076,8 +2027,8 @@
 If Target denotes the same object as Source, then this operation has no effect.
 If the length of Target is greater than 0, then Move raises Constraint_Error.
 Otherwise, the internal hash table of Target is deallocated; then the internal
-hash table is removed from Source and moved to Target. Source has size 0 after
-a successful call to Move.
+hash table is removed from Source and moved to Target. Source has capacity 0
+after a successful call to Move.
 
 procedure Insert (Container : in out Map;
                   Key       : in     Key_Type;
@@ -2085,24 +2036,24 @@
                   Position  :    out Cursor;
                   Success   :    out Boolean);
 
-If Length (Container) equals Size (Container), then Insert calls Resize to
-resize Container to some larger value. Insert then uses Hash and Is_Equal_Key
-to check if Key is already present in Container. If a key matches, Success
-returns False and Position designates the element with the matching key.
-Otherwise, Insert allocates a new node, initializes it to Key and New_Item, and
-adds it to Container. Success returns True and Position designates the
-newly-inserted node. Any exceptions raised during allocation are propagated
-and Container is not modified.
+If Length (Container) equals Capacity (Container), then Insert calls
+Set_Capacity to increase the capacity of Container to some larger value. Insert
+then uses Hash and Is_Equal_Key to check if Key is already present in
+Container. If a key matches, Success returns False and Position designates the
+element with the matching key. Otherwise, Insert allocates a new node,
+initializes it to Key and New_Item, and adds it to Container. Success returns
+True and Position designates the newly-inserted node. Any exceptions raised
+during allocation are propagated and Container is not modified.
 
 AARM Notes:
 Insert should only compare elements that hash to the same bucket in the hash
 table.
 
-We specify when Resize is called to bound the overhead of resize operations
-(which are potentially expensive). Moreover, expansion can be predicted by
-comparing Size(Map) to Length(Map). Since we don't specify by how much the hash
-table is expanded, this only can be used to predict the next expansion, not
-later ones.
+We specify when Set_Capacity is called to bound the overhead of capacity
+expansion operations (which are potentially expensive). Moreover, expansion can
+be predicted by comparing Capacity(Map) to Length(Map). Since we don't specify
+by how much the hash table is expanded, this only can be used to predict the
+next expansion, not later ones.
 End AARM Notes.
 
 procedure Replace (Container : in out Map;
@@ -2159,24 +2110,30 @@
 
 The function Element is equivalent to Element (Find (Container, Key)).
 
-The function Size returns the size of Container.
+The function Capacity returns the capacity of Container.
 
-procedure Resize (Container : in out Map;
-                  Size      : in     Size_Type);
+procedure Set_Capacity (Container : in out Map;
+                        Count     : in     Count_Type);
 
-If Size (Container) is equal to or greater than Size, this operation has no
-effect. Otherwise, it allocates a new hash table such that the length of the
-resulting map can become at least the value Size without requiring an
-additional Resize operation. If the allocation fails, the exception is
+If Length (Container) > Count, then Constraint_Error is propogated.
+Otherwise, it allocates a new hash table such that the length of the
+resulting map can become at least the value Count without requiring an
+additional Set_Capacity operation. If the allocation fails, the exception is
 propagated and Container is not modified. It then rehashes the nodes in
 Container onto the new hash table. It replaces the old hash table with the new
 hash table, and then deallocates the old hash table.
 
-AARM Note: This routine is used to preallocate the internal hash table to the
-specified size such that future Inserts do not require expansion of the hash
-table. Therefore, the implementation should allocate the needed memory to make
-that true at this point, even though the visible semantics could be preserved
-by waiting until enough elements are inserted.
+AARM Notes: This routine is used to preallocate the internal hash table to the
+specified capacity such that future Inserts do not require expansion of the
+hash table. Therefore, the implementation should allocate the needed memory to
+make that true at this point, even though the visible semantics could be
+preserved by waiting until enough elements are inserted.
+
+While Set_Capacity can be used to reduce the capacity of a map, we do not
+specify whether an implementation actually supports reduction of the capacity.
+Since the actual capacity can be anything greater than or equal to Count, an
+implementation never has to reduce the capacity.
+End AARM Notes
 
 function First (Container : Map) return Cursor;
 
@@ -2234,11 +2191,11 @@
 equivalent to Is_Equal_Key (Left, Key (Right)).
 
 
-generic
-   with procedure Process (Position : in Cursor) is <>;
-procedure Generic_Iteration (Container : in Map);
+procedure Iteration
+   (Container : in Map;
+    Process : not null access procedure (Element : in out Element_Type));
 
-Generic_Iteration calls Process with a cursor that designates each node
+Iteration calls Process.all with a cursor that designates each node
 in the Container. Any exceptions raised during Process are propagated.
 
 If Element_Type is unconstrained and definite, then the Element parameter
@@ -2258,7 +2215,7 @@
 the Implementation Requirement is met. These would require all instantiations
 to occur at the library level. We certainly do not want to require magic
 for nested container instantiations, while not giving similar capabilities to
-users. We've made this a legality rule to enhance portability. This rule can
+users. We've made this a legality rule to enhance portability. This rule will
 be dropped if AI-344 or some other solution to nested controlled types is
 adopted.
 
@@ -2332,7 +2289,7 @@
 package Ada.Containers.Ordered_Sets is
    pragma Preelaborate (Ordered_Sets);
 
-   type Set is private;
+   type Set is tagged private;
 
    type Cursor is private;
 
@@ -2342,7 +2299,7 @@
 
    function "=" (Left, Right : Set) return Boolean;
 
-   function Length (Container : Set) return Size_Type;
+   function Length (Container : Set) return Count_Type;
 
    function Is_Empty (Container : Set) return Boolean;
 
@@ -2350,10 +2307,6 @@
 
    function Element (Position : Cursor) return Element_Type;
 
-   generic
-      with procedure Process (Element : in out Element_Type) is <>;
-   procedure Generic_Update (Position : in Cursor);
-
    procedure Move (Target : in out Set;
                    Source : in out Set);
 
@@ -2417,6 +2370,14 @@
                   Item      : Element_Type)
       return Cursor;
 
+   function Floor (Container : Set;
+                   Item      : Element_Type)
+      return Cursor_Type;
+
+   function Ceiling (Container : Set;
+                     Item      : Element_Type)
+      return Cursor_Type;
+
    function First (Container : Set) return Cursor;
 
    function First_Element (Container : Set) return Element_Type;
@@ -2451,18 +2412,20 @@
    function ">" (Left : Element_Type; Right : Cursor)
       return Boolean;
 
-   generic
-      with procedure Process (Position : in Cursor) is <>;
-   procedure Generic_Iteration (Container : in Set);
+   procedure Iteration
+       (Container : in Set;
+        Process : not null access procedure (Element : in out Element_Type));
+
+   procedure Reverse_Iteration
+       (Container : in Set;
+        Process : not null access procedure (Element : in out Element_Type));
 
    generic
-      with procedure Process (Position : in Cursor) is <>;
-   procedure Generic_Reverse_Iteration (Container : in Set);
 
-   generic
-
       type Key_Type (<>) is limited private;
 
+      with function Key (Element : Element_Type) return Key_Type;
+
       with function "<" (Left : Key_Type; Right : Element_Type)
           return Boolean is <>;
 
@@ -2479,6 +2442,14 @@
                       Key       : Key_Type)
           return Cursor;
 
+       function Floor (Container : Set;
+                       Item      : Key_Type)
+          return Cursor_Type;
+
+       function Ceiling (Container : Set;
+                         Item      : Key_Type)
+          return Cursor_Type;
+
        function Element (Container : Set;
                          Key       : Key_Type)
           return Element_Type;
@@ -2497,17 +2468,10 @@
 
        function ">" (Left : Key_Type; Right : Cursor)
           return Boolean;
-
-       generic
 
-          with procedure Set_Key
-            (Element : in out Element_Type;
-             Key     : in     Key_Type) is <>;
-
-       procedure Generic_Insertion (Container : in out Set;
-                                    Key       : in     Key_Type;
-                                    Position  :    out Cursor;
-                                    Success   :    out Boolean);
+       procedure Update_Element
+          (Position : in Cursor;
+           Process : not null access procedure (Element : in out Element_Type));
 
    end Generic_Keys;
 
@@ -2527,8 +2491,8 @@
 this package call "<" and "=", and how many times the functions are called, is
 unspecified.
 
-Two elements are *equivalent* if the function "=" returns True when called
-with the elements as parameters.
+Two elements E1 and E2 are *equivalent* if not (E1 < E2) and not (E2 < E1) is
+true for the elements, using the generic formal less-than operator for elements.
 
 AARM Notes
 The implementation is not required to protect against "<" or "=" raising an
@@ -2572,14 +2536,6 @@
 If Position equals No_Element, then Constraint_Error is propagated.
 Otherwise, it returns the element designated by Position.
 
-generic
-   with procedure Process (Element : in out Element_Type) is <>;
-procedure Generic_Update (Position : in Cursor);
-
-If Position equals No_Element, then Constraint_Error is propagated. Otherwise,
-Generic_Update invokes the generic actual procedure bound to Process
-with the element designated by Position as the argument.
-
 procedure Move (Target : in out Set;
                 Source : in out Set);
 
@@ -2594,26 +2550,19 @@
                   Success   :    out Boolean);
 
 Insert compares New_Item to the elements in Container using the generic
-formal less-than operator for elements. Any exceptions raised by the
-less-than operator are propagated. If an element equivalent (see below)
+formal less-than operator for elements. If an element equivalent
 to New_Item is already in Container, Success is False and Position
 designates the element. Otherwise, it allocates a
 new element which is initialized to New_Item. Success returns True
 and Position designates the newly-inserted element. Any exceptions raised
 during allocation are propagated and Container is not modified.
 
-The equality operator for elements is not used by this operation.
-Insert compares elements for "equivalence," which for elements E1 and E2
-is defined as "not (E1 < E2) and not (E2 < E1)".
-
 
 procedure Delete (Container : in out Set;
                   Item      : in     Element_Type);
 
-Delete searches Container for an element equivalent to Item, using the
-generic formal less-than operator for elements. Any exceptions raised by
-less-than are propagated. If there is an element in Container equivalent
-to Item, the element is removed from Container.
+Delete searches Container for an element equivalent to Item. If there is an
+element in Container equivalent to Item, the element is removed from Container.
 
 AARM Note: The internal node containing the element may be deallocated now,
 or it may be saved and reused later.
@@ -2724,6 +2673,24 @@
 
 The function Is_In is equivalent to Find (Set, Item) /= No_Element.
 
+function Floor (Container : Set;
+                Item      : Element_Type)
+   return Cursor_Type;
+
+The Floor operation searches for the largest element not greater than Item,
+using the generic formal less-than operator for elements. If there is an
+element in Set that is not greater than Item, it returns a cursor designating
+the node containing the element. Otherwise it returns No_Element.
+
+function Ceiling (Container : Set;
+                  Item      : Element_Type)
+   return Cursor_Type;
+
+The Ceiling operation searches for the smallest element not less
+than Item, using the generic formal less-than operator for elements. If there
+is an element in Set that is not less than Item, it returns a cursor
+designating the node containing the element. Otherwise it returns No_Element.
+
 function First (Container : Set) return Cursor;
 
 Returns a cursor that designates the smallest element. If Container is empty,
@@ -2784,46 +2751,58 @@
 The function ">" (Left : Element_Type; Right : Cursor) is
 equivalent to Element (Right) < Left.
 
-generic
-   with procedure Process (Position : in Cursor) is <>;
-procedure Generic_Iteration (Container : in Set);
+procedure Iteration
+   (Container : in Set;
+    Process : not null access procedure (Element : in out Element_Type));
 
-Invokes Process with a cursor that designates each element in Container.
+Invokes Process.all with a cursor that designates each element in Container.
 
-generic
-   with procedure Process (Position : in Cursor) is <>;
-procedure Generic_Reverse_Iteration (Container : in Set);
+procedure Reverse_Iteration
+   (Container : in Set;
+    Process : not null access procedure (Element : in out Element_Type));
 
-Iterates over the elements in Container as per Generic_Iteration, with the
+Iterates over the elements in Container as per Iteration, with the
 difference that the nodes are traversed in reverse order.
 
 The package Generic_Keys provides operations that allow set manipulation
 in terms of a key (typically, a portion of an element) instead of a
 complete element.
 
-The operations in package Generic_Keys named Is_In, Find, Element,
-Delete, and operators designated "<" and ">", are equivalent to the
-corresponding operations in the parent package, with the difference that
-the Key subprogram parameter is compared to elements in the container
-using the Generic_Keys generic formal relational operators.
-
-procedure Generic_Insertion (Container : in out Set;
-                             Key       : in     Key_Type;
-                             Position  :    out Cursor;
-                             Success   :    out Boolean);
-
-Generic_Insertion compares Key to elements already in Container using
-the Generic_Keys generic formal relational operators for keys and
-elements. Any exceptions raised by less-than are propagated. If an
-element equivalent to Key is already in Container, Success is False and
-Position designates the element equivalent to Key.
-Otherwise, it allocates a new element and then calls Set_Key with the
-element and Key as the parameters. Any exceptions raised
-during allocation are propagated. If Set_Key raises an exception, Insert
-deallocates the element and then propagates the exception. Otherwise, it
-inserts the element into the Container. Success returns True and Position
-designates the newly-inserted element.
+The formal function Key is intended to extract a key value from an element. For
+any two elements E1 and E2, it is expected that (E1 < E2) = (Key(E1) < E2) =
+(Key(E2) > E1). If Key, "<", or ">" behaves in some other manner, the behavior
+of this package is unspecified. Which subprograms of this package call Key, "<"
+and ">", and how many times the functions are called, is unspecified.
+
+AARM Note: As for the main package, if the formal subprograms don't make sense,
+the package is not required to do anything that makes sense.
+
+
+The operations in package Generic_Keys named Is_In, Find, Floor, Ceiling,
+Element, Delete, and operators designated "<" and ">", are equivalent to the
+corresponding operations in the parent package, with the difference that the
+Key subprogram parameter is compared to elements in the container using the
+Generic_Keys generic formal relational operators.
+
+procedure Update_Element
+   (Position : in Cursor;
+    Process : not null access procedure (Element : in out Element_Type));
 
+If Position equals No_Element, then Constraint_Error is propagated. Otherwise,
+Update_Element uses Key to save the key value (KB) of the element.
+Update_Element then invokes Process.all with the element designated by Position
+as the argument. The key KB is compared to the new element value using the
+generic formal less-than and greater-than operators; if either returns True,
+the element is removed from the set, then is inserted back into the set.
+If the insertion fails, Constraint_Error is raised.
+
+AARM Note: The key check insures that the invariants of the set are
+preserved by the modification. If not, we try to re-insert the element at
+the correct place. If that fails, we have no choice other than to drop
+the element completely, because saving a value to roll back to would be
+expensive and defeat the purpose of this routine (which is cheap, in-place
+modifications).
+
 Legality Rules
 
 An instantiation of Containers.Ordered_Sets shall be at the library level.
@@ -2833,7 +2812,7 @@
 the Implementation Requirement is met. These would require all instantiations
 to occur at the library level. We certainly do not want to require magic
 for nested container instantiations, while not giving similar capabilities to
-users. We've made this a legality rule to enhance portability. This rule can
+users. We've made this a legality rule to enhance portability. This rule will
 be dropped if AI-344 or some other solution to nested controlled types is
 adopted.
 
@@ -2862,17 +2841,6 @@
 Constraint_Error if detected.
 End AARM Notes.
 
-Execution is erroneous if the actual subprogram of an instantiation of
-Generic_Update changes the element so that the formal subprogram "<" could give
-different results than before the modification.
-
-AARM Note: This means that the implementation is not required to check and
-fix the ordering if Generic_Update changes its position within the set. It
-would be possible to check for this, but it would be as expensive as a new
-insertion to do for the reference red-black tree. That would defeat the
-purpose of the Generic_Update routine (a cheap in-place update), so we didn't
-require it.
-
 Implementation Requirements
 
 No storage associated with an ordered set object shall be lost upon assignment
@@ -2911,9 +2879,8 @@
 
    * The generic formal Element_Type is indefinite.
 
-   * The Element parameter of formal subprogram Process of Generic_Update
-     and Generic_Update_by_Index may be constrained even if Element_Type is
-     unconstrained.
+   * The Element parameter of access subprogram Process of Update_Element
+     may be constrained even if Element_Type is unconstrained.
 
 
 A.17.7 The Package Containers.Indefinite_Doubly_Linked_Lists
@@ -2936,7 +2903,7 @@
        procedure Insert (Container : in out List;
                          Before    : in     Cursor;
                          Position  :    out Cursor;
-                         Count     : in     Size_Type := 1);
+                         Count     : in     Count_Type := 1);
     is omitted.
 
 AARM Note: This procedure is omitted because there is no way to create a
@@ -2948,7 +2915,7 @@
 omitting the routine completely, any problems will be diagnosed by the
 compiler.
 
-  * The Element parameter of formal subprogram Process of Generic_Update
+  * The Element parameter of access subprogram Process of Update_Element
     may be constrained even if Element_Type is unconstrained.
 
 
@@ -2985,7 +2952,7 @@
 omitting the routine completely, any problems will be diagnosed by the
 compiler.
 
-  * The Element parameter of formal subprogram Process of Generic_Update
+  * The Element parameter of access subprogram Process of Update_Element
     may be constrained even if Element_Type is unconstrained.
 
 
@@ -3002,13 +2969,8 @@
 has the same contents as Containers.Ordered_Sets except:
 
   * The generic formal Element_Type is indefinite.
-
-  * Instead of Set_Key, the generic formal operation of generic
-    operation Generic_Insertion is:
 
-   with function New_Element (Key : Key_Type) return Element_Type is <>;
-
-  * The Element parameter of formal subprogram Process of Generic_Update
+  * The Element parameter of access subprogram Process of Update_Element
     may be constrained even if Element_Type is unconstrained.
 
 
@@ -3092,7 +3054,7 @@
    procedure Copy (A : Array_Subtype) is
       V : Vector;
    begin
-      Resize (V, Size => A'Length);
+      Set_Capacity (V, Count => A'Length);
 
       for I in A'Range loop
          Append (V, New_Item => A (I));
@@ -3100,10 +3062,10 @@
       ...
    end Copy;
 
-The Resize operation tells the vector object to preallocate an internal
-array having at least the size specified. If you need to perform many
+The Set_Capacity operation tells the vector object to preallocate an internal
+array having at least the capacity specified. If you need to perform many
 repeated insertions, then if you know the ultimate length apriori you
-should always call Resize beforehand. This is more efficient because it
+should always call Set_Capacity beforehand. This is more efficient because it
 allocates the internal array once, and therefore avoids the repeated
 reallocation, copying, and deallocation cycles that might be necessary
 otherwise as the array is expanded.
@@ -3163,38 +3125,37 @@
    procedure Finalize (Element : in out My_Element_Type) is ...;
 
    procedure My_Clear (V : in out Vector) is
-
-      procedure Finalize_Element is
-         new Generic_Update_By_Index (Finalize);
    begin
       for I in First_Index (V) .. Last_Index (V) loop
-         Finalize_Element (V, I);
+         Update_Element (V, I, Finalize'Access);
       end loop;
 
       Clear (V);
    end My_Clear;
 
-Here we use the Generic_Update_By_Index modifier, and pass Finalize as
-the generic actual.
+Here we use the Update_Element modifier, and pass Finalize as the Process
+parameter.
 
-The internal array never shrinks, and it only expands under specific
-conditions. If you want to clear the vector and also deallocate the
+The internal array is managed by the implementation, and there is no
+requirement that it has any particular capacity; the only requirement is that
+the actual capacity is the same or larger than the most recent call to
+Set_Capacity. Thus Set_Capacity (V, 0) might, but might not, deallocate the
+internal array. If you want to clear the vector and also deallocate the
 internal array, you can use Move:
 
    procedure Clear_And_Deallocate (V : in out Vector) is
 
-      V2 : Vector;   -- length is 0; assume size is 0
+      V2 : Vector;   -- length is 0; assume capacity is 0
    begin
-      Clear (V);     -- sets length to 0, but size > 0
+      Clear (V);     -- sets length to 0, but capacity > 0
       Move (Target => V, Source => V2);  -- deallocate V's array
    end;
 
 The internal array that belonged to V is deallocated, and the null (or
 otherwise small) array of V2 is moved into V.
 
-The Resize operation can only be used to grow the internal array, not to
-shrink it. If for whatever reason you want more efficient use of
-storage, you can use Move to allocate an array having the minimum size
+Similarly, if for whatever reason you want more efficient use of
+storage, you can use Move to allocate an array having the minimum capacity
 necessary to store the active elements:
 
    procedure Reclaim_Storage (V : in out Vector) is
@@ -3206,10 +3167,14 @@
 
 This operation first copies all active elements in V to the temporary
 vector object Temp, which is allocated using a smaller internal array
-(presumably the smallest size necessary to store the elements, according
+(presumably the smallest capacity necessary to store the elements, according
 to whatever algorithm the implementor has chosen). The new, smaller
 array from Temp is then moved into V.
 
+These, however, are exceptional cases. Usually it is best to ignore the
+existence of the internal array altogther, and just let the container
+implementation manage memory (other than possibly setting an initial capacity).
+
 If some sort of finalization of the last element is necessary prior to
 its "removal" by a deletion operation, the programmer is responsible for
 effecting this action prior to calling the operation. As an example,
@@ -3219,13 +3184,16 @@
 
    procedure Pop (V : in out Vector) is
 
-      procedure Free is
+      procedure Free is -- Convention Intrinsic.
          new Ada.Unchecked_Deallocation (T, T_Access);
+
+      procedure Process (V : in out Vector) is -- Convention Ada.
+      begin
+          Free (V);
+      end Process;
 
-      procedure Free_Element is
-         new Generic_Update_By_Index (Process => Free);
    begin
-      Free_Element (V, Index => Last_Index (V));
+      Update_Element (V, Index => Last_Index (V), Process => Process'Access);
       Delete_Last (V);
    end Pop;
 
@@ -3266,13 +3234,11 @@
          Process (E => Element (I));
       end;
 
-      procedure Iterate is
-         new Generic_Iteration (Process);
    begin
-      Iterate (V);
+      Iteration (V, Process'Access);
    end Op;
 
-The Generic_Update generic operation is very important, as it allows
+The Update_Element operation is very important, as it allows
 in-place modification of elements. For example, suppose we have a vector
 whose elements are lists, and we want to append an item to the list
 element at a specified vector position. We can do that as follows:
@@ -3287,10 +3253,8 @@
          Append (L, New_Item => E);
       end;
 
-      procedure Update is
-         new Generic_Update_By_Index (Process);
    begin
-      Update (V, Index => I);
+      Update_Element (V, Index => I, Process => Process'Access);
    end;
 
 It's often the case that during an insertion you don't have an item
@@ -3304,19 +3268,17 @@
          ... -- manipulate E as appropriate
       end;
 
-      procedure Update is
-        new Generic_Update (Process);
-
       C : Cursor;
       Empty : ET; -- A default-initialized object of ET.
    begin
-      Insert                       --allocate the element
+      Insert                       -- Allocate the element
         (Container => V,
-         Before    => No_Element,  --insert at back end
+         Before    => No_Element,  -- Insert at back end
          New_Item  => Empty,
-         Position  => C);          --return value
+         Position  => C);          -- Return value
 
-      Update (Position => C);      --give element a value
+      Update_Element (Position => C, Process => Process'Access);
+                                   -- Give element a value
    end Op;
 
 We insert a default-initialized object so that the initial state of the
@@ -3325,7 +3287,7 @@
 
 
 If we have a container whose elements are vectors, we can use
-Generic_Update in combination with Move to insert a vector onto the
+Update_Element in combination with Move to insert a vector onto the
 container without actually copying the vector. (Actually, this is true
 for all containers -- not just vectors.) Suppose that we have a list of
 vectors:
@@ -3339,15 +3301,12 @@
          Move (Target => E, Source => V);
       end;
 
-      procedure Update is
-         new Generic_Update (Move_V);
-
       C : Cursor;
    begin
       Append (V, New_Item => E);
       ... -- populate vector some more
       Insert (L, Before => No_Element, New_Item => Empty_Vector, Position => C);
-      Update (C);  --move V to position C of list L
+      Update_Element (C, Move_V'Access);  -- Move V to position C of list L
    end;
 
 A new, default-initialized vector element is appended to L by
@@ -3447,7 +3406,7 @@
 element in order to perform the swap. However, we would prefer not to
 make a copy of this element, which is a list and hence potentially large
 (or otherwise expensive to copy). To avoid making a copy, we can use
-Move and nested instantiations of Generic_Update:
+Move and nested processing routines:
 
   procedure Swap
     (V    : in out Vector_Of_Lists.Vector;
@@ -3463,16 +3422,12 @@
            Move (Target => JE, Source => IE_Temp);
         end;
 
-        procedure Update_J is
-           new Generic_Update_By_Index (Process_J);
      begin
-        Update_J (V, Index => J);
+        Update_Element (V, Index => J, Process => Process_J'Access);
      end;
 
-     procedure Update_I is
-       new Generic_Update_By_Index (Process_I);
   begin
-     Update_I (V, Index => I);
+     Update_Element (V, Index => I, Process => Process_I'Access);
   end Swap;
 
 To do the swap, we need direct visibility to both objects, so nested
@@ -3488,21 +3443,21 @@
 
 It's often the case that you know apriori the total number of elements
 you intend to insert into the map. Under these circumstances you should
-always Resize the map first (similar to a vector container), and then
-perform the insertions. This preallocates a hash table that is
-properly sized, and thus avoids the automatic rehashing that occurs
+always Set_Capacity the map first (similar to a vector container), and then
+perform the insertions. This preallocates a hash table that has the proper
+capacity, and thus avoids the automatic rehashing that occurs
 during normal insertion to preserve the load factor. For example:
 
-   procedure Op (N : Size_Type) is
-      M : Map_Types.Map;  -- Size = 0 (or small)
+   procedure Op (N : Count_Type) is
+      M : Map_Types.Map;  -- Capacity = 0 (or small)
 
       Position : Map_Types.Cursor;
       Success  : Boolean;
    begin
-      Resize (M, Size => N);  -- Size >= N
+      Set_Capacity (M, Count => N);  -- Capacity >= N
 
       for I in 1 .. N loop
-         Insert  -- no resizing will occur
+         Insert  -- no expansion and rehashing will occur
            (Container => Map,
             Key       => New_Key (I),
             New_Item  => New_Element (I),
@@ -3513,9 +3468,10 @@
    end Op;
 
 Note that Clear doesn't delete the internal hash table -- it just
-deletes the nodes hanging off the hash table. If you want to delete the
-internal hash table too (thus setting the map's size to 0), then you can
-use Move with a temporary map object:
+deletes the nodes hanging off the hash table. Neither does
+Set_Capacity (Map, 0), as that is defined as specifying a lower bound for the
+capacity. If you want to delete the internal hash table too (thus setting the
+map's capacity to 0), then you can use Move with a temporary map object:
 
    procedure Clear_And_Deallocate (M : in out Map) is
       Temp : Map;
@@ -3536,10 +3492,8 @@
          ... -- do whatever
       end;
 
-      procedure Iterate is
-         new Generic_Iteration; -- accept default name
    begin
-      Iterate (M);
+      Iteration (M, Process'Access);
    end;
 
 You could of course implement this function yourself, by iterating over
@@ -3759,9 +3713,6 @@
          Count := Count + 1;
       end;
 
-      procedure Increment_Count is
-         new Generic_Update (Increment);
-
       Position : Wordcount_Maps.Cursor;
       Success  : Boolean;
 
@@ -3774,7 +3725,7 @@
          Position  => Position,
          Success   => Success);
 
-      Increment_Count (Position);
+      Update_Element (Position, Increment'Access);
 
    end Insert;
 
@@ -3815,12 +3766,9 @@
       begin
          Put (Key (C)); Put (':'); Put (Element (C)); New_Line;
       end;
-
-      procedure Dump is
-        new Wordcount_Maps.Generic_Iteration; -- "Process"
-  begin
-     Dump (Map);
-  end;
+   begin
+      Iteration (Map, Process'Access);
+   end;
 
 This would display the words in their order in the hashed map. That's
 probably not what you want (especially for a well-performing hash table,
@@ -3831,24 +3779,21 @@
    procedure Print_Results (Histogram : in Wordcount_Map) is
 
       type Cursor_Array is
-         array (Size_Type range <>) of Wordcount_Maps.Cursor;
+         array (Count_Type range <>) of Wordcount_Maps.Cursor;
 
       Cursors : Cursor_Array (1 .. Length (Histogram));
 
-      I : Size_Type := Cursors'First;
+      I : Count_Type := Cursors'First;
 
       procedure Process (C : in Wordcount_Maps.Cursor) is
       begin
          Cursors (I) := C;
-         I := Size_Type'Succ (I);
+         I := Count_Type'Succ (I);
       end;
 
-      procedure Populate_Array is
-        new Wordcount_Maps.Generic_Iteration; -- use default name
-
    begin -- Print_Results
 
-      Populate_Array (Histogram);
+      Iteration (Histogram, Process'Access); -- Populate array
 
       ... -- see below
 
@@ -3875,7 +3820,7 @@
 
       procedure Sort is
         new Generic_Array_Sort
-          (Index_Type   => Size_Type,
+          (Index_Type   => Count_Type,
            Element_Type => Word_Count_Maps.Cursor,
            Array_Type   => Cursor_Array);  -- accept "<" default
    begin
@@ -3900,7 +3845,7 @@
 
       procedure Sort is
         new Generic_Array_Sort
-          (Index_Type   => Size_Type,
+          (Index_Type   => Count_Type,
            Element_Type => Word_Count_Maps.Cursor,
            Array_Type   => Cursor_Array);  -- accept "<" default
    begin
@@ -4219,19 +4164,13 @@
    procedure Shutdown_Sessions is
 
       procedure Process (C : in Id_Map_Types.Cursor) is
-
-         procedure Free_Session is
-            new Is_Map_Types.Generic_Update (Process => Free);
       begin
-         Free_Session (C);
+         Update_Element (C, Free'Access); -- Free a session.
       end;
 
-      procedure Free_Sessions is
-         new Id_Map_Types.Generic_Iteration; -- accept default
-
    begin -- Shutdown_Sessions
 
-      Free_Sessions (Id_Map);
+      Iteration (Id_Map, Process'Access); -- Free all sessions.
 
       Clear (Id_Map);
 
@@ -4292,16 +4231,14 @@
       A : Integer_Array (1 .. Length (S));
       J : Positive := A'First;
 
-      procedure Process (I : Integer_Sets.Cursor) is
+      procedure Fill_Element_of_A (I : Integer_Sets.Cursor) is
       begin
          A (J) := Element (I);
          J := J + 1;
       end;
 
-      procedure Fill_Array_A is
-         new Integer_Sets.Generic_Iteration;  -- accept default
    begin
-      Fill_Array_A (S);
+      Iteration (S, Fill_Element_of_A'Access);
       ...
    end Op;
 
@@ -4621,7 +4558,7 @@
 
    procedure Display is
 
-      procedure Process (I : in Employee_Sets.Cursor) is
+      procedure Print (I : in Employee_Sets.Cursor) is
 
          procedure Do_Print (E : in out Employee_Type) is
          begin
@@ -4630,16 +4567,12 @@
             ...;
          end;
 
-         procedure Print is
-            new Generic_Update (Do_Print);
       begin
-        Print (Position => I);
+        Update_Element (Position => I, Process => Do_Print'Access);
       end;
 
-      procedure Print is
-         new Employee_Sets.Generic_Iteration; -- "Process"
    begin
-      Print (Employees);
+      Iteration (Employees, Print'Access);
    end;
 
 However, this will list employees in order of their social security
@@ -4668,24 +4601,20 @@
               Result := LE.Name < RE.Name;
            end;
 
-           procedure Update_R is
-              new Generic_Update (Process_RE);
         begin
-           Update_R (R);
+           Update_Element (R, Process_RE'Access);
         end Process_LE;
 
-        procedure Update_L is
-           new Generic_Update (Process_LE);
       begin
-         Update_L (L);
+         Update_Element (L, Process_LE'Access);
          return Result;
       end;
 
       type Cursor_Array is
-         array (Size_Type range <>) of Employee_Sets.Cursor;
+         array (Count_Type range <>) of Employee_Sets.Cursor;
 
       procedure Sort is
-        new Generic_Array_Sort (Size_Type, Cursor, Cursor_Array);
+        new Generic_Array_Sort (Count_Type, Cursor, Cursor_Array);
 
       procedure Do_Print (E : in out Employee_Type) is
       begin
@@ -4694,9 +4623,6 @@
          ...;
       end;
 
-      procedure Print is
-         new Generic_Update (Do_Print);
-
       C : Employee_Sets.Cursor := First (Employee_Sets);
 
       function Get_Cursor return Employee_Sets.Cursor is
@@ -4715,7 +4641,7 @@
 
       for Index in Cursors'Range loop
           C := Cursors (Index);
-          Print (Position => C);
+          Update_Element (Position => C, Process => Do_Print'Access);
       end loop;
 
    end Display_Employees_In_Name_Order;
@@ -4728,7 +4654,7 @@
 
 Implementing the sort order relation turns out to slightly tricky,
 because we don't want to make a copy of the employee just do get its
-name.  We use nested instantiations of Generic_Update to create a
+name.  We use nested process routines for Update_Element to create a
 context in which both employee objects are directly visible, and then
 compare employee names by querying the employee elements directly.
 
@@ -4811,40 +4737,6 @@
          New_Item  => Session,     -- element, has its own key
          Position  => Position,
          Success   => Success);
-      ...
-      return Session;
-   end;
-
-An alternate way to do this is to use the key-form of insertion:
-
-   procedure Set_Key
-     (Session : in out Session_Access;
-      Id      : in     String) is
-   begin
-      Session := new Session_Type;
-      Session.Id = Id;
-   end;
-
-   procedure Insert is
-      new Id_Types.Generic_Insertion;  -- accept default
-
-   function Setup_Session return Session_Access is
-      Session  : Session_Access;  -- no allocation here
-
-      Position : Session_Set_Types.Cursor;
-      Success  : Boolean;
-
-      Id : Id_Subtype;
-   begin
-      Generate_Id (Id);
-
-      Insert
-        (Container => Sessions_Set,
-         Key       => Id,             -- key, not element
-         Position  => Position,
-         Success   => Success);
-
-      Session := Element (Position); -- element was allocated in Set_Key
       ...
       return Session;
    end;

Questions? Ask the ACAA Technical Agent