1 #ifndef DataFormats_Common_AssociationVector_h
2 #define DataFormats_Common_AssociationVector_h
27 #include "boost/static_assert.hpp"
42 template<
typename REFPROD>
56 template<
typename KeyRefProd,
typename CVal,
58 typename SizeType =
unsigned int,
66 typedef typename KeyRefProd::product_type
CKey;
69 typedef typename std::pair<KeyRef, typename CVal::value_type>
value_type;
80 typename CVal::const_reference
operator[](KeyRef
const&
k)
const;
81 typename CVal::reference
operator[](KeyRef
const&
k);
86 void swap(
self& other);
92 std::vector<void const*>& pointers,
109 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
111 data_(), ref_(), transientVector_(), fixed_(
false) { }
113 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
116 data_(coll == 0 ? ref->
size() : coll->
size()), ref_(ref),
117 transientVector_(coll == 0 ? ref->
size() : coll->
size()), fixed_(
true) { }
119 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
122 data_(o.data_), ref_(o.ref_), transientVector_(o.transientVector_), fixed_(o.fixed_) { }
124 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
127 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
130 return transientVector()[
n ];
133 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
134 inline typename CVal::const_reference
138 return data_[ keyRef.key() ];
142 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
143 inline typename CVal::reference
148 return data_[ keyRef.key() ];
151 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
160 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
164 transientVector_[
i ].first = ref;
165 transientVector_[
i ].second = data_[
i ];
168 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
174 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
176 return data_.empty();
179 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
182 transientVector_.clear();
187 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
189 data_.swap(other.data_);
190 transientVector_.swap(other.transientVector_);
191 ref_.swap(other.ref_);
195 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
199 transientVector_.resize(
size());
201 transientVector_[
i ] = std::make_pair(KeyRef(ref_,
i), data_[
i ]);
206 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
208 std::vector<void const*>& pointers,
219 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
229 template <
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
234 std::vector<void const*>& pointers,
236 obj.
fillView(
id, pointers, helpers);
239 template <
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
void checkForWrongProduct(ProductID const &keyID, ProductID const &refID)
void fillView(AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > const &obj, ProductID const &id, std::vector< void const * > &pointers, helper_vector &helpers)
transient_vector_type::const_iterator const_iterator
Ref< typename RefProd< C >::product_type > ref_type
void reallyFillView(COLLECTION const &coll, ProductID const &id, std::vector< void const * > &ptrs, helper_vector &helpers)
void fillView(ProductID const &id, std::vector< void const * > &pointers, helper_vector &helpers) const
self & operator=(self const &)
const_iterator end() const
Container::value_type value_type
std::vector< value_type > transient_vector_type
void swap(Association< C > &lhs, Association< C > &rhs)
AssociationIdenticalKeyReference type
transient_vector_type const & transientVector() const
tuple obj
Example code starts here #.
value_type const & const_reference
const_reference operator[](size_type n) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::pair< KeyRef, typename CVal::value_type > value_type
BOOST_STATIC_ASSERT((boost::is_convertible< SizeType, typename CVal::size_type >::value))
transient_vector_type transientVector_
CVal::value_type const value(size_type i) const
KeyRefProd::product_type CKey
KeyRef key(size_type i) const
KeyRef::value_type key_type
KeyRefProd const & keyProduct() const
void setValue(size_type i, typename CVal::value_type const &val)
const_iterator begin() const
tuple size
Write out results.
T get(const Candidate &c)