ATLAS Offline Software
JaggedVecConversions.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
3  */
13 
14 
15 namespace SG { namespace detail {
16 
17 
25 void 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 
41 void 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),
76  JaggedVecEltBase::Shift (n_add));
77 }
78 
79 
80 } } // namespace SG::detail
SG::IAuxTypeVector::shift
virtual bool shift(size_t pos, ptrdiff_t offs)=0
Shift the elements of the vector.
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
SG::JaggedVecEltBase::Shift
Helper to shift indices.
Definition: JaggedVecImpl.h:104
SG::detail::JaggedVecProxyBase::adjust1
void adjust1(size_t elt_index, index_type index, int n_add)
Add or remove payload items from one jagged vector element.
Definition: JaggedVecConversions.cxx:41
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::JaggedVecEltBase::size
size_t size(size_t elt_ndx) const
Return the number of items in this range.
index
Definition: index.py:1
detail
Definition: extract_histogram_tag.cxx:14
SG::IAuxStore::linkedVector
virtual IAuxTypeVector * linkedVector(SG::auxid_t)
Definition: IAuxStore.h:187
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
SG::JaggedVecEltBase
Describe one element of a jagged vector (base class).
Definition: JaggedVecImpl.h:52
SG::detail::JaggedVecProxyBase::m_elts
Elt_span m_elts
The elements of the jagged vector.
Definition: JaggedVecConversions.h:157
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
SG::detail::JaggedVecProxyBase::m_container
AuxVectorData & m_container
The container holding the variable.
Definition: JaggedVecConversions.h:160
SG::detail::JaggedVecProxyBase::m_linkedVec
std::variant< IAuxTypeVector *, SG::auxid_t > m_linkedVec
Definition: JaggedVecConversions.h:163
SG::AuxVectorData::getStore
SG::IAuxStore * getStore()
Return the current store, as a non-const interface.
SG::detail::JaggedVecProxyBase::elt
Elt_t & elt(size_t elt_index) noexcept
Return one jagged vector element (non-const).
SG::detail::JaggedVecProxyBase::resize1
void resize1(size_t elt_index, index_type n_new)
Resize one jagged vector element.
Definition: JaggedVecConversions.cxx:25
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
SG::AuxVectorData::clearCache
void clearCache()
Clear the cached aux data pointers.
SG::detail::JaggedVecProxyBase::index_type
typename Elt_t::index_type index_type
Type used for indexing into a jagged vector.
Definition: JaggedVecConversions.h:105
SG::IAuxTypeVector::auxid
auxid_t auxid() const
Return the auxid of the variable this vector represents.
Definition: IAuxTypeVector.h:232
JaggedVecConversions.h
Conversions for accessing jagged vector variables.
SG::IAuxTypeVector
Abstract interface for manipulating vectors of arbitrary types.
Definition: IAuxTypeVector.h:42