Wraps a map-like object iterator to iterate on its first element. More...
#include <MapKeyIterator.h>
Public Types | |
using | map_iterator_t = Iter |
using | iterator_traits_t = std::iterator_traits< map_iterator_t > |
using | difference_type = typename iterator_traits_t::difference_type |
using | value_type = typename std::tuple_element< 0, typename iterator_traits_t::value_type >::type |
using | pointer = typename std::add_pointer< value_type >::type |
using | reference = typename std::add_lvalue_reference< value_type >::type |
using | iterator_category = typename iterator_traits_t::iterator_category |
Public Member Functions | |
MapKeyIterator ()=default | |
Default constructor is really default. More... | |
MapKeyIterator (map_iterator_t const &from) | |
Initialize from a original iterator type. More... | |
reference | operator* () |
Return the key of the original iterator value. More... | |
pointer | operator-> () |
Return a pointer to the key of the original iterator value. More... | |
Protected Types | |
using | pair_reference = typename iterator_traits_t::reference |
Protected Member Functions | |
pair_reference | get_value () const |
Static Protected Member Functions | |
static reference | get_key (pair_reference value) |
Wraps a map-like object iterator to iterate on its first element.
Iter | the iterator type |
This object can wrap a map-like iterator type to iterate through its key in a for loop.
The Iter::value_type must support a std::get<0>() call, that is what's used to extract the key.
Example of usage:
std::map<int, double> my_map; // ... fill the map ... // print all the kets for (MapKeyIterator<map_id_t::const_iterator> it = map_id.cbegin(); it != map_id.cend(); ++it) std::cout << "Key: " << *it << std::endl;
Although the non-constant iterators are supported, this is of little use since typically the key is declared constant anyway (in the example above, the key is const int
).
Definition at line 46 of file MapKeyIterator.h.
using rndm::NuRandomServiceHelper::MapKeyIterator< Iter >::difference_type = typename iterator_traits_t::difference_type |
Definition at line 52 of file MapKeyIterator.h.
using rndm::NuRandomServiceHelper::MapKeyIterator< Iter >::iterator_category = typename iterator_traits_t::iterator_category |
Definition at line 57 of file MapKeyIterator.h.
using rndm::NuRandomServiceHelper::MapKeyIterator< Iter >::iterator_traits_t = std::iterator_traits<map_iterator_t> |
Definition at line 49 of file MapKeyIterator.h.
using rndm::NuRandomServiceHelper::MapKeyIterator< Iter >::map_iterator_t = Iter |
Definition at line 48 of file MapKeyIterator.h.
|
protected |
Definition at line 75 of file MapKeyIterator.h.
using rndm::NuRandomServiceHelper::MapKeyIterator< Iter >::pointer = typename std::add_pointer<value_type>::type |
Definition at line 55 of file MapKeyIterator.h.
using rndm::NuRandomServiceHelper::MapKeyIterator< Iter >::reference = typename std::add_lvalue_reference<value_type>::type |
Definition at line 56 of file MapKeyIterator.h.
using rndm::NuRandomServiceHelper::MapKeyIterator< Iter >::value_type = typename std::tuple_element<0, typename iterator_traits_t::value_type>::type |
Definition at line 54 of file MapKeyIterator.h.
|
default |
Default constructor is really default.
|
inline |
Initialize from a original iterator type.
Definition at line 65 of file MapKeyIterator.h.
|
inlinestaticprotected |
Definition at line 79 of file MapKeyIterator.h.
|
inlineprotected |
Definition at line 77 of file MapKeyIterator.h.
|
inline |
Return the key of the original iterator value.
Definition at line 69 of file MapKeyIterator.h.
|
inline |
Return a pointer to the key of the original iterator value.
Definition at line 72 of file MapKeyIterator.h.