CVS difference for ais/ai-20302.txt

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

--- ais/ai-20302.txt	2005/02/26 00:51:54	1.17
+++ ais/ai-20302.txt	2005/04/13 05:37:28	1.18
@@ -662,7 +662,7 @@
 object V if:
 
  * it inserts or deletes elements of V, that is, it calls the Insert,
-   Insert_Space, Clear, Delete, Delete_Last, or Set_Length procedures with V
+   Insert_Space, Clear, Delete, or Set_Length procedures with V
    as a parameter; or
 
    AARM To Be Honest: Operations which are defined to be equivalent to
@@ -4785,41 +4785,14 @@
      Vector_Of_Lists.Swap (V, I, J);  -- vector operation
   end;
 
-For the definite form (the case here), this will make a copy of the
-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 processing routines:
-
-  procedure Swap
-    (V    : in out Vector_Of_Lists.Vector;
-     I, J : in     Extended_Index) is
-
-     procedure Process_I (IE : in out List) is
-
-        procedure Process_J (JE : in out List) is
-           IE_Temp : List;
-        begin
-           Move (Target => IE_Temp, Source => IE);
-           Move (Target => IE, Source => JE);
-           Move (Target => JE, Source => IE_Temp);
-        end;
-
-     begin
-        Update_Element (V, Index => J, Process => Process_J'Access);
-     end;
-
-  begin
-     Update_Element (V, Index => I, Process => Process_I'Access);
-  end Swap;
-
-To do the swap, we need direct visibility to both objects, so nested
-process procedures are required. We first move the list element at index I
-of the vector into a temporary. This allows another vector to by copied
-into that index position. We do that, moving the list element at index
-J into (empty) list element at index I. We then move the temporary
-(holding the list that was originally at index I) into the vector at
-index position J.
+This will (logically) make a copy of the element in order to perform the swap.
+Many implementations will avoid this copy; this is especially likely for
+the indefinite forms of these containers. But there is no guarantee that
+the copy can be avoided when using Swap.
+
+If we really must avoid making a copy (perhaps the element is potentially
+large), we need to use a list to store these elements. We then can use
+Swap_Links to swap the positions in the list without copying the elements.
 
 
 It's often the case that during an insertion you don't have an item

Questions? Ask the ACAA Technical Agent