34 #include <casacore/casa/aips.h>
35 #include <casacore/casa/BasicSL/Complex.h>
106 void objthrowmv1(
const void *to,
const void *from,
const size_t n);
107 void objthrowmv2(
const void *to,
const void *from,
const size_t n,
108 const size_t toStride,
const size_t fromStride);
109 void objthrowcp1(
const void *to,
const void *from,
const size_t n);
110 void objthrowcp2(
const void *to,
const void *from,
const size_t n,
111 const size_t toStride,
const size_t fromStride);
112 void objthrowfl1(
const void *to,
const size_t n);
113 void objthrowfl2(
const void *to,
const size_t n,
114 const size_t toStride);
120 void objtestmv(
size_t &nLeft,
size_t &startLeft,
size_t &startRight,
121 const void *to,
const void *from,
const size_t n,
122 const size_t toStride,
const size_t fromStride,
123 const void *toPn,
const void *fromPn,
124 const size_t fromMto,
const size_t toMfrom);
145 template<
class T>
void objmove(T* to,
const T* from,
size_t n) {
146 objthrowmv1(to,from,n);
147 (to<from || to >= from+n) ?
std::copy(from,from+n,to)
148 : std::copy_backward(from,from+n,to+n); }
149 template<
class T>
void objmove(T* to,
const T* from,
size_t n,
150 size_t toStride,
size_t fromStride) {
152 objthrowmv2(to,from,n,toStride,fromStride);
153 if (toStride*fromStride == 1) { objmove(to, from, n);
155 size_t nLeft, startLeft, startRight;
156 size_t fromMto=0;
size_t toMfrom=0;
157 if (toStride > fromStride && from > to)
158 fromMto = (from-to)/(toStride-fromStride);
159 else if (toStride < fromStride && from < to)
160 toMfrom = (to-from)/(fromStride-toStride);
161 objtestmv(nLeft, startLeft, startRight, to, from, n,
162 toStride, fromStride, to+n*toStride, from+n*fromStride,
166 const T* fromPtr = from + startLeft*fromStride;
167 T* toPtr = to + startLeft*toStride;
168 while (nLeft--) { *toPtr = *fromPtr;
169 fromPtr += fromStride;
170 toPtr += toStride; }; };
173 const T* fromPtr = from + startRight*fromStride;
174 T* toPtr = to + startRight*toStride;
175 while (n--) { fromPtr -= fromStride; toPtr -= toStride;
176 *toPtr = *fromPtr; }; };
198 template<
class T>
void objcopy(T* to,
const T* from,
size_t n) {
199 objthrowcp1(to,from,n);
std::copy(from, from+n, to); }
200 template<
class T>
void objcopy(T* to,
const T* from,
size_t n,
201 size_t toStride,
size_t fromStride) {
202 objthrowcp2(to,from,n,toStride,fromStride);
while (n--) {
203 *to = *from; to += toStride; from += fromStride; } }
205 template<
class T>
void objcopyctor(T* to,
const T* from,
size_t n) {
206 objthrowcp1(to, from, n);
209 for (i = 0; i < n; ++i) {
210 ::new (&to[i]) T(from[i]);
219 template<
class T>
void objcopyctor(T* to,
const T* from,
size_t n,
220 size_t toStride,
size_t fromStride) {
221 objthrowcp2(to, from, n, toStride, fromStride);
224 for (i = 0; i < n; ++i) {
252 template<
class T>
void objset(T* to,
const T fillValue,
size_t n) {
253 objthrowfl1(to,n); std::fill_n(to, n, fillValue); }
255 template<
class T>
void objset(T* to,
const T fillValue,
size_t n,
257 objthrowfl2(to,n,toStride);
258 while (n--){*to = fillValue; to += toStride; }; }
266 #ifndef CASACORE_NO_AUTO_TEMPLATES
267 #include <casacore/casa/Utilities/Copy.tcc>
this file contains all the compiler specific defines
StatsData< AccumType > copy(const StatsData< AccumType > &stats)
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)