32#include <casacore/casa/aips.h>
33#include <casacore/casa/BasicSL/Complex.h>
104 void objthrowmv1(
const void *to,
const void *from,
const size_t n);
105 void objthrowmv2(
const void *to,
const void *from,
const size_t n,
106 const size_t toStride,
const size_t fromStride);
107 void objthrowcp1(
const void *to,
const void *from,
const size_t n);
108 void objthrowcp2(
const void *to,
const void *from,
const size_t n,
109 const size_t toStride,
const size_t fromStride);
110 void objthrowfl1(
const void *to,
const size_t n);
111 void objthrowfl2(
const void *to,
const size_t n,
112 const size_t toStride);
118 void objtestmv(
size_t &nLeft,
size_t &startLeft,
size_t &startRight,
119 const void *to,
const void *from,
const size_t n,
120 const size_t toStride,
const size_t fromStride,
121 const void *toPn,
const void *fromPn,
122 const size_t fromMto,
const size_t toMfrom);
143 template<
class T>
void objmove(T* to,
const T* from,
size_t n) {
144 objthrowmv1(to,from,n);
145 (to<from || to >= from+n) ? std::copy(from,from+n,to)
146 : std::copy_backward(from,from+n,to+n); }
147 template<
class T>
void objmove(T* to,
const T* from,
size_t n,
148 size_t toStride,
size_t fromStride) {
150 objthrowmv2(to,from,n,toStride,fromStride);
151 if (toStride*fromStride == 1) { objmove(to, from, n);
153 size_t nLeft, startLeft, startRight;
154 size_t fromMto=0;
size_t toMfrom=0;
155 if (toStride > fromStride && from > to)
156 fromMto = (from-to)/(toStride-fromStride);
157 else if (toStride < fromStride && from < to)
158 toMfrom = (to-from)/(fromStride-toStride);
159 objtestmv(nLeft, startLeft, startRight, to, from, n,
160 toStride, fromStride, to+n*toStride, from+n*fromStride,
164 const T* fromPtr = from + startLeft*fromStride;
165 T* toPtr = to + startLeft*toStride;
166 while (nLeft--) { *toPtr = *fromPtr;
167 fromPtr += fromStride;
168 toPtr += toStride; }; };
171 const T* fromPtr = from + startRight*fromStride;
172 T* toPtr = to + startRight*toStride;
173 while (n--) { fromPtr -= fromStride; toPtr -= toStride;
174 *toPtr = *fromPtr; }; };
196 template<
class T>
void objcopy(T* to,
const T* from,
size_t n) {
197 objthrowcp1(to,from,n); std::copy(from, from+n, to); }
198 template<
class T>
void objcopy(T* to,
const T* from,
size_t n,
199 size_t toStride,
size_t fromStride) {
200 objthrowcp2(to,from,n,toStride,fromStride);
while (n--) {
201 *to = *from; to += toStride; from += fromStride; } }
203 template<
class T>
void objcopyctor(T* to,
const T* from,
size_t n) {
204 objthrowcp1(to, from, n);
207 for (i = 0; i < n; ++i) {
208 ::new (&to[i]) T(from[i]);
217 template<
class T>
void objcopyctor(T* to,
const T* from,
size_t n,
218 size_t toStride,
size_t fromStride) {
219 objthrowcp2(to, from, n, toStride, fromStride);
222 for (i = 0; i < n; ++i) {
250 template<
class T>
void objset(T* to,
const T fillValue,
size_t n) {
251 objthrowfl1(to,n); std::fill_n(to, n, fillValue); }
253 template<
class T>
void objset(T* to,
const T fillValue,
size_t n,
255 objthrowfl2(to,n,toStride);
256 while (n--){*to = fillValue; to += toStride; }; }
264#ifndef CASACORE_NO_AUTO_TEMPLATES
265#include <casacore/casa/Utilities/Copy.tcc>
this file contains all the compiler specific defines
void objcopyctor(T *to, const T *from, size_t n)
void objcopy(T *to, const T *from, size_t n)
The non-general function to copy n objects from one place to another.
void objset(T *to, const T fillValue, size_t n, size_t toStride)
void objcopyctor(T *to, const T *from, size_t n, size_t toStride, size_t fromStride)
void objmove(T *to, const T *from, size_t n)
The general function to copy n objects from one place to another if overlap between to and from field...
void objset(T *to, const T fillValue, size_t n)
Fill n elements of an array of objects with the given value, optionally with a stride.
void objcopy(T *to, const T *from, size_t n, size_t toStride, size_t fromStride)
void objmove(T *to, const T *from, size_t n, size_t toStride, size_t fromStride)
void objtestmv(size_t &nLeft, size_t &startLeft, size_t &startRight, const void *to, const void *from, const size_t n, const size_t toStride, const size_t fromStride, const void *toPn, const void *fromPn, const size_t fromMto, const size_t toMfrom)
Test on how to handle the overlap in move.
void objthrowmv1(const void *to, const void *from, const size_t n)
Throw the various AipsErrors when incorrect arguments used.
void objthrowcp1(const void *to, const void *from, const size_t n)
void objthrowfl1(const void *to, const size_t n)
void objthrowmv2(const void *to, const void *from, const size_t n, const size_t toStride, const size_t fromStride)
void objthrowfl2(const void *to, const size_t n, const size_t toStride)
void objthrowcp2(const void *to, const void *from, const size_t n, const size_t toStride, const size_t fromStride)