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> >
96 typedef typename map_type::size_type
size_type;
98 typedef typename map_type::iterator
iterator;
115 Map(
const map_type& other): m_map(other) {}
120 template <
typename In>
121 Map(In first, In last): m_map(first,last) {}
130 inline iterator
begin() {
return m_map.begin(); }
131 inline iterator
end() {
return m_map.end(); }
133 inline const_iterator
begin()
const {
return m_map.begin(); }
134 inline const_iterator
end()
const {
return m_map.end(); }
144 inline mapped_type &
operator[] (
const key_type &key) {
return m_map[key]; }
148 inline iterator
find(
const key_type &key) {
return m_map.find(key); }
149 inline const_iterator
find(
const key_type &key)
const {
return m_map.find(key); }
151 inline size_type
count(
const key_type &key)
const {
return m_map.count(key); }
153 inline iterator
lower_bound(
const key_type &key) {
return m_map.lower_bound(key); }
154 inline const_iterator
lower_bound(
const key_type &key)
const {
return m_map.lower_bound(key); }
155 inline iterator
upper_bound(
const key_type &key) {
return m_map.upper_bound(key); }
156 inline const_iterator
upper_bound(
const key_type &key)
const {
return m_map.upper_bound(key); }
158 inline std::pair<iterator,iterator>
equal_range(
const key_type &key)
159 {
return m_map.equal_range(key); }
160 inline std::pair<const_iterator,const_iterator>
equal_range(
const key_type &key)
const
161 {
return m_map.equal_range(key); }
165 inline std::pair<iterator,bool>
insert(
const value_type &val) {
return m_map.insert(val); }
166 inline std::pair<iterator,bool>
insert
167 (
const key_type & key ,
168 const mapped_type & val ) {
return insert ( value_type ( key , val ) ) ; }
169 template <
typename In>
170 inline void insert(In first, In last) { m_map.insert(first,last); }
171 inline iterator
insert( iterator ,
const value_type &val)
172 {
return m_map.insert( val ).first ; }
173 inline void erase(iterator pos) { m_map.erase(pos); }
174 inline size_type
erase(
const key_type &key) {
return m_map.erase(key); }
175 inline void erase(iterator first, iterator last) { m_map.erase(first,last); }
176 inline void clear() { m_map.clear(); }
180 inline size_type
size()
const {
return m_map.size(); }
181 inline size_type
max_size()
const {
return m_map.max_size(); }
182 inline bool empty()
const {
return size() == 0; }
183 inline void swap(map_type& other) { m_map.swap(other); }
209 inline const result_type &
operator() (
const argument_type &key )
const
212 const_iterator it = m_map.find(key);
213 if ( it != m_map.end() ) {
return it->second ; }
240 inline const mapped_type &
operator[] (
const key_type &key )
const
241 {
return (*
this)(key); }
248 inline const result_type &
at (
const argument_type &key )
const
250 const_iterator it = m_map.find ( key ) ;
256 inline Map&
merge (
const map_type& other )
258 for (
typename map_type::const_iterator it = other.begin() ;
259 other.end() != it ; ++it ) { (*this)[it->first] = it->second ; }
265 for ( const_iterator it = other.begin() ;
266 other.end() != it ; ++it ) { (*this)[it->first] = it->second ; }
270 template <
class K1,
class K2,
class K3>
271 inline Map&
merge (
const Map<K1,K2,K3>& other )
273 for (
typename Map<K1,K2,K3>::const_iterator it = other.begin() ;
274 other.end() != it ; ++it ) { (*this)[it->first] = it->second ; }
279 (
const key_type& key ,
280 const mapped_type& mapped ) { (*this)[ key ] = mapped ; }
285 inline operator map_type &() {
return m_map ; }
286 inline operator const map_type &()
const {
return m_map ; }
295 const key_type&
key_at (
const size_type index )
const
297 if ( index >=
size() )
299 const_iterator it = this->
begin() ;
300 std::advance ( it , index ) ;
308 const mapped_type&
value_at (
const size_type index )
const
310 if ( index >=
size() )
312 const_iterator it = this->
begin() ;
313 std::advance ( it , index ) ;
319 template <
typename K,
typename T,
typename M>
328 #endif // GAUDIKERNEL_MAP_H
Map()
Standard constructor.
static const result_type s_null_value
virtual ~Map()
Virtual destructor. You can inherit from this map type.
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)
std::pair< iterator, bool > insert(const value_type &val)
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.
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:
map_type::const_iterator const_iterator
map_type::iterator iterator
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.
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.
size_type max_size() const
KeyedObjectManager< map > Map
Forward declaration of specialized std::map-like object manager.