copy(3C++)


copy -- copy an array to a new location

Synopsis

   template <class *gt>
   void copy(T* b1,T* e1,T* b2);

Assumptions

(1) The output array has at least as many cells as the input array.

(2) T has operator=.

Description

Moves the contents of every cell in the array starting at b1 into the array starting at b2.

Complexity

If N is the size of the array, then complexity is O(N). Exactly N assignments are done unless b1 is equal to b2, in which case no assignments are done.

Notes

copy is the only function that allows input and output arrays to overlap; in particular, none of the "copy versions" (functions with their c suffix) allows overlap. Since copy allows the input array to be changed, the parameters b1 and e1 have type T*, rather than const T*.

Because a Block (see Block(3C++)) can always be used wherever an array is called for, Array Algorithms can also be used with Blocks. In fact, these two components were actually designed to be used together.

References

   Array_alg(3C++)
   Block(3C++)

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004