1 #ifndef DataFormats_Common_DetSetVectorNew_h
2 #define DataFormats_Common_DetSetVectorNew_h
9 #include <boost/iterator_adaptors.hpp>
10 #include <boost/iterator/transform_iterator.hpp>
11 #include <boost/iterator/counting_iterator.hpp>
12 #include <boost/any.hpp>
38 namespace dstvdetails {
84 class DetSetVector :
private dstvdetails::DetSetVectorTrans {
101 typedef typename IdContainer::iterator
IdIter;
102 typedef typename std::vector<data_type>::iterator
DataIter;
127 typedef std::pair<const_iterator,const_iterator>
Range;
194 v.m_data.push_back(d);
209 friend class ::TestDetSet;
217 class FindForDetSetVector :
public std::binary_function<const edmNew::DetSetVector<T>&, unsigned int, const T*> {
220 typename self::result_type
operator()(
typename self::first_argument_type iContainer,
typename self::second_argument_type iIndex) {
221 return &(iContainer.m_data[iIndex]);
253 m_ids.reserve(isize);
259 m_ids.shrink_to_fit();
264 void resize(
size_t isize,
size_t dsize) {
274 return DetSet(*
this,item,
false);
280 return DetSet(*
this,item,
false);
291 if (p==
m_ids.end())
return;
293 if ((*p).size>0&& (*p).offset>-1 &&
294 m_data.size()==(*p).offset+(*p).size)
295 m_data.resize((*p).offset);
307 return *
m_ids.insert(p,it);
323 return p!=
m_ids.end() && (*p).offset!=-1;
338 return DetSet(*
this,*p,
true);
346 boost::make_transform_iterator(p,
352 std::pair<const_IdIter,const_IdIter>
p =
354 return (p.first!=p.second) ? p.first :
m_ids.end();
359 return boost::make_transform_iterator(
m_ids.begin(),
365 return boost::make_transform_iterator(
m_ids.end(),
371 template<
typename CMP>
374 std::pair<const_IdIter,const_IdIter>
p =
376 return Range(boost::make_transform_iterator(p.first,IterHelp(*
this,
update)),
377 boost::make_transform_iterator(p.second,IterHelp(*
this,
update))
403 return m_ids[cell].id;
429 friend class ::TestDetSet;
444 template<
typename T>
456 const std::vector<det_id_type>& iDets,
461 m_ids.reserve(iDets.size());
463 for(std::vector<det_id_type>::const_iterator itDetId = iDets.begin(), itDetIdEnd = iDets.end();
464 itDetId != itDetIdEnd;
466 assert(sanityCheck < *itDetId &&
"vector of det_id_type was not ordered");
467 sanityCheck = *itDetId;
468 m_ids.push_back(*itDetId);
476 if (item.
offset!=-1 || getter.empty() )
return;
477 item.
offset = int(m_data.size());
479 (*boost::any_cast<std::shared_ptr<Getter> >(&getter))->fill(ff);
493 m_data=&icont.data();
501 #include <boost/mpl/assert.hpp>
502 #include <boost/type_traits/is_same.hpp>
507 namespace refhelper {
516 namespace refhelper {
520 typename self::result_type
operator()(
typename self::first_argument_type iContainer,
typename self::second_argument_type iIndex) {
521 return &(iContainer[iIndex]);
535 template<
class HandleT>
538 typename HandleT::element_type::value_type::const_iterator itIter) {
541 return edm::Ref<
typename HandleT::element_type,
557 return iElement-&(iContainer->
data().front());
void swap(ora::Record &rh, ora::Record &lh)
bool isValid(id_type i) const
DataContainer const & data() const
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
static unsigned int indexFor(const value_type *iElement, const edmNew::DetSetVector< T > *iContainer)
void swap(DetSetVectorTrans &rh)
void push_back(data_type const &d)
void update(Item const &item) const
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
size_type dataSize() const
DetSetVector< T >::id_type id_type
void reserve(size_type s)
Range equal_range(id_type i, CMP cmp, bool update=false) const
std::vector< data_type > DataContainer
Item & push_back(id_type iid)
const_IdIter findItem(id_type i) const
std::vector< Trans::Item > m_ids
bool any(const std::vector< T > &v, const T &what)
IdContainer::iterator IdIter
void checkCapacityExausted(size_type s) const
void set(Container const &icont, typename Container::Item const &item, bool update=true)
void throwCapacityExausted()
edmNew::DetSetVector< T >::FindForDetSetVector value
std::vector< data_type >::const_iterator const_DataIter
void swap(DetSetVector &rh)
void throw_range(det_id_type iid)
std::pair< const_IdIter, const_DataIter > const_IterPair
DetSetVector(int isubdet=0)
std::pair< const_iterator, const_iterator > Range
void pop_back(id_type iid)
#define CMS_CLASS_VERSION(_version_)
id_type id(size_t cell) const
bool operator<(Item const &rh) const
dstvdetails::DetSetVectorTrans Trans
self::result_type operator()(typename self::first_argument_type iContainer, typename self::second_argument_type iIndex)
Item const & item(size_t cell) const
DetSetVector< T > const * v
void checkCapacityExausted() const
IterHelp(DetSetVector< T > const &iv, bool iup)
Item & addItem(id_type iid, size_type isize)
DetSetVector< T >::data_type value_type
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
bool exists(id_type i) const
IdContainer const & ids() const
data_type const * data(size_t cell) const
FastFiller(DetSetVector< T > &iv, id_type id, bool isaveEmpty=false)
FindSetForNewDetSetVector< T > value
Item(id_type i=0, int io=-1, size_type is=0)
DetSetVector< T >::Item & item
void swap(IdContainer &iic, DataContainer &idc)
Container::value_type value_type
DetSetVector< T >::id_type key_type
static size_t size(const edmNew::DetSetVector< T > *iContainer)
void resize(size_t isize, size_t dsize)
size_type detsetSize(size_t cell) const
DetSet insert(id_type iid, data_type const *idata, size_type isize)
std::vector< Item > IdContainer
friend class FindForDetSetVector
dslv::LazyGetter< T > Getter
void errorIdExists(det_id_type iid)
void reserve(size_t isize, size_t dsize)
std::vector< data_type >::iterator DataIter
result_type & operator()(Item const &item) const
const_iterator find(id_type i, bool update=false) const
CapacityExaustedException()
DetSet insert(id_type iid, size_type isize)
std::pair< IdIter, DataIter > IterPair
void updateImpl(Item &item)
IdContainer::const_iterator const_IdIter
data_type operator()(size_t cell, size_t frame) const
self::result_type operator()(typename self::first_argument_type iContainer, typename self::second_argument_type iIndex)
edmNew::DetSet< T > DetSet
volatile std::atomic< bool > shutdown_flag false
FastFiller(DetSetVector< T > &iv, typename DetSetVector< T >::Item &it, bool isaveEmpty=false)
data_type & operator[](size_type i)
edm::refhelper::FindForNewDetSetVector< data_type > RefFinder
DetSetVector< T >::size_type size_type
DetSet operator[](id_type i) const
const_iterator begin(bool update=false) const