CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
edm::RangeMap< ID, C, P > Class Template Reference

#include <RangeMap.h>

Classes

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

Public Types

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

Public Member Functions

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

Static Public Member Functions

static short Class_Version ()
 

Private Attributes

collection_
 stored collection More...
 
mapType map_
 identifier map More...
 

Detailed Description

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

Definition at line 32 of file RangeMap.h.

Member Typedef Documentation

◆ const_iterator

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 43 of file RangeMap.h.

◆ mapType

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 48 of file RangeMap.h.

◆ pairType

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 46 of file RangeMap.h.

◆ pointer

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 41 of file RangeMap.h.

◆ range

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 50 of file RangeMap.h.

◆ reference

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 39 of file RangeMap.h.

◆ size_type

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 37 of file RangeMap.h.

◆ value_type

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 35 of file RangeMap.h.

Constructor & Destructor Documentation

◆ RangeMap()

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

default constructor

Definition at line 66 of file RangeMap.h.

66 {}

Member Function Documentation

◆ begin()

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

first collection iterator

Definition at line 126 of file RangeMap.h.

Referenced by edm::RangeMap< det_id_type, edm::OwnVector< B > >::get(), and edm::RangeMap< det_id_type, edm::OwnVector< B > >::put().

126 { return collection_.begin(); }
C collection_
stored collection
Definition: RangeMap.h:202

◆ Class_Version()

template<typename ID, typename C, typename P = typename clonehelper::CloneTrait<C>::type>
static short edm::RangeMap< ID, C, P >::Class_Version ( )
inlinestatic

Definition at line 198 of file RangeMap.h.

200 :

◆ end()

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

◆ get() [1/3]

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 75 of file RangeMap.h.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), submitPVValidationJobs.BetterConfigParser::__updateDict(), rrapi.RRApi::columns(), util.rrapi.RRApi::columns(), rrapi.RRApi::count(), util.rrapi.RRApi::count(), rrapi.RRApi::data(), util.rrapi.RRApi::data(), MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::fillTable(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), submitPVValidationJobs.BetterConfigParser::getResultingSection(), util.rrapi.RRApi::report(), rrapi.RRApi::report(), util.rrapi.RRApi::reports(), rrapi.RRApi::reports(), rrapi.RRApi::tables(), util.rrapi.RRApi::tables(), util.rrapi.RRApi::tags(), rrapi.RRApi::tags(), rrapi.RRApi::templates(), util.rrapi.RRApi::templates(), rrapi.RRApi::workspaces(), and util.rrapi.RRApi::workspaces().

75  {
76  std::pair<typename mapType::const_iterator, typename mapType::const_iterator> r =
77  std::equal_range(map_.begin(), map_.end(), id, comp<CMP>(comparator));
79  if ((r.first) == map_.end()) {
80  begin = end = collection_.end();
81  return std::make_pair(begin, end);
82  } else {
83  begin = collection_.begin() + (r.first)->second.first;
84  }
85  if ((r.second) == map_.end()) {
86  end = collection_.end();
87  } else {
88  end = collection_.begin() + (r.second)->second.first;
89  }
90  return std::make_pair(begin, end);
91  }
C collection_
stored collection
Definition: RangeMap.h:202
mapType map_
identifier map
Definition: RangeMap.h:204
C::const_iterator begin() const
first collection iterator
Definition: RangeMap.h:126
U second(std::pair< T, U > const &p)
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
C::const_iterator end() const
last collection iterator
Definition: RangeMap.h:128

◆ get() [2/3]

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() [3/3]

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 98 of file RangeMap.h.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), submitPVValidationJobs.BetterConfigParser::__updateDict(), util.rrapi.RRApi::columns(), rrapi.RRApi::columns(), rrapi.RRApi::count(), util.rrapi.RRApi::count(), rrapi.RRApi::data(), util.rrapi.RRApi::data(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), submitPVValidationJobs.BetterConfigParser::getResultingSection(), util.rrapi.RRApi::report(), rrapi.RRApi::report(), rrapi.RRApi::reports(), util.rrapi.RRApi::reports(), rrapi.RRApi::tables(), util.rrapi.RRApi::tables(), util.rrapi.RRApi::tags(), rrapi.RRApi::tags(), rrapi.RRApi::templates(), util.rrapi.RRApi::templates(), util.rrapi.RRApi::workspaces(), and rrapi.RRApi::workspaces().

