87 #ifndef Utilities_VectorMap_H 88 #define Utilities_VectorMap_H 103 template <
typename _Key,
typename _Tp,
typename _Compare = std::less<_Key>>
116 typedef typename vector_type::pointer
pointer;
151 bool operator()(
const value_type& __x,
const value_type& __y)
const 153 return keyLess(__x.first, __y.first);
155 bool operator()(
const value_type& __x,
const key_type& __y)
const 157 return keyLess(__x.first, __y);
159 bool operator()(
const key_type& __x,
const value_type& __y)
const 161 return keyLess(__x, __y.first);
165 bool keyLess(
const key_type& __x,
const key_type& __y)
const {
return comp(__x, __y); }
181 allocator_type
get_allocator()
const {
return sortedVectorMap.get_allocator(); }
183 iterator
begin() {
return sortedVectorMap.begin(); }
185 const_iterator
begin()
const {
return sortedVectorMap.begin(); }
187 iterator
end() {
return sortedVectorMap.end(); }
189 const_iterator
end()
const {
return sortedVectorMap.end(); }
191 reverse_iterator
rbegin() {
return sortedVectorMap.rbegin(); }
193 const_reverse_iterator
rbegin()
const {
return sortedVectorMap.rbegin(); }
195 reverse_iterator
rend() {
return sortedVectorMap.rend(); }
197 const_reverse_iterator
rend()
const {
return sortedVectorMap.rend(); }
199 bool empty()
const {
return sortedVectorMap.empty(); }
201 size_t size()
const {
return sortedVectorMap.size(); }
203 size_t max_size()
const {
return sortedVectorMap.max_size(); }
228 throw std::out_of_range(
"Utilities/VectorMap::operator[]");
229 return (*__i).second;
234 mapped_type&
at(
const key_type& __k)
238 throw std::out_of_range(
"Utilities/VectorMap::at");
239 return (*__i).second;
242 const mapped_type&
at(
const key_type& __k)
const 246 throw std::out_of_range(
"Utilities/VectorMap::at");
247 return (*__i).second;
259 std::pair<iterator, bool>
insert(
const value_type& entry)
261 const key_type& key = entry.first;
267 i = sortedVectorMap.insert(i, entry);
268 return std::make_pair(i,
true);
272 return std::make_pair(i,
false);
279 iterator
insert(iterator,
const value_type& entry)
281 std::pair<iterator, bool> result =
insert(entry);
286 template <
typename _InputIterator>
287 void insert(_InputIterator __first, _InputIterator __last)
289 for (; __first != __last; ++__first)
293 void erase(iterator __position) { sortedVectorMap.erase(__position); }
297 size_type
erase(
const key_type& key)
299 iterator i =
find(key);
300 if (i ==
end())
return 0;
306 void erase(iterator __first, iterator __last) { sortedVectorMap.erase(__first, __last); }
320 void clear() { sortedVectorMap.clear(); }
323 key_compare
key_comp()
const {
return valueCompare.GetCompare(); }
329 iterator
find(
const key_type& key)
337 const_iterator
find(
const key_type& key)
const 347 size_type
count(
const key_type& __x)
const {
return find(__x) ==
end() ? 0 : 1; }
351 return std::lower_bound(
begin(),
end(), __x, valueCompare);
356 return std::lower_bound(
begin(),
end(), __x, valueCompare);
361 return std::upper_bound(
begin(),
end(), __x, valueCompare);
366 return std::upper_bound(
begin(),
end(), __x, valueCompare);
371 return std::equal_range(
begin(),
end(), key, valueCompare);
391 return sortedVectorMap[index].second;
394 const mapped_type&
Data(
const size_type& index)
const {
return sortedVectorMap[index].second; }
396 const key_type&
Key(
const size_type& index)
const {
return sortedVectorMap[index].first; }
399 void reserve(size_type i) { sortedVectorMap.reserve(i); }
400 size_type
capacity() {
return sortedVectorMap.capacity(); }
403 template <
typename _K1,
typename _T1,
typename _C1>
406 template <
typename _K1,
typename _T1,
typename _C1>
417 template <
typename _Key,
typename _Tp,
typename _Compare>
424 template <
typename _Key,
typename _Tp,
typename _Compare>
425 inline bool operator<(const VectorMap<_Key, _Tp, _Compare>& __x,
428 return std::lexicographical_compare(__x.sortedVectorMap.begin(),
429 __x.sortedVectorMap.end(),
430 __y.sortedVectorMap.begin(),
431 __y.sortedVectorMap.end(),
436 template <
typename _Key,
typename _Tp,
typename _Compare>
440 return !(__x == __y);
444 template <
typename _Key,
typename _Tp,
typename _Compare>
452 template <
typename _Key,
typename _Tp,
typename _Compare>
453 inline bool operator<=(const VectorMap<_Key, _Tp, _Compare>& __x,
460 template <
typename _Key,
typename _Tp,
typename _Compare>
468 template <
typename _Key,
typename _Tp,
typename _Compare>
476 #endif // Utilities_VectorMap_H std::pair< iterator, iterator > equal_range(const key_type &key)
std::allocator< std::pair< _Key, _Tp > > allocator_type
const_reverse_iterator rend() const
void reserve(size_type i)
Namespace for general, non-LArSoft-specific utilities.
value_compare value_comp() const
const mapped_type & operator()(const size_type &index) const
_Compare GetCompare() const
void erase(iterator __first, iterator __last)
reverse_iterator rbegin()
const_iterator upper_bound(const key_type &__x) const
const_reverse_iterator rbegin() const
value_compare valueCompare
const_iterator begin() const
mapped_type & at(const key_type &__k)
const mapped_type & Data(const size_type &index) const
void insert(_InputIterator __first, _InputIterator __last)
bool operator()(const value_type &__x, const value_type &__y) const
vector_type::iterator iterator
void erase(iterator __position)
vector_type sortedVectorMap
const mapped_type & operator[](const key_type &__k) const
const mapped_type & at(const key_type &__k) const
vector_type::const_iterator const_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
bool operator()(const key_type &__x, const value_type &__y) const
iterator insert(iterator, const value_type &entry)
vector_type::const_pointer const_pointer
allocator_type get_allocator() const
Don't write this to the ROOT file.
const key_type & Key(const size_type &index) const
std::reverse_iterator< iterator > reverse_iterator
std::pair< iterator, bool > insert(const value_type &entry)
const_iterator find(const key_type &key) const
iterator find(const key_type &key)
iterator lower_bound(const key_type &__x)
vector_type::reference reference
key_compare key_comp() const
mapped_type & operator[](const key_type &key)
ptrdiff_t difference_type
size_type erase(const key_type &key)
value_compare(_Compare __c=_Compare())
size_type count(const key_type &__x) const
bool operator()(const value_type &__x, const key_type &__y) const
void swap(VectorMap &other)
friend bool operator==(const VectorMap< _K1, _T1, _C1 > &, const VectorMap< _K1, _T1, _C1 > &)
iterator upper_bound(const key_type &__x)
vector_type::const_reference const_reference
bool operator>(const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y)
Based on operator<.
std::vector< value_type > vector_type
vector_type::pointer pointer
bool operator!=(TensorIndices< RANK1 > const &a, TensorIndices< RANK2 > const &b)
Comparison operator with tensors of different rank.
std::pair< _Key, _Tp > value_type
const_iterator lower_bound(const key_type &__x) const
const_iterator end() const
bool operator>=(const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y)
Based on operator<.
bool keyLess(const key_type &__x, const key_type &__y) const