CMS 3D CMS Logo

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