1 #ifndef GAUDIKERNEL_MAP_H 2 #define GAUDIKERNEL_MAP_H 1 80 template <
typename K,
typename T,
typename M = std::map<K, T>>
114 Map(
const map_type& other ) : m_map( other ) {}
119 template <
typename In>
120 Map( In&& first, In&& last ) : m_map(
std::forward<In>( first ),
std::forward<In>( last ) ) {}
123 virtual ~Map() =
default;
130 inline iterator
end() {
return m_map.
end(); }
132 inline const_iterator
begin()
const {
return m_map.
begin(); }
133 inline const_iterator
end()
const {
return m_map.
end(); }
143 inline mapped_type&
operator[](
const key_type& key ) {
return m_map[key]; }
147 inline iterator
find(
const key_type& key ) {
return m_map.
find( key ); }
148 inline const_iterator
find(
const key_type& key )
const {
return m_map.
find( key ); }
150 inline size_type
count(
const key_type& key )
const {
return m_map.
count( key ); }
152 inline iterator
lower_bound(
const key_type& key ) {
return m_map.lower_bound( key ); }
153 inline const_iterator
lower_bound(
const key_type& key )
const {
return m_map.lower_bound( key ); }
154 inline iterator
upper_bound(
const key_type& key ) {
return m_map.upper_bound( key ); }
155 inline const_iterator
upper_bound(
const key_type& key )
const {
return m_map.upper_bound( key ); }
163 template <
class... Args>
165 return m_map.
emplace( std::forward<Args>(
args )... );
167 template <
typename ValueType>
169 return m_map.
insert( std::forward<ValueType>( val ) );
172 return m_map.
insert( std::forward<value_type>( val ) );
174 template <
typename In>
175 inline void insert( In&& first, In&& last ) {
176 m_map.
insert( std::forward<In>( first ), std::forward<In>( last ) );
178 template <
typename ValueType>
179 inline iterator
insert( iterator , ValueType&& val ) {
180 return m_map.
insert( std::forward<ValueType>( val ) ).first;
182 inline iterator
erase( const_iterator pos ) {
return m_map.
erase( pos ); }
183 inline size_type
erase(
const key_type& key ) {
return m_map.
erase( key ); }
184 inline iterator
erase( const_iterator first, const_iterator last ) {
return m_map.
erase( first, last ); }
189 inline size_type
size()
const {
return m_map.
size(); }
192 inline void swap( map_type& other ) { m_map.
swap( other ); }
218 inline const result_type&
operator()(
const argument_type& key )
const {
220 auto it = m_map.
find( key );
247 inline const mapped_type&
operator[](
const key_type& key )
const {
return ( *
this )( key ); }
254 inline const result_type&
at(
const argument_type& key )
const {
return m_map.
at( key ); }
267 template <
class K1,
class K2,
class K3>
273 void update(
const key_type& key,
const mapped_type& mapped ) { ( *this )[key] = mapped; }
278 inline operator map_type&() {
return m_map; }
279 inline operator const map_type&()
const {
return m_map; }
288 const key_type&
key_at(
const size_type index )
const {
297 const mapped_type&
value_at(
const size_type index )
const {
304 template <
typename K,
typename T,
typename M>
313 #endif // GAUDIKERNEL_MAP_H std::pair< iterator, bool > insert(value_type &&val)
Extension of the STL map.
const_iterator end() const
static const result_type s_null_value
size_type count(const key_type &key) const
Map(In &&first, In &&last)
Construct from a subset.
const result_type & at(const argument_type &key) const
checked access to the map for missing keys
map_type::size_type size_type
size_type erase(const key_type &key)
iterator insert(iterator, ValueType &&val)
void update(const key_type &key, const mapped_type &mapped)
const_iterator find(const key_type &key) const
std::pair< iterator, bool > insert(ValueType &&val)
const_iterator lower_bound(const key_type &key) const
mapped_type & operator[](const key_type &key)
iterator erase(const_iterator first, const_iterator last)
iterator upper_bound(const key_type &key)
const result_type & operator()(const argument_type &key) const
Allow to use Map as an unary function.
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:
std::pair< iterator, bool > emplace(Args &&...args)
virtual ~Map()=default
Virtual destructor. You can inherit from this map type.
map_type::const_iterator const_iterator
Map & merge(const Map &other)
Merge two maps.
void insert(In &&first, In &&last)
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:
const_iterator begin() const
Map(const map_type &other)
Constructor from a standard map.
std::pair< const K, T > value_type
std::pair< const_iterator, const_iterator > equal_range(const key_type &key) const
const_iterator upper_bound(const key_type &key) const
Map & merge(const Map< K1, K2, K3 > &other)
Merge two maps.
Forward declarations for the functions in SerializeSTL.h.
void throw_out_of_range_exception() const
throw std::out_of_range exception
const mapped_type & operator[](const key_type &key) const
Access elements of a const Map.
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.
std::pair< iterator, iterator > equal_range(const key_type &key)