CMS 3D CMS Logo

edm::RangeMap< ID, C, P > Class Template Reference

#include <DataFormats/Common/interface/RangeMap.h>

List of all members.

Public Types

typedef C::const_iterator const_iterator
 constant access iterator type
typedef std::map< ID, pairTypemapType
 map of identifier to index range
typedef std::pair< unsigned
int, unsigned int
pairType
 index range
typedef C::pointer pointer
 pointer type
typedef std::pair
< const_iterator,
const_iterator
range
 iterator range
typedef C::reference reference
 reference type
typedef C::size_type size_type
 collection size type
typedef C::value_type value_type
 contained object type

Public Member Functions

C::const_iterator begin () const
 first collection iterator
C::const_iterator end () const
 last collection iterator
range get (ID id) const
 get a range of objects with specified identifier
template<typename CMP>
range get (std::pair< ID, CMP > p) const
 get range of objects matching a specified identifier with a specified comparator.
template<typename CMP>
range get (ID id, CMP comparator) const
 get range of objects matching a specified identifier with a specified comparator.
id_iterator id_begin () const
 first identifier iterator
id_iterator id_end () const
 last identifier iterator
size_t id_size () const
 number of contained identifiers
std::vector< ID > ids () const
 indentifier vector
RangeMapoperator= (RangeMap const &rhs)
 copy assignment
reference operator[] (size_type i)
 direct access to an object in the collection
void post_insert ()
 perfor post insert action
template<typename CI>
void put (ID id, CI begin, CI end)
 insert an object range with specified identifier
 RangeMap ()
 default constructor
size_t size () const
 return number of contained object
void swap (RangeMap< ID, C, P > &other)
 swap member function

Private Attributes

collection_
 stored collection
mapType map_
 identifier map

Classes

struct  comp
 comparator helper class More...
struct  id_iterator
 identifier iterator More...


Detailed Description

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
class edm::RangeMap< ID, C, P >

Definition at line 34 of file RangeMap.h.


Member Typedef Documentation

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
typedef C::const_iterator edm::RangeMap< ID, C, P >::const_iterator

constant access iterator type

Definition at line 45 of file RangeMap.h.

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
typedef std::map<ID, pairType> edm::RangeMap< ID, C, P >::mapType

map of identifier to index range

Definition at line 50 of file RangeMap.h.

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
typedef std::pair<unsigned int, unsigned int> edm::RangeMap< ID, C, P >::pairType

index range

Definition at line 48 of file RangeMap.h.

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
typedef C::pointer edm::RangeMap< ID, C, P >::pointer

pointer type

Definition at line 43 of file RangeMap.h.

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
typedef std::pair<const_iterator, const_iterator> edm::RangeMap< ID, C, P >::range

iterator range

Definition at line 52 of file RangeMap.h.

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
typedef C::reference edm::RangeMap< ID, C, P >::reference

reference type

Definition at line 41 of file RangeMap.h.

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
typedef C::size_type edm::RangeMap< ID, C, P >::size_type

collection size type

Definition at line 39 of file RangeMap.h.

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
typedef C::value_type edm::RangeMap< ID, C, P >::value_type

contained object type

Definition at line 37 of file RangeMap.h.


Constructor & Destructor Documentation

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
edm::RangeMap< ID, C, P >::RangeMap (  )  [inline]

default constructor

Definition at line 72 of file RangeMap.h.

00072 { }


Member Function Documentation

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
C::const_iterator edm::RangeMap< ID, C, P >::begin (  )  const [inline]

first collection iterator

Definition at line 133 of file RangeMap.h.

Referenced by edm::RangeMap< DetId, edm::OwnVector< double_binary > >::get(), CalibrationTrackSelector::isIsolated(), AlignmentTrackSelector::isIsolated(), CRackTrajectoryBuilder::SortHits(), and CosmicTrajectoryBuilder::SortHits().

00133 { return collection_.begin(); }

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
C::const_iterator edm::RangeMap< ID, C, P >::end (  )  const [inline]

last collection iterator

Definition at line 135 of file RangeMap.h.

Referenced by edm::RangeMap< DetId, edm::OwnVector< double_binary > >::get(), CalibrationTrackSelector::isIsolated(), AlignmentTrackSelector::isIsolated(), CRackTrajectoryBuilder::SortHits(), and CosmicTrajectoryBuilder::SortHits().

00135 { return collection_.end(); }

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
range edm::RangeMap< ID, C, P >::get ( ID  id  )  const [inline]

get a range of objects with specified identifier

Definition at line 106 of file RangeMap.h.

