22 if (
index > 0 && elts[
index-1].end() == 0 && elts[
sz-1].end() == 0) {
27 if (
index == 0)
break;
61 size_t src_end = src_index + n;
62 size_t dst_end = dst_index + n;
63 if ((src_end > dst_index && src_end <= dst_end) ||
64 (dst_end > src_index && dst_end <= src_end))
72 vector_value_type* v_dst =
reinterpret_cast<vector_value_type*
> (dst.
getDataArray (
auxid));
73 const vector_value_type* v_src = &dst==&src ? v_dst :
reinterpret_cast<const vector_value_type*
> (src.getDataArray (
auxid));
78 const size_t dst_sz = dst.
size_v();
83 const size_t dst_first = v_dst[dst_index].begin(dst_index);
84 size_t src_first = v_src[src_index].begin(src_index);
85 size_t src_first_orig = src_first;
86 const size_t n_dst = v_dst[dst_index+n-1].end() - dst_first;
87 size_t n_src = v_src[src_index+n-1].end() - src_first;
90 std::copy_n (v_src+src_index, n, v_dst+dst_index);
93 if (v_dst[dst_index+n-1].end() == 0) {
94 const size_t src_sz = src.size_v();
95 if (v_src[src_sz-1].end() == 0) {
100 for (
size_t i = src_index+n; i < src_sz; ++i) {
101 if (v_src[i].end() != 0) {
108 for (
size_t i = dst_index+n-1; v_dst[i].end() == 0; --i) {
110 if (i == dst_index)
break;
112 if (src_first == 0 && src_index > 0) {
113 src_first = v_src[src_index-1].end();
114 src_first_orig = src_first;
116 n_src = src_n_payload - src_first;
123 if (n_src != n_dst) {
124 if (!dst_lv->
shift (dst_first+n_dst, n_src - n_dst)) {
127 if (&dst == &src && src_first > dst_first) {
128 src_first += (n_src - n_dst);
134 payload_fac->
copyForOutput (payload_auxid, dst, dst_first, src, src_first, n_src);
137 payload_fac->
copy (payload_auxid, dst, dst_first, src, src_first, n_src);
142 std::for_each_n (v_dst+dst_index, n,
Shift (dst_first - src_first_orig));
144 if (dst_index+n < dst_sz && !(v_dst[dst_index+n].end() == 0 && v_dst[dst_sz-1].end() == 0))
146 std::for_each (v_dst+dst_index+n, v_dst+dst_sz,
Shift (n_src - n_dst));
172 vector_value_type* v_a =
reinterpret_cast<vector_value_type*
> (
a.getDataArray (
auxid));
173 vector_value_type* v_b = &
a==&b ? v_a :
reinterpret_cast<vector_value_type*
> (b.getDataArray (
auxid));
179 const size_t a_sz =
a.size_v();
180 const size_t b_sz = b.size_v();
186 size_t a_first = v_a[aindex].begin(aindex);
187 size_t b_first = v_b[bindex].begin(bindex);
188 const size_t a_first_orig = a_first;
189 const size_t b_first_orig = b_first;
190 const size_t n_a = v_a[aindex+n-1].end() - a_first;
191 const size_t n_b = v_b[bindex+n-1].end() - b_first;
200 const size_t n_common = std::min (n_a, n_b);
201 payload_fac->
swap (payload_auxid,
a, a_first, b, b_first, n_common);
207 auto shiftTail = [payload_fac, n_common, payload_auxid]
218 if (!lv2->shift (first2 + n_common, n1 - n_common)) {
219 vd2.clearCache (payload_auxid);
221 if (&vd1 == &vd2 && first1 > first2) {
223 first1 += (n1 - n_common);
226 payload_fac->
copy (payload_auxid,
227 vd2, first2 + n_common, vd1, first1 + n_common,
230 lv1->shift (first1 + n1, - (n1 - n_common));
231 if (&vd1 == &vd2 && first2 > first1) {
233 first2 -= (n1 - n_common);
239 shiftTail (
a, alv, a_first, n_a, b, blv, b_first);
241 else if (n_b > n_a) {
242 shiftTail (b, blv, b_first, n_b,
a, alv, a_first);
248 std::for_each_n (v_a+aindex, n,
Shift (a_first - b_first_orig));
249 std::for_each_n (v_b+bindex, n,
Shift (b_first - a_first_orig));
257 if (aindex < bindex) {
258 std::for_each (v_a+aindex+n, v_a+bindex,
Shift (n_b - n_a));
261 std::for_each (v_a+bindex+n, v_a+aindex,
Shift (n_a - n_b));
266 std::for_each (v_a+aindex+n, v_a+a_sz,
Shift (n_b - n_a));
267 std::for_each (v_b+bindex+n, v_b+b_sz,
Shift (n_a - n_b));
287 const size_t dst_sz = dst.
size_v();
293 size_t begin = v[dst_index].begin(dst_index);
294 size_t end = v[dst_index+n-1].end();
296 size_t n_payload = end - begin;
299 lv->
shift (end, - n_payload);
302 std::for_each (v+dst_index+n, v+dst_sz,
Shift (-n_payload));
Factory object that creates vectors using AuxTypeVector, specialized for JaggedVec.
void clear()
Empty the pool.
Handle mappings between names and auxid_t.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Manage lookup of vectors of auxiliary data.
void clearCache()
Clear the cached aux data pointers.
virtual size_t size_v() const =0
Return the size of the container.
const void * getDataArray(SG::auxid_t auxid) const
Return a const pointer to the start of an aux data vector.
SG::IAuxStore * getStore()
Return the current store, as a non-const interface.
virtual IAuxTypeVector * linkedVector(SG::auxid_t)
Interface for factory objects that create vectors.
virtual void copyForOutput(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const =0
Copy elements between vectors, possibly applying thinning.
virtual void copy(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const =0
Copy elements between vectors.
virtual void swap(SG::auxid_t auxid, AuxVectorData &a, size_t aindex, AuxVectorData &b, size_t bindex, size_t n) const =0
Swap elements between vectors.
Abstract interface for manipulating vectors of arbitrary types.
auxid_t auxid() const
Return the auxid of the variable this vector represents.
virtual bool shift(size_t pos, ptrdiff_t offs)=0
Shift the elements of the vector.
const AuxDataSpanBase & getDataSpan() const
Return a reference to a description of this vector's start+size.
Describe one element of a jagged vector (base class).
index_type end() const
Return the index of the end of the range.
void fillTrailingZeros(JaggedVecEltBase *elts, size_t index, size_t sz, IAuxTypeVector *lv)
Fill in trailing zeros in a range.
void copyImpl(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n, bool for_output)
Copy elements between vectors: out-of-line portion.
void swap(SG::auxid_t auxid, AuxVectorData &a, size_t aindex, AuxVectorData &b, size_t bindex, size_t n)
Swap elements between vectors.
SG::auxid_t auxid() const
Return the aux id for this variable.
virtual void shift(size_t pos, ptrdiff_t offs) override
Shift the elements of the container.
void throwJaggedVecOverlappingCopy()
Throw a SG::ExcJaggedVecOverlappingCopy exception.
size_t auxid_t
Identifier for a particular aux data item.
DataModel_detail::iterator< DV > swap_ranges(DataModel_detail::iterator< DV > first1, DataModel_detail::iterator< DV > last1, DataModel_detail::iterator< DV > first2)
Specialization of swap_ranges for DataVector/DataList.
size_t size
The length of the variable's vector.