2 #ifndef GAUDIKERNEL_VECTORMAP_H 3 #define GAUDIKERNEL_VECTORMAP_H 1 14 #include <initializer_list> 147 typedef typename _vector::const_iterator
iterator ;
174 bool operator () (
const key_type& k1 ,
const key_type& k2 )
const 177 bool operator() (
const value_type& v1 ,
const value_type& v2 )
const 180 bool operator() (
const key_type& k ,
const value_type& v )
const 183 bool operator() (
const value_type& v ,
const key_type & k )
const 227 size_type
erase (
const key_type& key )
229 iterator pos =
find ( key ) ;
230 if (
end() == pos ) {
return 0 ; }
244 return last - first ;
267 template <
class TYPE>
268 size_type
erase ( TYPE first , TYPE last )
271 for ( ; first != last ; ++first ) { res +=
erase ( *first ) ; }
317 (
const key_type& key ,
318 const mapped_type& mapped )
319 {
return insert ( value_type ( key , mapped ) ) ; }
362 (
const value_type& value )
366 if (
end() == result ||
compare( value.first , result -> first ) )
367 { result =
m_vct.
insert ( result , value ) ; found = false ; }
381 const value_type& value )
383 if ( pos !=
end() &&
compare ( *pos , value ) &&
384 ( pos ==
end() - 1 ||
385 ( !
compare ( value , *( pos + 1 ) )
386 &&
compare ( *( pos + 1 ) , value ) ) ) )
402 const key_type& key ,
403 const mapped_type& mapped )
404 {
return insert ( pos , value_type ( key , mapped ) ) ; }
411 template <
class PAIRS>
415 {
for ( ; first != last ; ++first ) {
insert ( *first ) ; } }
424 template <
class KEYS,
class VALUES>
void insert 428 {
for ( ; kf != kl ; ++kf, ++vf ) {
insert ( *kf , *vf ) ; } }
455 iterator
find (
const key_type& key )
const 458 if (
end() != res &&
compare ( key , res->first ) )
478 size_type
count (
const key_type& key )
const 479 {
return end() ==
find ( key ) ? 0 : 1 ; }
520 {
return right < left ; }
523 {
return !( left == right ) ; }
526 {
return !( left < right ) ; }
529 {
return !( right < left ) ; }
561 (
const key_type& key ,
562 const mapped_type& mapped )
565 if (
end() == result ||
compare ( key , result -> first ) )
570 else { result->second = mapped ; }
604 {
return update ( val.first , val.second ) ; }
639 static const mapped_type s_default =
mapped_type() ;
640 iterator res =
find ( key ) ;
641 if (
end() == res ) {
return s_default ; }
676 {
return (*
this)( key ) ; }
695 const mapped_type&
at (
const key_type& key )
const 697 iterator res =
find ( key ) ;
710 VectorMap (
const allocator_type& alloc = allocator_type () )
727 template <
class INPUT>
730 const allocator_type& alloc = allocator_type () )
731 :
m_vct ( first , last , alloc )
740 const allocator_type& alloc = allocator_type () )
741 :
m_vct ( first , alloc )
753 if ( &right ==
this ) {
return *this ; }
779 for (
const auto& i : right ) {
update ( i.first , i.second ) ; }
783 template <
class K1,
class K2,
class K3,
class K4>
786 for (
const auto& i : right ) {
update ( i.first , i.second ) ; }
797 const key_type&
key_at (
const size_t index )
const 799 if ( index >=
size() )
801 auto it = this->
begin() ;
810 const mapped_type&
value_at (
const size_t index )
const 812 if ( index >=
size() )
814 auto it = this->
begin() ;
828 template <
class TYPE1,
class TYPE2>
830 const TYPE2& obj2 )
const 832 return compare() ( obj1 , obj2 ) ;
853 auto result =
begin();
882 { left.
swap( right ) ; }
928 #endif // GAUDIKERNEL_MAPS_H const mapped_type & operator[](const key_type &key) const
access to element by key (const version) there is no container increment for missing keys ...
A bit modified version of 'Loki::AssocVector' associative vector from Loki library by Andrei Alexandr...
friend bool operator!=(const VectorMap &left, const VectorMap &right)
bool operator==(const VectorMap &other) const
comparison criteria for containers
const mapped_type & at(const key_type &key) const
checked access to elements by key throw std::out_of_range exception for non-existing keys ...
~VectorMap()
destructor (non-virtual!)
iterator iter(_iterator p)
the conversion from 'non-const' to 'const' iterator
void reserve(size_type num)
reserve the space in the container for at least 'num' elements
bool compare(const TYPE1 &obj1, const TYPE2 &obj2) const
compare the objects using the comaprison criteria
_vector::iterator _iterator
the regular iterator (no export)
const key_type & key_at(const size_t index) const
useful method for python decoration:
_vector::const_iterator iterator
visible const_iterator (exported)
size_type erase(TYPE first, TYPE last)
erase the sequence of elements using the sequence of keys
bool operator()(const key_type &k1, const key_type &k2) const
compare keys: use key_compare
result_type insert(const key_type &key, const mapped_type &mapped)
insert the (key,value) pair into the container
VectorMap & merge(const VectorMap< K1, K2, K3, K4 > &right)
merge two maps
VectorMap(const VectorMap &right)
copy constructor
size_type erase(const key_type &key)
erase the element using the key
size_type max_size() const
maximal allowed size
iterator find(const key_type &key) const
find the element by key
const key_compare & compare_key() const
get the comparison criteria for keys
reverse_iterator rbegin() const
"rbegin" iterator for sequential access (const-only version!)
std::pair< iterator, iterator > iterators
visible iterator pait
iterator lower_bound(const key_type &key) const
iterator end() const
"end" iterator for sequential access (const-only version!)
ALLOCATOR::const_reference reference
the types to conform STL
size_type erase(iterator first, iterator last)
erase the sequence of elements using the iterators
_vector m_vct
the underlying sorted vector of (key,mapped) pairs
std::reverse_iterator< const_iterator > const_reverse_iterator
visible reverse const_iterator (exported)
This class is used for returning status codes from appropriate routines.
iterator begin() const
"begin" iterator for sequential access (const-only version!)
_compare_type()
default constructor
friend bool operator>=(const VectorMap &left, const VectorMap &right)
std::reverse_iterator< iterator > reverse_iterator
visible reverse const_iterator (exported)
friend bool operator>(const VectorMap &left, const VectorMap &right)
std::pair< iterator, bool > result_type
visible iterator pait
ALLOCATOR::const_reference const_reference
the types to conform STL
_compare_type(const key_compare &cmp)
constructor from the key-comparison criteria
bool update(const value_type &val)
forced insertion of the key/mapped pair The method acts like "insert" but it DOES overwrite the mappe...
VectorMap(std::initializer_list< value_type > first, const allocator_type &alloc=allocator_type())
tconstructor from initializer list
friend bool operator<=(const VectorMap &left, const VectorMap &right)
VectorMap(INPUT first, INPUT last, const allocator_type &alloc=allocator_type())
templated constructor from "convertible" sequence
reverse_iterator rend() const
"rend" iterator for sequential access (const-only version!)
VALUE mapped_type
the actual type of value
_compare_type compare_type
the actual comparison criteria for valye_type objects
_vector::const_iterator const_iterator
visible const_iterator (exported)
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
iterator upper_bound(const key_type &key) const
bool operator<(const VectorMap &other) const
comparison criteria for containers
VectorMap & operator=(const VectorMap &right)
size_type count(const key_type &key) const
count number of elements with the certain key
const compare_type & compare() const
get the comparison criteria itself
ALLOCATOR allocator_type
allocator (could be useful for optimizations)
Forward declarations for the functions in SerializeSTL.h.
_iterator iter(iterator p)
the conversion from 'const' to 'non-const' iterator
bool update(const key_type &key, const mapped_type &mapped)
forced insertion of the key/mapped pair The method acts like "insert" but it DOES overwrite the exist...
KEYCOMPARE key_compare
comparison of keys
void clear()
clear the container
KEY key_type
the actual type of key
void throw_out_of_range_exception() const
throw std::out_of_range exception
void swap(VectorMap &other)
swap function, which 'swaps' the content of two containers
The actual structure used to compare the elements Only "key" is important for comparison.
ALLOCATOR::difference_type difference_type
the types to conform STL
bool empty() const
empty container ?
iterators equal_range(const key_type &key) const
std::pair< key_type, mapped_type > value_type
the actual storage item
VectorMap & merge(const VectorMap &right)
merge two maps
Helper base-class to allow the generic Python-decoration for all "map-like" classes in Gaudi...
ALLOCATOR::size_type size_type
the types to conform STL
void erase(iterator pos)
erase the element using the iterator
Helper functions to set/get the application return code.
VectorMap(const allocator_type &alloc=allocator_type())
default constructor from the the allocator
_iterator lower_bound(const key_type &key)
'lower-bound' - non-const version
GAUDI_API StatusCode parse(GaudiUtils::VectorMap< Gaudi::StringKey, double > &result, const std::string &input)
parse the vector of keys from the string
size_type size() const
number of elements
std::vector< value_type, allocator_type > _vector
the actual storage container (no export)
const mapped_type & value_at(const size_t index) const
useful method for python decoration: