ATLAS Offline Software
Loading...
Searching...
No Matches
JaggedVecImpl.icc
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration.
3 */
4/**
5 * @file AthContainers/JaggedVecImpl.icc
6 * @author scott snyder <snyder@bnl.gov>
7 * @date Jul, 2024
8 * @brief Definition of JaggedVecElt.
9 */
10
11
12namespace SG {
13
14
15/**
16 * @brief Constructor.
17 * @param end Index of the end of the range.
18 */
19inline
20JaggedVecEltBase::JaggedVecEltBase (index_type end)
21 : m_end (end)
22{
23}
24
25
26/**
27 * @brief Return the index of the beginning of the range.
28 * @param elt_ndx The index of this element in its container.
29 */
30inline
31JaggedVecEltBase::index_type JaggedVecEltBase::begin (size_t elt_ndx) const
32{
33 // Return 0 if we're looking at the first element, or our end index is 0.
34 if (elt_ndx == 0 || m_end == 0) [[unlikely]] {
35 return 0;
36 }
37
38 // Normal case: returm the end index from the elemente which is
39 // contiguously previous in memory.
40 return this[-1].m_end;
41}
42
43
44/**
45 * @brief Return the index of the end of the range.
46 */
47inline
48JaggedVecEltBase::index_type JaggedVecEltBase::end() const
49{
50 return m_end;
51}
52
53
54/**
55 * @brief Return the number of items in this range.
56 * @param elt_ndx The index of this element in its container.
57 */
58inline
59size_t JaggedVecEltBase::size (size_t elt_ndx) const
60{
61 return end() - begin (elt_ndx);
62}
63
64
65/**
66 * @brief Equality test.
67 * @param other Other element with which to compare.
68 */
69inline
70bool JaggedVecEltBase::operator== (const JaggedVecEltBase& other) const
71{
72 return m_end == other.m_end;
73}
74
75
76/// Constructor.
77inline
78JaggedVecEltBase::Shift::Shift (int offs)
79 : m_offs (offs)
80{
81}
82
83
84/// Shift indices in @c e by the offset given to the constructor.
85inline
86void JaggedVecEltBase::Shift::operator() (JaggedVecEltBase& e) const
87{
88 e.m_end += m_offs;
89}
90
91
92
93} // namespace SG