CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

edm::DetSetLazyVector< T > Class Template Reference

#include <DetSetLazyVector.h>

List of all members.

Public Types

typedef std::vector< value_typecollection_type
typedef
boost::transform_iterator
< dslv::LazyAdapter< T >
, typename
collection_type::const_iterator > 
const_iterator
typedef detset const & const_reference
typedef DetSet< Tdetset
typedef collection_type::size_type size_type
typedef detset value_type

Public Member Functions

const_iterator begin () const
 Return an iterator to the first DetSet.
 DetSetLazyVector ()
 DetSetLazyVector (boost::shared_ptr< dslv::LazyGetter< T > > iGetter, const std::vector< det_id_type > &iDets)
bool empty () const
 Return true if we contain no DetSets.
const_iterator end () const
 Return the off-the-end iterator.
const_iterator find (det_id_type id) const
const_reference operator[] (det_id_type i) const
size_type size () const
 Return the number of contained DetSets.
void swap (DetSetLazyVector &other)

Private Member Functions

 BOOST_CLASS_REQUIRE (T, boost, LessThanComparableConcept)

Private Attributes

boost::shared_ptr
< dslv::LazyGetter< T > > 
getter_
collection_type sets_

Detailed Description

template<class T>
class edm::DetSetLazyVector< T >

Definition at line 97 of file DetSetLazyVector.h.


Member Typedef Documentation

template<class T>
typedef std::vector<value_type> edm::DetSetLazyVector< T >::collection_type

Definition at line 106 of file DetSetLazyVector.h.

template<class T>
typedef boost::transform_iterator< dslv::LazyAdapter<T>, typename collection_type::const_iterator > edm::DetSetLazyVector< T >::const_iterator

Definition at line 111 of file DetSetLazyVector.h.

template<class T>
typedef detset const& edm::DetSetLazyVector< T >::const_reference

Definition at line 108 of file DetSetLazyVector.h.

template<class T>
typedef DetSet<T> edm::DetSetLazyVector< T >::detset

Definition at line 104 of file DetSetLazyVector.h.

template<class T>
typedef collection_type::size_type edm::DetSetLazyVector< T >::size_type

Definition at line 112 of file DetSetLazyVector.h.

template<class T>
typedef detset edm::DetSetLazyVector< T >::value_type

Definition at line 105 of file DetSetLazyVector.h.


Constructor & Destructor Documentation

template<class T>
edm::DetSetLazyVector< T >::DetSetLazyVector ( ) [inline]

Compiler-generated default c'tor, copy c'tor, d'tor and assignment are correct.

Definition at line 121 of file DetSetLazyVector.h.

{}
template<class T>
edm::DetSetLazyVector< T >::DetSetLazyVector ( boost::shared_ptr< dslv::LazyGetter< T > >  iGetter,
const std::vector< det_id_type > &  iDets 
) [inline]

Definition at line 123 of file DetSetLazyVector.h.

References edm::DetSetLazyVector< T >::sets_.

                                                                                                       :
    sets_(),
    getter_(iGetter) {
        sets_.reserve(iDets.size());
        det_id_type sanityCheck = 0;
        for(std::vector<det_id_type>::const_iterator itDetId = iDets.begin(), itDetIdEnd = iDets.end();
            itDetId != itDetIdEnd;
            ++itDetId) {
          assert(sanityCheck <= *itDetId && "vector of det_id_type was not ordered");
          sanityCheck = *itDetId;
          sets_.push_back(DetSet<T>(*itDetId));
        }
      }

Member Function Documentation

template<class T >
DetSetLazyVector< T >::const_iterator edm::DetSetLazyVector< T >::begin ( void  ) const [inline]

Return an iterator to the first DetSet.

Definition at line 239 of file DetSetLazyVector.h.

  {
    dslv::LazyAdapter<T> adapter(getter_);
    return boost::make_transform_iterator(sets_.begin(),adapter);
  }
template<class T>
edm::DetSetLazyVector< T >::BOOST_CLASS_REQUIRE ( T  ,
boost  ,
LessThanComparableConcept   
) [private]

DetSetVector requires that T objects can be compared with operator<.

template<class T >
bool edm::DetSetLazyVector< T >::empty ( ) const [inline]

Return true if we contain no DetSets.

Definition at line 187 of file DetSetLazyVector.h.

  {
    return sets_.empty();
  }
template<class T >
DetSetLazyVector< T >::const_iterator edm::DetSetLazyVector< T >::end ( void  ) const [inline]

Return the off-the-end iterator.

Definition at line 248 of file DetSetLazyVector.h.

  {
    dslv::LazyAdapter<T> adapter(getter_);
    return boost::make_transform_iterator(sets_.end(),adapter);
  }
template<class T >
DetSetLazyVector< T >::const_iterator edm::DetSetLazyVector< T >::find ( det_id_type  id) const [inline]

Return an iterator to the DetSet with the given id, or end() if there is no such DetSet.

Definition at line 203 of file DetSetLazyVector.h.

References relativeConstraints::empty, and L1TEmulatorMonitor_cff::p.

  {
    if(empty()) {
      dslv::LazyAdapter<T> adapter(getter_);
      return boost::make_transform_iterator(sets_.end(),adapter);
    }
    //NOTE: using collection_type::const_iterator and NOT const_iterator. We do this to avoid calling the
    // dereferencing operation on const_iterator which would cause the 'lazy update' to happen
    std::pair<typename collection_type::const_iterator,typename collection_type::const_iterator> p = 
    std::equal_range(sets_.begin(), sets_.end(), id);
    if (p.first == p.second) {
      dslv::LazyAdapter<T> adapter(getter_);
      return boost::make_transform_iterator(sets_.end(),adapter);
    }
    // The range indicated by [p.first, p.second) should be exactly of
    // length 1.
    assert(std::distance(p.first, p.second) == 1);
    dslv::LazyAdapter<T> adapter(getter_);
    return boost::make_transform_iterator(p.first,adapter);
  }
template<class T >
DetSetLazyVector< T >::const_reference edm::DetSetLazyVector< T >::operator[] ( det_id_type  i) const [inline]

Return a reference to the DetSet with the given detector ID. If there is no such DetSet, we throw an edm::Exception. DO NOT MODIFY THE id DATA MEMBER OF THE REFERENCED DetSet!**

Definition at line 227 of file DetSetLazyVector.h.

References edm::dslvdetail::_throw_range(), end, and spr::find().

  {
    // Find the right DetSet, and return a reference to it.  Throw if
    // there is none.
    const_iterator it = this->find(i);
    if (it == this->end()) dslvdetail::_throw_range(i);
    return *it;
  }
template<class T >
DetSetLazyVector< T >::size_type edm::DetSetLazyVector< T >::size ( void  ) const [inline]

Return the number of contained DetSets.

Definition at line 195 of file DetSetLazyVector.h.

  {
    return sets_.size();
  }
template<class T>
void edm::DetSetLazyVector< T >::swap ( DetSetLazyVector< T > &  other)

Referenced by edm::swap().


Member Data Documentation

template<class T>
boost::shared_ptr<dslv::LazyGetter<T> > edm::DetSetLazyVector< T >::getter_ [private]

Definition at line 172 of file DetSetLazyVector.h.

template<class T>
collection_type edm::DetSetLazyVector< T >::sets_ [private]

This function will be called by the edm::Event after the DetSetVector has been inserted into the Event.

Definition at line 171 of file DetSetLazyVector.h.

Referenced by edm::DetSetLazyVector< T >::DetSetLazyVector().