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 
40  private:
41  std::vector<T> obj;
42  };
43 
44  template <class T>
46 
47  template <class T>
49 
50  template <class T>
51  inline EDCollection<T>::EDCollection(std::vector<T> const& vec) : obj(vec) {}
52 
53  template <class T>
55 
56  template <class T>
58 
59  template <class T>
60  inline void EDCollection<T>::push_back(T const& t) {
61  obj.push_back(t);
62  }
63 
64  template <class T>
66  obj.swap(other.obj);
67  }
68 
69  template <class T>
71  EDCollection<T> temp(rhs);
72  this->swap(temp);
73  return *this;
74  }
75 
76  template <class T>
77  inline bool EDCollection<T>::empty() const {
78  return obj.empty();
79  }
80 
81  template <class T>
83  return obj.size();
84  }
85 
86  template <class T>
88  return obj.capacity();
89  }
90 
91  template <class T>
93  obj.reserve(n);
94  }
95 
96  template <class T>
98  return obj[i];
99  }
100 
101  template <class T>
102  inline T const& EDCollection<T>::operator[](size_type i) const {
103  return obj[i];
104  }
105 
106  template <class T>
108  return obj.at(i);
109  }
110 
111  template <class T>
112  inline T const& EDCollection<T>::at(size_type i) const {
113  return obj.at(i);
114  }
115 
116  template <class T>
117  inline typename std::vector<T>::const_iterator EDCollection<T>::begin() const {
118  return obj.begin();
119  }
120 
121  template <class T>
122  inline typename std::vector<T>::const_iterator EDCollection<T>::end() const {
123  return obj.end();
124  }
125 
126  // Free swap function
127  template <class T>
129  a.swap(b);
130  }
131 
132 } // namespace edm
133 
134 #endif
edm::EDCollection::push_back
void push_back(T const &t)
Definition: EDCollection.h:60
edm::EDCollection::begin
const_iterator begin() const
Definition: EDCollection.h:117
edm::EDCollection::EDCollection
EDCollection()
Definition: EDCollection.h:45
mps_fire.i
i
Definition: mps_fire.py:428
edm::EDCollection::value_type
T value_type
Definition: EDCollection.h:18
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::EDCollection::operator[]
T & operator[](size_type i)
Definition: EDCollection.h:97
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EDCollection::obj
std::vector< T > obj
Definition: EDCollection.h:41
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::EDCollection::capacity
size_type capacity() const
Definition: EDCollection.h:87
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
edm::EDCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: EDCollection.h:19
mps_fire.end
end
Definition: mps_fire.py:242
trackingPlots.other
other
Definition: trackingPlots.py:1467
h
edm::EDCollection::~EDCollection
virtual ~EDCollection()
Definition: EDCollection.h:57
b
double b
Definition: hdecay.h:118
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
edm::EDCollection::empty
bool empty() const
Definition: EDCollection.h:77
a
double a
Definition: hdecay.h:119
edm::EDCollection::swap
void swap(EDCollection< T > &other)
Definition: EDCollection.h:65
edm::EDCollection::reserve
void reserve(size_type n)
Definition: EDCollection.h:92
edm::EDCollection::size_type
std::vector< T >::size_type size_type
Definition: EDCollection.h:20
edm::EDCollection::at
T & at(size_type i)
Definition: EDCollection.h:107
edm::EDCollection::operator=
EDCollection< T > & operator=(EDCollection< T > const &rhs)
Definition: EDCollection.h:70
edm::EDCollection
Definition: EDCollection.h:16
edm::swap
void swap(EDCollection< T > &a, EDCollection< T > &b)
Definition: EDCollection.h:128
T
long double T
Definition: Basic3DVectorLD.h:48
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
edm::EDCollection::size
size_type size() const
Definition: EDCollection.h:82
operator[]
T operator[](int i) const
Definition: extBasic3DVector.h:222
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
edm::EDCollection::end
const_iterator end() const
Definition: EDCollection.h:122
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443