ATLAS Offline Software
Loading...
Searching...
No Matches
JaggedVecImpl.icc
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2024 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 // If the index is more than zero, return the end index from the
34 // element which is contiguously previous in memory.
35 if (elt_ndx > 0) {
36 return this[-1].m_end;
37 }
38 // Otherwise this is the first element. Return 0.
39 return 0;
40}
41
42
43/**
44 * @brief Return the index of the end of the range.
45 */
46inline
47JaggedVecEltBase::index_type JaggedVecEltBase::end() const
48{
49 return m_end;
50}
51
52
53/**
54 * @brief Return the number of items in this range.
55 * @param elt_ndx The index of this element in its container.
56 */
57inline
58size_t JaggedVecEltBase::size (size_t elt_ndx) const
59{
60 return end() - begin (elt_ndx);
61}
62
63
64/**
65 * @brief Equality test.
66 * @param other Other element with which to compare.
67 */
68inline
69bool JaggedVecEltBase::operator== (const JaggedVecEltBase& other) const
70{
71 return m_end == other.m_end;
72}
73
74
75/// Constructor.
76inline
77JaggedVecEltBase::Shift::Shift (int offs)
78 : m_offs (offs)
79{
80}
81
82
83/// Shift indices in @c e by the offset given to the constructor.
84inline
85void JaggedVecEltBase::Shift::operator() (JaggedVecEltBase& e) const
86{
87 e.m_end += m_offs;
88}
89
90
91
92} // namespace SG