ATLAS Offline Software
Loading...
Searching...
No Matches
JaggedVecConversions.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
3 */
10
11
13
14
15namespace SG { namespace detail {
16
17
25void JaggedVecProxyBase::resize1 (size_t elt_index, index_type n_new)
26{
27 int n_old = elt (elt_index).size (elt_index);
28 adjust1 (elt_index, n_old, static_cast<int>(n_new) - n_old);
29}
30
31
41void JaggedVecProxyBase::adjust1 (size_t elt_index, index_type index, int n_add)
42{
43 // Return right away if there's nothing to do.
44 if (n_add == 0) return;
45
46 // Find the IAuxTypeVector for the payload variable.
47 IAuxTypeVector* linkedVec;
48 if (m_linkedVec.index() == 0) {
49 // We already have it.
50 linkedVec = std::get<0>(m_linkedVec);
51 }
52 else {
53 // Look it up from the container.
54 SG::auxid_t auxid = std::get<1>(m_linkedVec);
55 linkedVec = m_container.getStore()->linkedVector (auxid);
56
57 // Remember it to possibly use again.
58 m_linkedVec = linkedVec;
59 }
60
61 // Indices from the element that we're modifying.
62 Elt_t& e = elt(elt_index);
63 size_t beg = e.begin(elt_index);
64 size_t end = e.end();
65
66 // Shift the payload items.
67 if (!linkedVec->shift (beg+index, n_add)) {
68 m_container.clearCache (linkedVec->auxid());
69 }
70
71 // Adjust the indices in the jagged vector elements.
72 // First the element that we're modifying...
73 e = JaggedVecEltBase (end + n_add);
74 // .. then all the remaining elements.
75 std::ranges::for_each (m_elts | std::views::drop (elt_index+1),
77}
78
79
80} } // namespace SG::detail
Conversions for accessing jagged vector variables.
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.
Describe one element of a jagged vector (base class).
size_t size(size_t elt_ndx) const
Return the number of items in this range.
typename Elt_t::index_type index_type
Type used for indexing into a jagged vector.
SG::JaggedVecEltBase Elt_t
Type of a jagged vector element.
Elt_t & elt(size_t elt_index) noexcept
Return one jagged vector element (non-const).
void adjust1(size_t elt_index, index_type index, int n_add)
Add or remove payload items from one jagged vector element.
std::variant< IAuxTypeVector *, SG::auxid_t > m_linkedVec
Elt_span m_elts
The elements of the jagged vector.
void resize1(size_t elt_index, index_type n_new)
Resize one jagged vector element.
AuxVectorData & m_container
The container holding the variable.
Forward declaration.
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
Definition index.py:1
Helper to shift indices.