CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
40 
41  private:
42  std::vector<T> obj;
43  };
44 
45  template <class T>
46  inline
48 
49  template <class T>
50  inline
52 
53  template <class T>
54  inline
55  EDCollection<T>::EDCollection(std::vector<T> const& vec) : obj(vec) {}
56 
57  template <class T>
58  inline
60 
61  template <class T>
63 
64  template <class T>
65  inline
66  void
68  obj.push_back(t);
69  }
70 
71  template <class T>
72  inline
73  void
75  obj.swap(other.obj);
76  }
77 
78  template <class T>
79  inline
82  EDCollection<T> temp(rhs);
83  this->swap(temp);
84  return *this;
85  }
86 
87  template <class T>
88  inline
89  bool
91  return obj.empty();
92  }
93 
94  template <class T>
95  inline
98  return obj.size();
99  }
100 
101  template <class T>
102  inline
105  return obj.capacity();
106  }
107 
108  template <class T>
109  inline
110  void
112  obj.reserve(n);
113  }
114 
115  template <class T>
116  inline
117  T&
119  return obj[i];
120  }
121 
122  template <class T>
123  inline
124  T const&
126  return obj[i];
127  }
128 
129  template <class T>
130  inline
131  T&
133  return obj.at(i);
134  }
135 
136  template <class T>
137  inline
138  T const&
140  return obj.at(i);
141  }
142 
143  template <class T>
144  inline
145  typename std::vector<T>::const_iterator
147  return obj.begin();
148  }
149 
150  template <class T>
151  inline
152  typename std::vector<T>::const_iterator
154  return obj.end();
155  }
156 
157  // Free swap function
158  template <class T>
159  inline
160  void
162  {
163  a.swap(b);
164  }
165 
166 }
167 
168 #endif
size_type size() const
Definition: EDCollection.h:97
int i
Definition: DBlmapReader.cc:9
virtual ~EDCollection()
Definition: EDCollection.h:62
const_iterator end() const
Definition: EDCollection.h:153
void push_back(T const &t)
Definition: EDCollection.h:67
uint16_t size_type
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
bool empty() const
Definition: EDCollection.h:90
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< T > obj
Definition: EDCollection.h:42
std::vector< T >::size_type size_type
Definition: EDCollection.h:20
void reserve(size_type n)
Definition: EDCollection.h:111
const_iterator begin() const
Definition: EDCollection.h:146
T & at(size_type i)
Definition: EDCollection.h:132
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
long double T
void swap(EDCollection< T > &other)
Definition: EDCollection.h:74
size_type capacity() const
Definition: EDCollection.h:104
std::vector< T >::const_iterator const_iterator
Definition: EDCollection.h:19
T & operator[](size_type i)
Definition: EDCollection.h:118
EDCollection< T > & operator=(EDCollection< T > const &rhs)
Definition: EDCollection.h:81