libzypp 17.37.17
zypp::MapKVIteratorTraits< TMap > Struct Template Reference

Traits for std::map key and value iterators. More...

#include <zypp-core/base/Iterator.h>

Public Types

using MapType = TMap
 The map type.
using KeyType = typename TMap::key_type
 The maps key type.
using Key_const_iterator = transform_iterator<GetPairFirst<typename MapType::value_type>, typename MapType::const_iterator>
 The key iterator type.
using ValueType = typename TMap::mapped_type
 The maps value (mapped) type.
using Value_const_iterator = transform_iterator<GetPairSecond<typename MapType::value_type>, typename MapType::const_iterator>
 The value iterator type.

Detailed Description

template<class TMap>
struct zypp::MapKVIteratorTraits< TMap >

Traits for std::map key and value iterators.

GetPairFirst and GetPairSecond help building a transform_iterator that iterates over keys or values of a std::map. Class MapKVIteratorTraits provides some typedefs, you usg. do not want to write explicitly.

// typedefs
typedef std::map<K,V> MapType;
// transform_iterator<GetPairFirst<MapType::value_type>, MapType::const_iterator>
// transform_iterator<GetPairSecond<MapType::value_type>, MapType::const_iterator>
// usage
MapType mymap;
MapTypeKey_const_iterator keyBegin( make_map_key_begin( mymap ) );
MapTypeKey_const_iterator keyEnd ( make_map_key_end( mymap ) );
MapTypeValue_const_iterator valBegin( make_map_value_begin( mymap ) );
MapTypeValue_const_iterator valEnd ( make_map_value_end( mymap ) );
std::for_each( keyBegin, keyEnd, DoSomething() );
std::for_each( valBegin, valEnd, DoSomething() );
MapKVIteratorTraits< TMap >::Key_const_iterator make_map_key_begin(const TMap &map_r)
Convenience to create the key iterator from container::begin()
Definition Iterator.h:226
MapKVIteratorTraits< TMap >::Value_const_iterator make_map_value_begin(const TMap &map_r)
Convenience to create the value iterator from container::begin()
Definition Iterator.h:236
MapKVIteratorTraits< TMap >::Key_const_iterator make_map_key_end(const TMap &map_r)
Convenience to create the key iterator from container::end()
Definition Iterator.h:231
MapKVIteratorTraits< TMap >::Value_const_iterator make_map_value_end(const TMap &map_r)
Convenience to create the value iterator from container::end()
Definition Iterator.h:241
transform_iterator< GetPairFirst< typename MapType::value_type >, typename MapType::const_iterator > Key_const_iterator
The key iterator type.
Definition Iterator.h:217
transform_iterator< GetPairSecond< typename MapType::value_type >, typename MapType::const_iterator > Value_const_iterator
The value iterator type.
Definition Iterator.h:221
TMap MapType
The map type.
Definition Iterator.h:213

Or short:

typedef std::map<K,V> MapType;
MapType mymap;
std::for_each( make_map_key_begin( mymap ), make_map_key_end( mymap ), DoSomething() );
std::for_each( make_map_value_begin( mymap ), make_map_value_end( mymap ), DoSomething() );

Definition at line 210 of file Iterator.h.

Member Typedef Documentation

◆ MapType

template<class TMap>
using zypp::MapKVIteratorTraits< TMap >::MapType = TMap

The map type.

Definition at line 213 of file Iterator.h.

◆ KeyType

template<class TMap>
using zypp::MapKVIteratorTraits< TMap >::KeyType = typename TMap::key_type

The maps key type.

Definition at line 215 of file Iterator.h.

◆ Key_const_iterator

template<class TMap>
using zypp::MapKVIteratorTraits< TMap >::Key_const_iterator = transform_iterator<GetPairFirst<typename MapType::value_type>, typename MapType::const_iterator>

The key iterator type.

Definition at line 217 of file Iterator.h.

◆ ValueType

template<class TMap>
using zypp::MapKVIteratorTraits< TMap >::ValueType = typename TMap::mapped_type

The maps value (mapped) type.

Definition at line 219 of file Iterator.h.

◆ Value_const_iterator

template<class TMap>
using zypp::MapKVIteratorTraits< TMap >::Value_const_iterator = transform_iterator<GetPairSecond<typename MapType::value_type>, typename MapType::const_iterator>

The value iterator type.

Definition at line 221 of file Iterator.h.


The documentation for this struct was generated from the following file: