ATLAS Offline Software
DataArrayImpl.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 #ifndef L1TopoEvent_DataArrayImpl
4 #define L1TopoEvent_DataArrayImpl
5 
6 #include <iostream>
7 #include <vector>
8 
10 
11 namespace TCS {
12  template<class DATA>
13  class DataArrayImpl {
14  public:
15 
16  typedef std::vector<DATA*> data_t;
17  typedef typename data_t::iterator iterator;
18  typedef typename data_t::const_iterator const_iterator;
19 
20  // constructor
21  DataArrayImpl(unsigned int reserve = 0) :
22  m_reserve(reserve)
23  {
24  m_data.reserve(reserve);
25  }
26 
27  // destructor
28  virtual ~DataArrayImpl(){};
29 
30  size_t size() const { return m_data.size(); }
31 
32  size_t capacity() const { return m_data.capacity(); }
33 
34  void clear() { m_data.clear(); }
35 
36  virtual void push_back(const DATA& tob);
37 
38  void pop_back() { m_data.pop_back(); }
39 
40  iterator begin() { return m_data.begin(); }
41  const_iterator begin() const { return m_data.begin(); }
42 
43  iterator end() { return m_data.end(); }
44  const_iterator end() const { return m_data.end(); }
45 
46  DATA& operator[](const int i) { return *m_data[i]; }
47  const DATA& operator[](const int i) const { return *m_data[i]; }
48 
49  protected:
51  unsigned int m_reserve {0};
52  };
53 
54 }
55 
56 template<class DATA>
57 void TCS::DataArrayImpl<DATA>::push_back(const DATA& tob) {
58  m_data.push_back(DATA::createOnHeap(tob));
59 }
60 
61 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TCS::DataArrayImpl::data_t
std::vector< DATA * > data_t
Definition: DataArrayImpl.h:16
TCS::DataArrayImpl::end
const_iterator end() const
Definition: DataArrayImpl.h:44
TCS::DataArrayImpl::const_iterator
data_t::const_iterator const_iterator
Definition: DataArrayImpl.h:18
m_data
std::vector< T > m_data
Definition: TrackTruthMatchingBaseAlg.cxx:660
TCS::DataArrayImpl::operator[]
const DATA & operator[](const int i) const
Definition: DataArrayImpl.h:47
TCS::DataArrayImpl::m_reserve
unsigned int m_reserve
Definition: DataArrayImpl.h:51
TCS::DataArrayImpl::end
iterator end()
Definition: DataArrayImpl.h:43
TCS::DataArrayImpl
Definition: DataArrayImpl.h:13
lumiFormat.i
int i
Definition: lumiFormat.py:85
TCS::DataArrayImpl::size
size_t size() const
Definition: DataArrayImpl.h:30
TCS::DataArrayImpl::capacity
size_t capacity() const
Definition: DataArrayImpl.h:32
TCS::DataArrayImpl::DataArrayImpl
DataArrayImpl(unsigned int reserve=0)
Definition: DataArrayImpl.h:21
TCS::DataArrayImpl::begin
const_iterator begin() const
Definition: DataArrayImpl.h:41
TCS::DataArrayImpl::pop_back
void pop_back()
Definition: DataArrayImpl.h:38
TCS::DataArrayImpl::m_data
data_t m_data
Definition: DataArrayImpl.h:50
TCS::DataArrayImpl::~DataArrayImpl
virtual ~DataArrayImpl()
Definition: DataArrayImpl.h:28
TCS::DataArrayImpl::begin
iterator begin()
Definition: DataArrayImpl.h:40
TCS::DataArrayImpl::clear
void clear()
Definition: DataArrayImpl.h:34
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
TCS::DataArrayImpl::push_back
virtual void push_back(const DATA &tob)
Definition: DataArrayImpl.h:57
TCS::DataArrayImpl::iterator
data_t::iterator iterator
Definition: DataArrayImpl.h:17
TCS::DataArrayImpl::operator[]
DATA & operator[](const int i)
Definition: DataArrayImpl.h:46
DataArray.h