1 #ifndef GAUDIKERNEL_MAP_H
2 #define GAUDIKERNEL_MAP_H 1
12 #include "GaudiKernel/MapBase.h"
81 template <
typename K,
typename T,
typename M = std::map<K,T> >
97 typedef typename map_type::size_type
size_type;
99 typedef typename map_type::iterator
iterator;
116 Map(
const map_type& other): m_map(other) {}
121 template <
typename In>
122 Map(In&& first, In&& last): m_map(
std::forward<In>(first),
std::forward<In>(last)) {}
125 virtual ~Map() =
default;
131 inline iterator
begin() {
return m_map.begin(); }
132 inline iterator
end() {
return m_map.end(); }
134 inline const_iterator
begin()
const {
return m_map.begin(); }
135 inline const_iterator
end()
const {
return m_map.end(); }
145 inline mapped_type &
operator[] (
const key_type &key) {
return m_map[key]; }
149 inline iterator
find(
const key_type &key) {
return m_map.find(key); }
150 inline const_iterator
find(
const key_type &key)
const {
return m_map.find(key); }
152 inline size_type
count(
const key_type &key)
const {
return m_map.count(key); }
154 inline iterator
lower_bound(
const key_type &key) {
return m_map.lower_bound(key); }
155 inline const_iterator
lower_bound(
const key_type &key)
const {
return m_map.lower_bound(key); }
156 inline iterator
upper_bound(
const key_type &key) {
return m_map.upper_bound(key); }
157 inline const_iterator
upper_bound(
const key_type &key)
const {
return m_map.upper_bound(key); }
159 inline std::pair<iterator,iterator>
equal_range(
const key_type &key)
160 {
return m_map.equal_range(key); }
161 inline std::pair<const_iterator,const_iterator>
equal_range(
const key_type &key)
const
162 {
return m_map.equal_range(key); }
165 template<
class... Args >
166 std::pair<iterator,bool>
emplace( Args&&...
args ) {
return m_map.emplace(std::forward<Args>(
args)...); }
167 template <
typename ValueType>
168 inline std::pair<iterator,bool>
insert(ValueType&& val) {
return m_map.insert(std::forward<ValueType>(val)); }
169 inline std::pair<iterator,bool>
insert(value_type&& val) {
return m_map.insert(std::forward<value_type>(val)); }
170 template <
typename In>
171 inline void insert(In&& first, In&& last) { m_map.insert(std::forward<In>(first),std::forward<In>(last)); }
172 template <
typename ValueType>
173 inline iterator
insert( iterator , ValueType && val)
174 {
return m_map.insert( std::forward<ValueType>(val) ).first ; }
175 inline iterator
erase(const_iterator pos) {
return m_map.erase(pos); }
176 inline size_type
erase(
const key_type &key) {
return m_map.erase(key); }
177 inline iterator
erase(const_iterator first, const_iterator last) {
return m_map.erase(first,last); }
178 inline void clear() { m_map.clear(); }
182 inline size_type
size()
const {
return m_map.size(); }
183 inline size_type
max_size()
const {
return m_map.max_size(); }
184 inline bool empty()
const {
return size() == 0; }
185 inline void swap(map_type& other) { m_map.swap(other); }
211 inline const result_type &
operator() (
const argument_type &key )
const
214 auto it = m_map.find(key);
241 inline const mapped_type &
operator[] (
const key_type &key )
const
242 {
return (*
this)(key); }
249 inline const result_type &
at (
const argument_type &key )
const
251 return m_map.at(key);
255 inline Map&
merge (
const map_type& other )
267 template <
class K1,
class K2,
class K3>
268 inline Map&
merge (
const Map<K1,K2,K3>& other )
275 (
const key_type& key ,
276 const mapped_type& mapped ) { (*this)[ key ] = mapped ; }
281 inline operator map_type &() {
return m_map ; }
282 inline operator const map_type &()
const {
return m_map ; }
291 const key_type&
key_at (
const size_type index )
const
293 if ( index >=
size() )
295 return std::next ( this->
begin() , index )->first ;
302 const mapped_type&
value_at (
const size_type index )
const
304 if ( index >=
size() )
306 return std::next( this->
begin() , index )->second ;
311 template <
typename K,
typename T,
typename M>
320 #endif // GAUDIKERNEL_MAP_H
std::pair< iterator, bool > emplace(Args &&...args)
static const result_type s_null_value
auto begin(reverse_wrapper< T > &w)
size_type count(const key_type &key) const
const result_type & at(const argument_type &key) const
checked access to the map for missing keys
map_type::size_type size_type
void update(const key_type &key, const mapped_type &mapped)
std::pair< iterator, iterator > equal_range(const key_type &key)
mapped_type & operator[](const key_type &key)
iterator upper_bound(const key_type &key)
const result_type & operator()(const argument_type &key) const
Allow to use Map as an unary function.
auto end(reverse_wrapper< T > &w)
std::pair< const K, T > value_type
iterator lower_bound(const key_type &key)
iterator find(const key_type &key)
const mapped_type & value_at(const size_type index) const
useful method for python decoration:
virtual ~Map()=default
Virtual destructor. You can inherit from this map type.
map_type::const_iterator const_iterator
map_type::iterator iterator
iterator erase(const_iterator pos)
void swap(map_type &other)
const key_type & key_at(const size_type index) const
useful method for python decoration:
Forward declarations for the functions in SerializeSTL.h.
std::pair< iterator, bool > insert(ValueType &&val)
void throw_out_of_range_exception() const
throw std::out_of_range exception
Helper base-class to allow the generic Python-decoration for all "map-like" classes in Gaudi...
Map & merge(const map_type &other)
Merge two maps.
const value_type & const_reference
size_type max_size() const
Map()=default
Standard constructor.
KeyedObjectManager< map > Map
Forward declaration of specialized std::map-like object manager.