98  {
100  typename mapType::const_iterator i = map_.find(id);
101  if (i != map_.end()) {
102  begin = collection_.begin() + i->second.first;
103  end = collection_.begin() + i->second.second;
104  } else {
105  begin = end = collection_.end();
106  }
107  return std::make_pair(begin, end);
108  }
C collection_
stored collection
Definition: RangeMap.h:202
mapType map_
identifier map
Definition: RangeMap.h:204
C::const_iterator begin() const
first collection iterator
Definition: RangeMap.h:126
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
C::const_iterator end() const
last collection iterator
Definition: RangeMap.h:128

◆ id_begin()

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 180 of file RangeMap.h.

Referenced by MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::fillTable(), and edm::RangeMap< det_id_type, edm::OwnVector< B > >::ids().

180 { return id_iterator(map_.begin()); }
mapType map_
identifier map
Definition: RangeMap.h:204

◆ id_end()

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 182 of file RangeMap.h.

Referenced by MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::fillTable(), and edm::RangeMap< det_id_type, edm::OwnVector< B > >::ids().

182 { return id_iterator(map_.end()); }
mapType map_
identifier map
Definition: RangeMap.h:204

◆ id_size()

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 184 of file RangeMap.h.

Referenced by edm::RangeMap< det_id_type, edm::OwnVector< B > >::ids().

184 { return map_.size(); }
mapType map_
identifier map
Definition: RangeMap.h:204

◆ ids()

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 186 of file RangeMap.h.

186  {
187  std::vector<ID> temp(id_size());
188  std::copy(id_begin(), id_end(), temp.begin());
189  return temp;
190  }
size_t id_size() const
number of contained identifiers
Definition: RangeMap.h:184
id_iterator id_end() const
last identifier iterator
Definition: RangeMap.h:182
id_iterator id_begin() const
first identifier iterator
Definition: RangeMap.h:180

◆ operator[]()

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 192 of file RangeMap.h.

192 { return collection_[i]; }
C collection_
stored collection
Definition: RangeMap.h:202

◆ post_insert()

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 165 of file RangeMap.h.

165  {
166  // sorts the container via ID
167  C tmp;
168  for (typename mapType::iterator it = map_.begin(), itEnd = map_.end(); it != itEnd; it++) {
169  range r = get((*it).first);
170  //do cast to acknowledge that we may be going from a larger type to a smaller type but we are OK
171  unsigned int begIt = static_cast<unsigned int>(tmp.size());
172  for (const_iterator i = r.first; i != r.second; ++i)
173  tmp.push_back(P::clone(*i));
174  unsigned int endIt = static_cast<unsigned int>(tmp.size());
175  it->second = pairType(begIt, endIt);
176  }
177  collection_ = tmp;
178  }
C collection_
stored collection
Definition: RangeMap.h:202
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
mapType map_
identifier map
Definition: RangeMap.h:204
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
std::pair< unsigned int, unsigned int > pairType
index range
Definition: RangeMap.h:46
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
tmp
align.sh
Definition: createJobs.py:716

◆ put()

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 111 of file RangeMap.h.

Referenced by CSCMake2DRecHit::hitFromStripAndWire(), and edmNew::dstvdetails::ToRM< B >::operator()().

111  {
112  typename mapType::const_iterator i = map_.find(id);
113  if (i != map_.end()) {
114  throw Exception(errors::LogicError, "trying to insert duplicate entry");
115  }
116  assert(i == map_.end());
117  pairType& p = map_[id];
118  p.first = collection_.size();
119  for (CI ii = begin; ii != end; ++ii)
120  collection_.push_back(P::clone(*ii));
121  p.second = collection_.size();
122  }
C collection_
stored collection
Definition: RangeMap.h:202
mapType map_
identifier map
Definition: RangeMap.h:204
C::const_iterator begin() const
first collection iterator
Definition: RangeMap.h:126
assert(be >=bs)
std::pair< unsigned int, unsigned int > pairType
index range
Definition: RangeMap.h:46
ii
Definition: cuy.py:589
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
C::const_iterator end() const
last collection iterator
Definition: RangeMap.h:128

◆ size()

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 124 of file RangeMap.h.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), and CSCMake2DRecHit::hitFromStripAndWire().

124 { return collection_.size(); }
C collection_
stored collection
Definition: RangeMap.h:202

◆ swap()

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 208 of file RangeMap.h.

208  {
209  collection_.swap(other.collection_);
210  map_.swap(other.map_);
211  }
C collection_
stored collection
Definition: RangeMap.h:202
mapType map_
identifier map
Definition: RangeMap.h:204

Member Data Documentation

◆ collection_

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

◆ map_

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