1 #ifndef DataFormats_Common_AssociationVector_h 2 #define DataFormats_Common_AssociationVector_h 26 #include <type_traits> 30 template<
class T>
class Ptr;
44 template<
typename REFPROD>
58 template<
typename KeyRefProd,
typename CVal,
60 typename SizeType =
unsigned int,
68 typedef typename KeyRefProd::product_type
CKey;
71 typedef typename std::pair<KeyRef, typename CVal::value_type>
value_type;
79 size_type
size()
const;
82 typename CVal::const_reference
operator[](KeyRef
const&
k)
const;
90 self& operator=(
self const&);
95 KeyRef
key(size_type
i)
const {
return KeyRef(ref_, i); }
99 std::vector<void const*>& pointers,
104 const_iterator
begin()
const {
return transientVector().begin(); }
105 const_iterator
end()
const {
return transientVector().end(); }
116 transient_vector_type
const& transientVector()
const;
120 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
124 return *(transientVector_.load(std::memory_order_acquire)); }
126 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
128 data_(), ref_(), transientVector_(
nullptr) { }
130 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
136 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
146 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
151 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
157 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
158 inline typename CVal::const_reference
162 return data_[ keyRef.key() ];
165 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
166 template<
typename K>
167 inline typename CVal::const_reference
174 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
175 template<
typename K>
176 typename CVal::const_reference
183 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
190 return data_[ keyRef.key() ];
193 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
206 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
211 (*t)[
i ].first = ref;
215 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
221 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
223 return data_.empty();
226 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
234 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
237 other.transientVector_.store(
transientVector_.exchange(
other.transientVector_.load(std::memory_order_acquire),std::memory_order_acq_rel),std::memory_order_release);
241 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
246 (*newT)[
i ] = std::make_pair(KeyRef(
ref_,
i),
data_[
i ]);
255 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
257 std::vector<void const*>& pointers,
268 template<
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
278 template <
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
283 std::vector<void const*>& pointers,
285 obj.
fillView(
id, pointers, helpers);
288 template <
typename KeyRefProd,
typename CVal,
typename KeyRef,
typename SizeType,
typename KeyReferenceHelper>
void checkForWrongProduct(ProductID const &keyID, ProductID const &refID)
void fillView(ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers) const
transient_vector_type::const_iterator const_iterator
void reallyFillView(COLLECTION const &coll, ProductID const &id, std::vector< void const * > &ptrs, FillViewHelperVector &helpers)
Ref< typename RefProd< C >::product_type > ref_type
self & operator=(self const &)
const_iterator end() const
std::vector< value_type > transient_vector_type
#define CMS_CLASS_VERSION(_version_)
bool setValue(Container &, const reco::JetBaseRef &, const JetExtendedData &)
associate jet with value. Returns false and associate nothing if jet is already associated ...
AssociationIdenticalKeyReference type
void swap(IndexRangeAssociation &lhs, IndexRangeAssociation &rhs)
Container::value_type value_type
value_type const & const_reference
const_reference operator[](size_type n) const
std::pair< KeyRef, typename CVal::value_type > value_type
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
void fillView(AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > const &obj, ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers)
T operator[](int i) const
CVal::value_type const value(size_type i) const
KeyRefProd::product_type CKey
KeyRef key(size_type i) const
KeyRef::value_type key_type
ProductID id() const
Accessor for product ID.
std::atomic< transient_vector_type * > transientVector_
KeyRefProd const & keyProduct() const
transient_vector_type const & transientVector() const
void setValue(size_type i, typename CVal::value_type const &val)
const_iterator begin() const
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector
T get(const Candidate &c)