ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthContainers
Root
JaggedVecConversions.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration.
3
*/
10
11
12
#include "
AthContainers/tools/JaggedVecConversions.h
"
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
// Backfill trailing zeros up to the current element if needed.
67
if
(end == 0 &&
m_elts
.back().end() == 0) {
68
if
(
size_t
npayload = linkedVec->
getDataSpan
().
size
) {
69
Elt_t::Shift
shift
(npayload);
70
size_t
i = elt_index;
71
while
(
m_elts
[i].end() == 0) {
72
if
(i == 0)
break
;
73
--i;
74
}
75
if
(
m_elts
[i].end() != 0) {
76
std::fill (
m_elts
.data()+i+1,
m_elts
.data()+elt_index+1,
Elt_t
(
m_elts
[i].end()));
77
beg = end = npayload;
78
}
79
}
80
}
81
82
// Shift the payload items.
83
if
(!linkedVec->
shift
(beg+
index
, n_add)) {
84
m_container
.clearCache (linkedVec->
auxid
());
85
}
86
87
// Adjust the indices in the jagged vector elements.
88
// First the element that we're modifying...
89
e =
JaggedVecEltBase
(end + n_add);
90
// .. then the remaining elements
91
JaggedVecEltBase::Shift
shift
(n_add);
92
for
(
auto
pos =
m_elts
.begin() + elt_index+1; pos <
m_elts
.end(); ++pos)
93
{
94
if
(pos->end() == 0 && (pos-1)->end() == linkedVec->
getDataSpan
().
size
) {
95
// Stop if we get to trailing zeros to avoid N^2 behavior.
96
break
;
97
}
98
shift
(*pos);
99
}
100
}
101
102
103
} }
// namespace SG::detail
JaggedVecConversions.h
Conversions for accessing jagged vector variables.
SG::IAuxTypeVector
Abstract interface for manipulating vectors of arbitrary types.
Definition
IAuxTypeVector.h:45
SG::IAuxTypeVector::auxid
auxid_t auxid() const
Return the auxid of the variable this vector represents.
Definition
IAuxTypeVector.h:244
SG::IAuxTypeVector::shift
virtual bool shift(size_t pos, ptrdiff_t offs)=0
Shift the elements of the vector.
SG::IAuxTypeVector::getDataSpan
const AuxDataSpanBase & getDataSpan() const
Return a reference to a description of this vector's start+size.
Definition
IAuxTypeVector.h:273
SG::JaggedVecEltBase
Describe one element of a jagged vector (base class).
Definition
JaggedVecImpl.h:57
SG::JaggedVecEltBase::size
size_t size(size_t elt_ndx) const
Return the number of items in this range.
SG::detail::JaggedVecProxyBase::index_type
typename Elt_t::index_type index_type
Type used for indexing into a jagged vector.
Definition
JaggedVecConversions.h:104
SG::detail::JaggedVecProxyBase::Elt_t
SG::JaggedVecEltBase Elt_t
Type of a jagged vector element.
Definition
JaggedVecConversions.h:98
SG::detail::JaggedVecProxyBase::elt
Elt_t & elt(size_t elt_index) noexcept
Return one jagged vector element (non-const).
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::detail::JaggedVecProxyBase::m_linkedVec
std::variant< IAuxTypeVector *, SG::auxid_t > m_linkedVec
Definition
JaggedVecConversions.h:162
SG::detail::JaggedVecProxyBase::m_elts
Elt_span m_elts
The elements of the jagged vector.
Definition
JaggedVecConversions.h:156
SG::detail::JaggedVecProxyBase::resize1
void resize1(size_t elt_index, index_type n_new)
Resize one jagged vector element.
Definition
JaggedVecConversions.cxx:25
SG::detail::JaggedVecProxyBase::m_container
AuxVectorData & m_container
The container holding the variable.
Definition
JaggedVecConversions.h:159
SG::detail
Definition
DataVectorWithAllocFwd.h:22
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
SG::auxid
SG::auxid_t auxid() const
Return the aux id for this variable.
SG::shift
virtual void shift(size_t pos, ptrdiff_t offs) override
Shift the elements of the container.
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition
AuxTypes.h:27
index
Definition
index.py:1
SG::AuxDataSpanBase::size
size_t size
The length of the variable's vector.
Definition
AuxDataSpan.h:57
SG::JaggedVecEltBase::Shift
Helper to shift indices.
Definition
JaggedVecImpl.h:108
Generated on
for ATLAS Offline Software by
1.17.0