LDMX Software
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator Class Reference

Iterator type representing a group of elements. More...

#include <GroupBy.h>

Public Types

using iterator_category = std::input_iterator_tag
 
using value_type = Group
 
using difference_type = std::ptrdiff_t
 
using pointer = Group *
 
using reference = Group &
 

Public Member Functions

constexpr GroupIterator (const GroupBy &groupBy, Iterator groupBegin)
 
constexpr GroupIteratoroperator++ ()
 Pre-increment operator to advance to the next group.
 
constexpr GroupIterator operator++ (int)
 Post-increment operator to advance to the next group.
 
constexpr Group operator* () const
 Derefence operator that returns the pointed-to group of elements.
 

Private Attributes

const GroupBym_groupBy
 
Iterator m_groupBegin
 
Iterator m_groupEnd
 

Friends

constexpr bool operator== (const GroupIterator &lhs, const GroupEndIterator &rhs)
 
constexpr bool operator!= (const GroupIterator &lhs, const GroupEndIterator &rhs)
 

Detailed Description

template<typename Iterator, typename KeyGetter>
class ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator

Iterator type representing a group of elements.

Definition at line 52 of file GroupBy.h.

Member Typedef Documentation

◆ difference_type

template<typename Iterator , typename KeyGetter >
using ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator::difference_type = std::ptrdiff_t

Definition at line 56 of file GroupBy.h.

◆ iterator_category

template<typename Iterator , typename KeyGetter >
using ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator::iterator_category = std::input_iterator_tag

Definition at line 54 of file GroupBy.h.

◆ pointer

template<typename Iterator , typename KeyGetter >
using ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator::pointer = Group*

Definition at line 57 of file GroupBy.h.

◆ reference

template<typename Iterator , typename KeyGetter >
using ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator::reference = Group&

Definition at line 58 of file GroupBy.h.

◆ value_type

template<typename Iterator , typename KeyGetter >
using ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator::value_type = Group

Definition at line 55 of file GroupBy.h.

Constructor & Destructor Documentation

◆ GroupIterator()

template<typename Iterator , typename KeyGetter >
constexpr ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator::GroupIterator ( const GroupBy groupBy,
Iterator  groupBegin 
)
inlineconstexpr

Definition at line 60 of file GroupBy.h.

61 : m_groupBy(groupBy),
62 m_groupBegin(groupBegin),
63 m_groupEnd(groupBy.findEndOfGroup(groupBegin)) {}

Member Function Documentation

◆ operator*()

template<typename Iterator , typename KeyGetter >
constexpr Group ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator::operator* ( ) const
inlineconstexpr

Derefence operator that returns the pointed-to group of elements.

Definition at line 79 of file GroupBy.h.

79 {
80 const Key key = (m_groupBegin != m_groupEnd)
81 ? m_groupBy.m_keyGetter(*m_groupBegin)
82 : Key();
83 return {key, makeRange(m_groupBegin, m_groupEnd)};
84 }
std::decay_t< decltype(KeyGetter()(*Iterator()))> Key
The key type that identifies elements within a group.
Definition GroupBy.h:42

◆ operator++() [1/2]

template<typename Iterator , typename KeyGetter >
constexpr GroupIterator & ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator::operator++ ( )
inlineconstexpr

Pre-increment operator to advance to the next group.

Definition at line 65 of file GroupBy.h.

65 {
66 // make the current end the new group beginning
67 std::swap(m_groupBegin, m_groupEnd);
68 // find the end of the next group starting from the new beginning
69 m_groupEnd = m_groupBy.findEndOfGroup(m_groupBegin);
70 return *this;
71 }
constexpr Iterator findEndOfGroup(Iterator start) const
Find the end of the group that starts at the given position.
Definition GroupBy.h:121

References ActsExamples::GroupBy< Iterator, KeyGetter >::findEndOfGroup().

◆ operator++() [2/2]

template<typename Iterator , typename KeyGetter >
constexpr GroupIterator ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator::operator++ ( int  )
inlineconstexpr

Post-increment operator to advance to the next group.

Definition at line 73 of file GroupBy.h.

73 {
74 GroupIterator retval = *this;
75 ++(*this);
76 return retval;
77 }

Friends And Related Symbol Documentation

◆ operator!=

template<typename Iterator , typename KeyGetter >
constexpr bool operator!= ( const GroupIterator lhs,
const GroupEndIterator rhs 
)
friend

Definition at line 95 of file GroupBy.h.

96 {
97 return not(lhs == rhs);
98 }

◆ operator==

template<typename Iterator , typename KeyGetter >
constexpr bool operator== ( const GroupIterator lhs,
const GroupEndIterator rhs 
)
friend

Definition at line 91 of file GroupBy.h.

92 {
93 return lhs.m_groupBegin == rhs;
94 }

Member Data Documentation

◆ m_groupBegin

template<typename Iterator , typename KeyGetter >
Iterator ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator::m_groupBegin
private

Definition at line 88 of file GroupBy.h.

◆ m_groupBy

template<typename Iterator , typename KeyGetter >
const GroupBy& ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator::m_groupBy
private

Definition at line 87 of file GroupBy.h.

◆ m_groupEnd

template<typename Iterator , typename KeyGetter >
Iterator ActsExamples::GroupBy< Iterator, KeyGetter >::GroupIterator::m_groupEnd
private

Definition at line 89 of file GroupBy.h.


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