00106                            {
00107       const_iterator begin, end;
00108       typename mapType::const_iterator i = map_.find(id);
00109       if (i != map_.end()) { 
00110         begin = collection_.begin() + i->second.first;
00111         end = collection_.begin() + i->second.second;
00112       } else {
00113         begin = end = collection_.end();
00114       }
00115       return std::make_pair(begin, end);
00116     }

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
template<typename CMP>
range edm::RangeMap< ID, C, P >::get ( std::pair< ID, CMP >  p  )  const [inline]

get range of objects matching a specified identifier with a specified comparator.

Definition at line 102 of file RangeMap.h.

00102                                         {
00103       return get(p.first, p.second); 
00104     }

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
template<typename CMP>
range edm::RangeMap< ID, C, P >::get ( ID  id,
CMP  comparator 
) const [inline]

get range of objects matching a specified identifier with a specified comparator.

WARNING: the comparator has to be written in such a way that the std::equal_range function returns a meaningful range. Not properly written comparators may return an unpredictable range. It is recommended to use only comparators provided with CMSSW release.

Definition at line 81 of file RangeMap.h.

Referenced by SiStripElectronAlgo::coarseHitSelection(), SiStripElectronAlgo::coarseMatchedHitSelection(), RoadSearchCloudMakerAlgorithm::FillPixRecHitsIntoCloud(), DetHitAccess::getHitVector(), CosmicLayerTriplets::init(), LaserLayerPairs::init(), SiStripRecHitConverterAlgorithm::match(), VisTrackerRechit2DTwig::onNewEvent(), VisTrackerRechit2DMatchedTwig::onNewEvent(), VisTrackerPiRechitTwig::onNewEvent(), ElectronGSPixelSeedGenerator::run(), CosmicLayerPairs::selectTECHit(), CosmicLayerPairs::selectTIBHit(), CosmicLayerPairs::selectTOBHit(), and VisCuTrackerRecHit::setEvent().

00081                                            {
00082       using namespace __gnu_cxx;
00083       std::pair<typename mapType::const_iterator,
00084         typename mapType::const_iterator> r =
00085         std::equal_range(map_.begin(), map_.end(), id, comp<CMP>(comparator));
00086       const_iterator begin, end;
00087       if ((r.first) == map_.end()){
00088         begin = end = collection_.end();
00089         return  std::make_pair(begin,end);
00090       } else {
00091         begin = collection_.begin() + (r.first)->second.first;
00092       }
00093       if ((r.second) == map_.end()){
00094         end = collection_.end();
00095       }else{
00096         end = collection_.begin() + (r.second)->second.first;
00097       }
00098       return  std::make_pair(begin,end);
00099     }

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
id_iterator edm::RangeMap< ID, C, P >::id_begin (  )  const [inline]

first identifier iterator

Definition at line 173 of file RangeMap.h.

Referenced by edm::RangeMap< DetId, edm::OwnVector< double_binary > >::ids(), VisTrackerRechit2DTwig::onNewEvent(), VisTrackerRechit2DMatchedTwig::onNewEvent(), and VisTrackerPiRechitTwig::onNewEvent().

00173 { return id_iterator(map_.begin()); }

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
id_iterator edm::RangeMap< ID, C, P >::id_end (  )  const [inline]

last identifier iterator

Definition at line 175 of file RangeMap.h.

Referenced by edm::RangeMap< DetId, edm::OwnVector< double_binary > >::ids(), VisTrackerRechit2DTwig::onNewEvent(), VisTrackerRechit2DMatchedTwig::onNewEvent(), and VisTrackerPiRechitTwig::onNewEvent().

00175 { return id_iterator(map_.end()); }

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
size_t edm::RangeMap< ID, C, P >::id_size (  )  const [inline]

number of contained identifiers

Definition at line 177 of file RangeMap.h.

Referenced by edm::RangeMap< DetId, edm::OwnVector< double_binary > >::ids().

00177 { return map_.size(); }

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
std::vector<ID> edm::RangeMap< ID, C, P >::ids (  )  const [inline]

indentifier vector

Definition at line 179 of file RangeMap.h.

Referenced by SiStripElectronAlgo::coarseHitSelection(), SiStripElectronAlgo::coarseMatchedHitSelection(), SiStripRecHitConverterAlgorithm::match(), RoadSearchCloudMakerAlgorithm::run(), ElectronGSPixelSeedGenerator::run(), and VisCuTrackerRecHit::setEvent().

00179                               {
00180       std::vector<ID> temp(id_size());
00181       std::copy(id_begin(), id_end(), temp.begin());
00182       return temp;
00183     }

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
RangeMap& edm::RangeMap< ID, C, P >::operator= ( RangeMap< ID, C, P > const &  rhs  ) 

copy assignment

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
reference edm::RangeMap< ID, C, P >::operator[] ( size_type  i  )  [inline]

