1 #ifndef DataFormats_Common_ValueMap_h 2 #define DataFormats_Common_ValueMap_h 21 template<
typename Map>
26 typedef std::map<ProductID, value_vector>
value_map;
35 if (map.empty())
return;
36 typename id_offset_vector::const_iterator j = map.ids_.begin();
37 const typename id_offset_vector::const_iterator
end = map.ids_.end();
39 const size_t size = map.values_.size();
44 size_t max = (j == end ? size : j->second);
45 typename value_map::iterator
f =
values_.find(
id);
49 values.push_back( map.values_[i++] );
52 template<
typename H,
typename I>
55 size_t size = h->size(), sizeIt = end -
begin;
57 typename value_map::const_iterator
f =
values_.find(
id);
68 for(
typename value_map::const_iterator
i =
values_.begin();
i !=
values_.end(); ++
i) {
70 map_.ids_.push_back(std::make_pair(
id, off));
71 const value_vector &
values =
i->second;
72 for(
typename value_vector::const_iterator j = values.begin(); j != values.end(); ++j) {
73 map_.values_.push_back( *j );
89 "ValueMap::Filler: handle and reference " 90 "collections should the same size\n");
94 e <<
"index map has already been filled for id: " <<
id <<
"\n";
99 "ValueMap: trying to add entries for an already existing product\n");
118 ids_.swap(other.
ids_);
127 template<
typename RefKey>
129 return get(r.id(), r.key());
133 typename id_offset_vector::const_iterator
f = getIdOffset(
id);
134 if(f==ids_.end()) throwNotExisting();
135 offset off = f->second;
137 if(j >=
values_.size()) throwIndexBound();
143 template<
typename RefKey>
145 return get(r.id(), r.key());
156 return getIdOffset(
id) != ids_.end();
159 size_t idSize()
const {
return ids_.size(); }
163 ids_.shrink_to_fit();
175 typename container::const_iterator
begin()
const {
176 return values_->begin() + i_->second;
178 typename container::const_iterator
end()
const {
179 if(i_ == end_)
return values_->end();
180 id_offset_vector::const_iterator
end = i_; ++
end;
181 if(end == end_)
return values_->end();
182 return values_->begin() + end->second;
200 const id_offset_vector::const_iterator &
end,
201 const container *
values) :
202 values_(values), i_(i_), end_(end) { }
204 id_offset_vector::const_iterator
i_, end_;
208 const_iterator
begin()
const {
return const_iterator(ids_.begin(), ids_.end(), &
values_); }
209 const_iterator
end()
const {
return const_iterator(ids_.end(), ids_.end(), &
values_); }
212 const id_offset_vector &
ids()
const {
return ids_; }
221 id_offset_vector ids_;
223 typename id_offset_vector::const_iterator getIdOffset(
ProductID id)
const {
224 typename id_offset_vector::const_iterator
i =
std::lower_bound(ids_.begin(), ids_.end(),
id, IDComparator());
225 if(i==ids_.end())
return i;
226 return i->first ==
id ? i : ids_.end();
261 template <
typename T>
bool operator<(const const_iterator &o) const
const_iterator end() const
id_offset_vector::const_iterator i_
const_iterator(const id_offset_vector::const_iterator &i_, const id_offset_vector::const_iterator &end, const container *values)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Association< C > operator+(const Association< C > &a1, const Association< C > &a2)
ValueMap< T > & operator+=(const ValueMap< T > &o)
const id_offset_vector & ids() const
meant to be used in AssociativeIterator, not by the ordinary user
void swap(ValueMap &other)
void insert(const H &h, I begin, I end)
Basic3DVector & operator-=(const Basic3DVector< U > &p)
difference_type operator-(const const_iterator &o) const
const_iterator operator-(difference_type n) const
#define CMS_CLASS_VERSION(_version_)
bool operator()(const std::pair< ProductID, offset > &p, const ProductID &id)
const_iterator & operator++()
ptrdiff_t difference_type
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
size_t rawIndexOf(ProductID id, size_t idx) const
void throwIndexBound() const
container::reference reference_type
bool contains(ProductID id) const
void throwFillSize() const
void swap(IndexRangeAssociation &lhs, IndexRangeAssociation &rhs)
const_iterator operator--(int)
container::const_reference const_reference_type
std::vector< std::pair< ProductID, offset > > id_offset_vector
const_iterator operator+(difference_type n) const
const_iterator & operator--()
bool operator!=(const const_iterator &ci) const
void add(const ValueMap< T > &o)
void throwNotExisting() const
const std::complex< double > I
helper::Filler< ValueMap< T > > Filler
const_iterator operator++(int)
std::map< ProductID, value_vector > value_map
const_iterator begin() const
std::vector< typename Map::value_type > value_vector
container::const_iterator begin() const
reference_type operator[](const RefKey &r)
ValueMap & operator=(ValueMap const &rhs)
std::vector< size_t > index_vector
bool operator==(const const_iterator &ci) const
std::vector< value_type > container
const_reference_type operator[](const RefKey &r) const
Map::id_offset_vector id_offset_vector
void throwFillID(ProductID id) const
const container * values_
container::const_iterator end() const
const T & operator[](size_t i)
Basic3DVector & operator+=(const Basic3DVector< U > &p)
EventID const & max(EventID const &lh, EventID const &rh)