1 #ifndef DataFormats_Common_DetSetRefVector_h
2 #define DataFormats_Common_DetSetRefVector_h
31 #include "boost/concept_check.hpp"
32 #include "boost/iterator/indirect_iterator.hpp"
62 "DetSetRefVector::operator[] called with index not in collection;\nindex value: ", i);
69 template<
typename T,
typename C >
72 typename self::result_type
operator()(
typename self::first_argument_type iContainer,
typename self::second_argument_type iIndex)
const {
73 return &(*(iContainer.find(iIndex)));
79 template <
typename T,
typename C=DetSetVector<T> >
83 return iRef.
key() < iId;
86 return iId < iRef.
key();
90 template <
typename T,
typename C=DetSetVector<T> >
106 typedef boost::indirect_iterator<typename collection_type::const_iterator>
const_iterator;
119 sets_.reserve(iDets.size());
121 for(std::vector<det_id_type>::const_iterator itDetId = iDets.begin(),
122 itDetIdEnd = iDets.end();
123 itDetId != itDetIdEnd;
125 assert(sanityCheck <= *itDetId &&
"vector of det_id_type was not ordered");
126 sanityCheck = *itDetId;
133 sets_.reserve(iDets.size());
135 for(std::vector<det_id_type>::const_iterator itDetId = iDets.begin(),
136 itDetIdEnd = iDets.end();
137 itDetId != itDetIdEnd;
139 assert(sanityCheck <= *itDetId &&
"vector of det_id_type was not ordered");
140 sanityCheck = *itDetId;
147 sets_.reserve(iDets.size());
149 for(std::vector<det_id_type>::const_iterator itDetId = iDets.begin(),
150 itDetIdEnd = iDets.end();
151 itDetId != itDetIdEnd;
153 assert(sanityCheck <= *itDetId &&
"vector of det_id_type was not ordered");
154 sanityCheck = *itDetId;
205 sets_.swap(other.sets_);
208 template <
typename T,
typename C>
217 template <
typename T,
typename C>
222 return sets_.empty();
225 template <
typename T,
typename C>
233 template <
typename T,
typename C>
241 std::pair<typename collection_type::const_iterator,typename collection_type::const_iterator>
p =
243 if (p.first == p.second)
return sets_.end();
246 assert(std::distance(p.first, p.second) == 1);
250 template <
typename T,
typename C>
262 template <
typename T,
typename C>
267 return sets_.begin();
270 template <
typename T,
typename C>
279 template <
typename T,
typename C>
288 namespace refhelper {
289 template<
typename T,
typename C>
290 struct FindForDetSetRefVector :
public std::binary_function<const DetSetRefVector<T,C>&, std::pair<det_id_type, typename DetSet<T>::collection_type::size_type>, const T*> {
292 typename self::result_type
operator()(
typename self::first_argument_type iContainer,
typename self::second_argument_type iIndex) {
293 return &(*(iContainer.find(iIndex.first)->data.begin()+iIndex.second));
297 template<
typename T,
typename C>
305 template<
class HandleT>
309 typename HandleT::element_type::value_type::const_iterator itIter) {
310 typedef typename HandleT::element_type Vec;
312 typename Vec::const_iterator itFound = iHandle->find(iDetID);
313 index += (itIter- itFound->data.begin());
317 template<
class HandleT>
318 Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type>
321 typename HandleT::element_type::value_type::iterator itIter) {
322 typedef typename HandleT::element_type Vec;
323 typename Vec::detset::const_iterator itIter2 = itIter;
DetSetRefVector & operator=(DetSetRefVector const &rhs)
Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefToDetSetRefVector(const HandleT &iHandle, det_id_type iDetID, typename HandleT::element_type::value_type::const_iterator itIter)
DetSetRefVector(const OrphanHandle< C > &iHandle, const std::vector< det_id_type > &iDets)
key_type key() const
Accessor for product key.
#define CMS_CLASS_VERSION(_version_)
const_iterator find(det_id_type id) const
DetSetRefVector(const Handle< C > &iHandle, const std::vector< det_id_type > &iDets)
Ref< C, DetSet< T >, refhelper::FindDetSetForDetSetVector< T, C > > ref_type
void _throw_range(det_id_type i)
std::vector< ref_type > collection_type
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
self::result_type operator()(typename self::first_argument_type iContainer, typename self::second_argument_type iIndex)
detset const & const_reference
const_iterator begin() const
Return an iterator to the first DetSet.
bool operator()(const ref_type &iRef, det_id_type iId)
bool empty() const
Return true if we contain no DetSets.
const_reference operator[](det_id_type i) const
bool operator()(det_id_type iId, const ref_type &iRef)
collection_type::size_type size_type
Ref< C, DetSet< T >, refhelper::FindDetSetForDetSetVector< T, C > > ref_type
size_type size() const
Return the number of contained DetSets.
void swap(DetSetRefVector &other)
BOOST_CLASS_REQUIRE(T, boost, LessThanComparableConcept)
FindForDetSetRefVector< T, C > value
boost::indirect_iterator< typename collection_type::const_iterator > const_iterator
const_iterator end() const
Return the off-the-end iterator.
self::result_type operator()(typename self::first_argument_type iContainer, typename self::second_argument_type iIndex) const
DetSetRefVector(const TestHandle< C > &iHandle, const std::vector< det_id_type > &iDets)