direct access to an object in the collection

Definition at line 185 of file RangeMap.h.

00185 { return collection_[ i ]; }

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
void edm::RangeMap< ID, C, P >::post_insert (  )  [inline]

perfor post insert action

Definition at line 158 of file RangeMap.h.

00158                        {
00159       // sorts the container via ID
00160       C tmp;
00161       for (typename mapType::iterator it = map_.begin(), itEnd = map_.end(); it != itEnd; it ++) {   
00162         range r = get((*it).first);
00163         //do cast to acknowledge that we may be going from a larger type to a smaller type but we are OK
00164         unsigned int begIt = static_cast<unsigned int>(tmp.size());
00165         for(const_iterator i = r.first; i != r.second; ++i)
00166           tmp.push_back(P::clone(*i));
00167         unsigned int endIt = static_cast<unsigned int>(tmp.size());
00168         it->second = pairType(begIt, endIt);
00169       }
00170       collection_ = tmp;
00171     }

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
template<typename CI>
void edm::RangeMap< ID, C, P >::put ( ID  id,
CI  begin,
CI  end 
) [inline]

insert an object range with specified identifier

Definition at line 119 of file RangeMap.h.

Referenced by CSCMake2DRecHit::hitFromStripAndWire(), SiTrackerGaussianSmearingRecHitConverter::loadClusters(), SiTrackerGaussianSmearingRecHitConverter::loadMatchedRecHits(), TrackingRecHitTranslator::loadRecHits(), SiTrackerGaussianSmearingRecHitConverter::loadRecHits(), SiStripRecHitConverterAlgorithm::match(), and SiStripRecHitConverterAlgorithm::run().

00119                                       {
00120       typename mapType::const_iterator i = map_.find(id);
00121       if(i != map_.end()) 
00122         throw cms::Exception("Error") << "trying to insert duplicate entry";
00123       assert(i == map_.end());
00124       pairType & p = map_[ id ];
00125       p.first = collection_.size();
00126       for(CI i = begin; i != end; ++i)
00127         collection_.push_back(P::clone(*i));
00128       p.second = collection_.size();
00129     }

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
size_t edm::RangeMap< ID, C, P >::size ( void   )  const [inline]

return number of contained object

Definition at line 131 of file RangeMap.h.

Referenced by CSCOfflineMonitor::analyze(), CSCValidation::doRecHits(), CSCValidation::findNonAssociatedRecHits(), VisTrackerRechit2DTwig::onNewEvent(), VisTrackerRechit2DMatchedTwig::onNewEvent(), ElectronGSPixelSeedGenerator::run(), and VisCuTrackerRecHit::setEvent().

00131 { return collection_.size(); }

template<typename ID, typename C, typename P>
void edm::RangeMap< ID, C, P >::swap ( RangeMap< ID, C, P > &  other  )  [inline]

swap member function

Definition at line 203 of file RangeMap.h.

References edm::RangeMap< ID, C, P >::collection_, and edm::RangeMap< ID, C, P >::map_.

Referenced by edm::swap().

00203                                                      {
00204     collection_.swap(other.collection_);
00205     map_.swap(other.map_);
00206   }


Member Data Documentation

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
C edm::RangeMap< ID, C, P >::collection_ [private]

stored collection

Definition at line 195 of file RangeMap.h.

Referenced by edm::RangeMap< DetId, edm::OwnVector< double_binary > >::begin(), edm::RangeMap< DetId, edm::OwnVector< double_binary > >::end(), edm::RangeMap< DetId, edm::OwnVector< double_binary > >::get(), edm::RangeMap< DetId, edm::OwnVector< double_binary > >::operator[](), edm::RangeMap< DetId, edm::OwnVector< double_binary > >::post_insert(), edm::RangeMap< DetId, edm::OwnVector< double_binary > >::put(), edm::RangeMap< DetId, edm::OwnVector< double_binary > >::size(), and edm::RangeMap< ID, C, P >::swap().

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
mapType edm::RangeMap< ID, C, P >::map_ [private]

identifier map

Definition at line 197 of file RangeMap.h.

Referenced by edm::RangeMap< DetId, edm::OwnVector< double_binary > >::get(), edm::RangeMap< DetId, edm::OwnVector< double_binary > >::id_begin(), edm::RangeMap< DetId, edm::OwnVector< double_binary > >::id_end(), edm::RangeMap< DetId, edm::OwnVector< double_binary > >::id_size(), edm::RangeMap< DetId, edm::OwnVector< double_binary > >::post_insert(), edm::RangeMap< DetId, edm::OwnVector< double_binary > >::put(), and edm::RangeMap< ID, C, P >::swap().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:43:24 2009 for CMSSW by  doxygen 1.5.4