ATLAS Offline Software
Loading...
Searching...
No Matches
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
11namespace TCS {
12 template<class DATA>
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
56template<class DATA>
58 m_data.push_back(DATA::createOnHeap(tob));
59}
60
61#endif
unsigned int m_reserve
size_t capacity() const
const_iterator begin() const
DATA & operator[](const int i)
std::vector< DATA * > data_t
data_t::iterator iterator
size_t size() const
const_iterator end() const
virtual ~DataArrayImpl()
virtual void push_back(const DATA &tob)
data_t::const_iterator const_iterator
const DATA & operator[](const int i) const
DataArrayImpl(unsigned int reserve=0)