32#include <casacore/casa/aips.h>
33#include <casacore/casa/BasicSL/Complex.h>
104void objthrowmv1(
const void* to,
const void* from,
const size_t n);
105void objthrowmv2(
const void* to,
const void* from,
const size_t n,
const size_t toStride,
106 const size_t fromStride);
107void objthrowcp1(
const void* to,
const void* from,
const size_t n);
108void objthrowcp2(
const void* to,
const void* from,
const size_t n,
const size_t toStride,
109 const size_t fromStride);
111void objthrowfl2(
const void* to,
const size_t n,
const size_t toStride);
117void objtestmv(
size_t& nLeft,
size_t& startLeft,
size_t& startRight,
const void* to,
118 const void* from,
const size_t n,
const size_t toStride,
const size_t fromStride,
119 const void* toPn,
const void* fromPn,
const size_t fromMto,
const size_t toMfrom);
142 objthrowmv1(to, from, n);
143 (to < from || to >= from + n) ? std::copy(from, from + n, to)
144 : std::copy_backward(from, from + n, to + n);
147void objmove(T* to,
const T* from,
size_t n,
size_t toStride,
size_t fromStride) {
149 objthrowmv2(to, from, n, toStride, fromStride);
150 if (toStride * fromStride == 1) {
154 size_t nLeft, startLeft, startRight;
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, toStride, fromStride, to + n * toStride,
162 from + n * fromStride, fromMto, toMfrom);
165 const T* fromPtr = from + startLeft * fromStride;
166 T* toPtr = to + startLeft * toStride;
169 fromPtr += fromStride;
175 const T* fromPtr = from + startRight * fromStride;
176 T* toPtr = to + startRight * toStride;
178 fromPtr -= fromStride;
206 objthrowcp1(to, from, n);
207 std::copy(from, from + n, to);
210void objcopy(T* to,
const T* from,
size_t n,
size_t toStride,
size_t fromStride) {
211 objthrowcp2(to, from, n, toStride, fromStride);
221 objthrowcp1(to, from, n);
224 for (i = 0; i < n; ++i) {
225 ::new (&to[i]) T(from[i]);
235void objcopyctor(T* to,
const T* from,
size_t n,
size_t toStride,
size_t fromStride) {
236 objthrowcp2(to, from, n, toStride, fromStride);
239 for (i = 0; i < n; ++i) {
268void objset(T* to,
const T fillValue,
size_t n) {
270 std::fill_n(to, n, fillValue);
274void objset(T* to,
const T fillValue,
size_t n,
size_t toStride) {
275 objthrowfl2(to, n, toStride);
288#ifndef CASACORE_NO_AUTO_TEMPLATES
289#include <casacore/casa/Utilities/Copy.tcc>
For temporary backward namespace compatibility, use casa as alias for casacore.
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)