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"
49 template <
typename T,
typename C>
56 namespace dsrvdetail {
60 "DetSetRefVector::operator[] called with index not in collection;\nindex value: ",
68 template <
typename T,
typename C>
75 return &(*(iContainer.find(iIndex)));
81 template <
typename T,
typename C = DetSetVector<T> >
88 template <
typename T,
typename C = DetSetVector<T> >
89 class DetSetRefVector {
103 typedef boost::indirect_iterator<typename collection_type::const_iterator>
const_iterator;
116 sets_.reserve(iDets.size());
118 for (std::vector<det_id_type>::const_iterator itDetId = iDets.begin(), itDetIdEnd = iDets.end();
119 itDetId != itDetIdEnd;
121 assert(sanityCheck <= *itDetId &&
"vector of det_id_type was not ordered");
122 sanityCheck = *itDetId;
129 sets_.reserve(iDets.size());
131 for (std::vector<det_id_type>::const_iterator itDetId = iDets.begin(), itDetIdEnd = iDets.end();
132 itDetId != itDetIdEnd;
134 assert(sanityCheck <= *itDetId &&
"vector of det_id_type was not ordered");
135 sanityCheck = *itDetId;
142 sets_.reserve(iDets.size());
144 for (std::vector<det_id_type>::const_iterator itDetId = iDets.begin(), itDetIdEnd = iDets.end();
145 itDetId != itDetIdEnd;
147 assert(sanityCheck <= *itDetId &&
"vector of det_id_type was not ordered");
148 sanityCheck = *itDetId;
196 sets_.swap(other.sets_);
199 template <
typename T,
typename C>
206 template <
typename T,
typename C>
208 return sets_.empty();
211 template <
typename T,
typename C>
216 template <
typename T,
typename C>
221 std::pair<typename collection_type::const_iterator, typename collection_type::const_iterator>
p =
223 if (p.first == p.second)
231 template <
typename T,
typename C>
236 if (it == this->
end())
241 template <
typename T,
typename C>
243 return sets_.begin();
246 template <
typename T,
typename C>
252 template <
typename T,
typename C>
259 namespace refhelper {
260 template <
typename T,
typename C>
267 return &(*(iContainer.
find(iIndex.first)->data.begin() + iIndex.second));
271 template <
typename T,
typename C>
279 template <
class HandleT>
281 const HandleT& iHandle,
det_id_type iDetID,
typename HandleT::element_type::value_type::const_iterator itIter) {
282 typedef typename HandleT::element_type Vec;
284 typename Vec::const_iterator itFound = iHandle->find(iDetID);
285 index += (itIter - itFound->data.begin());
287 iHandle, std::make_pair(iDetID, index));
290 template <
class HandleT>
292 const HandleT& iHandle,
det_id_type iDetID,
typename HandleT::element_type::value_type::iterator itIter) {
293 typedef typename HandleT::element_type Vec;
294 typename Vec::detset::const_iterator itIter2 = itIter;
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)
Ref< C, DetSet< T >, refhelper::FindDetSetForDetSetVector< T, C > > ref_type
uint16_t *__restrict__ id
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
result_type operator()(first_argument_type iContainer, second_argument_type iIndex)
DetSetRefVector(const Handle< C > &iHandle, const std::vector< det_id_type > &iDets)
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="")
detset const & const_reference
DetSetRefVector & operator=(DetSetRefVector const &rhs)
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)
std::pair< det_id_type, typename DetSet< T >::collection_type::size_type > second_argument_type
collection_type::size_type size_type
C const & first_argument_type
FindForDetSetRefVector< T, C > value
size_type size() const
Return the number of contained DetSets.
void swap(DetSetRefVector &other)
edm::det_id_type const second_argument_type
BOOST_CLASS_REQUIRE(T, boost, LessThanComparableConcept)
Ref< C, DetSet< T >, refhelper::FindDetSetForDetSetVector< T, C > > ref_type
result_type operator()(first_argument_type iContainer, second_argument_type iIndex) const
boost::indirect_iterator< typename collection_type::const_iterator > const_iterator
const_iterator end() const
Return the off-the-end iterator.
DetSetRefVector(const TestHandle< C > &iHandle, const std::vector< det_id_type > &iDets)