ATLAS Offline Software
Loading...
Searching...
No Matches
ArenaBlock.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4/**
5 * @file AthAllocators/ArenaBlock.icc
6 * @author scott snyder
7 * @date May 2007
8 * @brief These are large blocks of memory that get allocated and
9 * divided up into smaller, uniform elements.
10 * Inline/template implementations.
11 */
12
13namespace SG {
14
15
16/**
17 * @brief Return the number of elements in the block.
18 */
19inline
20size_t ArenaBlock::size() const
21{
22 return m_size;
23}
24
25
26/**
27 * @brief Return the size of the elements in the block.
28 */
29inline
30size_t ArenaBlock::eltSize() const
31{
32 return m_elt_size;
33}
34
35
36/**
37 * @brief Return the link pointer of the block.
38 */
39inline
40ArenaBlock*& ArenaBlock::link()
41{
42 return m_link;
43}
44
45
46/**
47 * @brief Return the link pointer of the block.
48 */
49inline
50const ArenaBlock* ArenaBlock::link() const
51{
52 return m_link;
53}
54
55
56/**
57 * @brief Return a pointer to element @c i in the block.
58 * @param i The index of the desired element.
59 */
60inline
61ArenaBlock::pointer ArenaBlock::index (size_t i)
62{
63 return reinterpret_cast<char*>(this) +
64 ArenaBlockBodyOffset + i*eltSize();
65}
66
67
68/**
69 * @brief Return a pointer to element @c i in the block.
70 * @param i The index of the desired element.
71 */
72inline
73ArenaBlock::const_pointer ArenaBlock::index (size_t i) const
74{
75 return reinterpret_cast<const char*>(this) +
76 ArenaBlockBodyOffset + i*eltSize();
77}
78
79
80/**
81 * @brief Return a pointer to element @c i in the block.
82 * @param i The index of the desired element.
83 * @param elt_size The block's element size.
84 *
85 * This is provided in addition to the previous function as it may
86 * allow for better inlined code in when used in a loop, if @c elt_size
87 * is saved in a local.
88 */
89inline
90ArenaBlock::pointer ArenaBlock::index (size_t i, size_t elt_size)
91{
92 return reinterpret_cast<char*>(this) + ArenaBlockBodyOffset + i*elt_size;
93}
94
95
96/**
97 * @brief Return a pointer to element @c i in the block.
98 * @param i The index of the desired element.
99 * @param elt_size The block's element size.
100 *
101 * This is provided in addition to the previous function as it may
102 * allow for better inlined code in when used in a loop, if @c elt_size
103 * is saved in a local.
104 */
105inline
106ArenaBlock::const_pointer ArenaBlock::index (size_t i, size_t elt_size) const
107{
108 return reinterpret_cast<const char*>(this) + ArenaBlockBodyOffset + i*elt_size;
109}
110
111
112/**
113 * @brief Return the global number of blocks in use.
114 */
115inline
116size_t ArenaBlock::nactive()
117{
118 return s_nactive;
119}
120
121
122} // namespace SG