1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
#ifndef DataFormats_Common_EDCollection_h
#define DataFormats_Common_EDCollection_h
/*----------------------------------------------------------------------
EDCollection: A collection of homogeneous objects that can be used for an EDProduct,
or as a base class for an EDProduct.
----------------------------------------------------------------------*/
#include <vector>
namespace edm {
template <class T>
class EDCollection {
public:
typedef T value_type;
typedef typename std::vector<T>::const_iterator const_iterator;
typedef typename std::vector<T>::size_type size_type;
EDCollection();
explicit EDCollection(size_type n);
explicit EDCollection(std::vector<T> const& vec);
EDCollection(EDCollection<T> const& h);
virtual ~EDCollection();
void push_back(T const& t);
void swap(EDCollection<T>& other);
EDCollection<T>& operator=(EDCollection<T> const& rhs);
bool empty() const;
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
T& operator[](size_type i);
T const& operator[](size_type i) const;
T& at(size_type i);
T const& at(size_type i) const;
const_iterator begin() const;
const_iterator end() const;
std::vector<T> const& as_vector() const { return obj; }
private:
std::vector<T> obj;
};
template <class T>
inline EDCollection<T>::EDCollection() : obj() {}
template <class T>
inline EDCollection<T>::EDCollection(size_type n) : obj(n) {}
template <class T>
inline EDCollection<T>::EDCollection(std::vector<T> const& vec) : obj(vec) {}
template <class T>
inline EDCollection<T>::EDCollection(EDCollection<T> const& h) : obj(h.obj) {}
template <class T>
EDCollection<T>::~EDCollection() {}
template <class T>
inline void EDCollection<T>::push_back(T const& t) {
obj.push_back(t);
}
template <class T>
inline void EDCollection<T>::swap(EDCollection<T>& other) {
obj.swap(other.obj);
}
template <class T>
inline EDCollection<T>& EDCollection<T>::operator=(EDCollection<T> const& rhs) {
EDCollection<T> temp(rhs);
this->swap(temp);
return *this;
}
template <class T>
inline bool EDCollection<T>::empty() const {
return obj.empty();
}
template <class T>
inline typename std::vector<T>::size_type EDCollection<T>::size() const {
return obj.size();
}
template <class T>
inline typename std::vector<T>::size_type EDCollection<T>::capacity() const {
return obj.capacity();
}
template <class T>
inline void EDCollection<T>::reserve(typename std::vector<T>::size_type n) {
obj.reserve(n);
}
template <class T>
inline T& EDCollection<T>::operator[](size_type i) {
return obj[i];
}
template <class T>
inline T const& EDCollection<T>::operator[](size_type i) const {
return obj[i];
}
template <class T>
inline T& EDCollection<T>::at(size_type i) {
return obj.at(i);
}
template <class T>
inline T const& EDCollection<T>::at(size_type i) const {
return obj.at(i);
}
template <class T>
inline typename std::vector<T>::const_iterator EDCollection<T>::begin() const {
return obj.begin();
}
template <class T>
inline typename std::vector<T>::const_iterator EDCollection<T>::end() const {
return obj.end();
}
// Free swap function
template <class T>
inline void swap(EDCollection<T>& a, EDCollection<T>& b) {
a.swap(b);
}
} // namespace edm
#endif
|