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;
156 const value_type& __y)
const 157 {
return keyLess(__x.first, __y.first); }
159 const key_type& __y)
const 160 {
return keyLess(__x.first, __y); }
162 const value_type& __y)
const 163 {
return keyLess(__x, __y.first); }
166 const key_type& __y)
const 167 {
return comp(__x, __y); }
185 return sortedVectorMap.get_allocator();
190 return sortedVectorMap.begin();
195 return sortedVectorMap.begin();
200 return sortedVectorMap.end();
203 const_iterator
end()
const 205 return sortedVectorMap.end();
210 return sortedVectorMap.rbegin();
215 return sortedVectorMap.rbegin();
220 return sortedVectorMap.rend();
223 const_reverse_iterator
rend()
const 225 return sortedVectorMap.rend();
230 return sortedVectorMap.empty();
235 return sortedVectorMap.size();
240 return sortedVectorMap.max_size();
266 throw std::out_of_range(
"Utilities/VectorMap::operator[]");
267 return (*__i).second;
272 mapped_type&
at(
const key_type& __k)
276 throw std::out_of_range(
"Utilities/VectorMap::at");
277 return (*__i).second;
280 const mapped_type&
at(
const key_type& __k)
const 284 throw std::out_of_range(
"Utilities/VectorMap::at");
285 return (*__i).second;
297 std::pair<iterator,bool>
insert(
const value_type& entry)
299 const key_type& key = entry.first;
306 i = sortedVectorMap.insert(i, entry);
307 return std::make_pair( i,
true);
311 return std::make_pair( i,
false );
318 iterator
insert(iterator,
const value_type& entry)
320 std::pair<iterator,bool> result =
insert(entry);
325 template <
typename _InputIterator>
326 void insert(_InputIterator __first, _InputIterator __last)
328 for ( ; __first != __last; ++__first)
334 sortedVectorMap.erase(__position);
339 size_type
erase(
const key_type& key)
341 iterator i =
find(key);
342 if ( i ==
end() )
return 0;
348 void erase(iterator __first, iterator __last)
350 sortedVectorMap.erase(__first, __last);
367 sortedVectorMap.clear();
373 return valueCompare.GetCompare();
383 iterator
find(
const key_type& key)
392 const_iterator
find(
const key_type& key)
const 403 size_type
count(
const key_type& __x)
const 405 return find(__x) ==
end() ? 0 : 1;
410 return std::lower_bound(
begin(),
end(),__x,valueCompare);
415 return std::lower_bound(
begin(),
end(),__x,valueCompare);
420 return std::upper_bound(
begin(),
end(),__x,valueCompare);
425 return std::upper_bound(
begin(),
end(),__x,valueCompare);
430 return std::equal_range(
begin(),
end(),key,valueCompare);
450 return sortedVectorMap[index].second;
453 const mapped_type&
Data(
const size_type& index)
const 455 return sortedVectorMap[index].second;
458 const key_type&
Key(
const size_type& index)
const 460 return sortedVectorMap[index].first;
467 sortedVectorMap.reserve(i);
471 return sortedVectorMap.capacity();
476 template <
typename _K1,
typename _T1,
typename _C1>
480 template <
typename _K1,
typename _T1,
typename _C1>
481 friend bool operator< (const VectorMap<_K1, _T1, _C1>&,
493 template <
typename _Key,
typename _Tp,
typename _Compare>
500 template <
typename _Key,
typename _Tp,
typename _Compare>
501 inline bool operator<(const VectorMap<_Key, _Tp, _Compare>& __x,
504 return std::lexicographical_compare(__x.sortedVectorMap.begin(),
505 __x.sortedVectorMap.end(),
506 __y.sortedVectorMap.begin(),
507 __y.sortedVectorMap.end(),
512 template <
typename _Key,
typename _Tp,
typename _Compare>
516 return !(__x == __y);
520 template <
typename _Key,
typename _Tp,
typename _Compare>
528 template <
typename _Key,
typename _Tp,
typename _Compare>
529 inline bool operator<=(const VectorMap<_Key, _Tp, _Compare>& __x,
536 template <
typename _Key,
typename _Tp,
typename _Compare>
544 template <
typename _Key,
typename _Tp,
typename _Compare>
553 #endif // Utilities_VectorMap_H std::pair< iterator, iterator > equal_range(const key_type &key)
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
std::pair< iterator, bool > insert(const value_type &entry)
void erase(iterator __position)
vector_type sortedVectorMap
const mapped_type & operator[](const key_type &__k) const
std::allocator< std::pair< _Key, _Tp > > allocator_type
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
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