LDMX Software
acts_examples::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_group_by_
 
Iterator m_group_begin_
 
Iterator m_group_end_
 

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 acts_examples::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 acts_examples::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 acts_examples::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 acts_examples::GroupBy< Iterator, KeyGetter >::GroupIterator::pointer = Group*

Definition at line 57 of file GroupBy.h.

◆ reference

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

Definition at line 58 of file GroupBy.h.

◆ value_type

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

Definition at line 55 of file GroupBy.h.

Constructor & Destructor Documentation

◆ GroupIterator()

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

Definition at line 60 of file GroupBy.h.

61 : m_group_by_(groupBy),
62 m_group_begin_(groupBegin),
63 m_group_end_(groupBy.findEndOfGroup(groupBegin)) {}

Member Function Documentation

◆ operator*()

template<typename Iterator , typename KeyGetter >
Group acts_examples::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_group_begin_ != m_group_end_)
81 ? m_group_by_.m_key_getter_(*m_group_begin_)
82 : Key();
83 return {key, makeRange(m_group_begin_, m_group_end_)};
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 >
GroupIterator & acts_examples::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_group_begin_, m_group_end_);
68 // find the end of the next group starting from the new beginning
69 m_group_end_ = m_group_by_.findEndOfGroup(m_group_begin_);
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 acts_examples::GroupBy< Iterator, KeyGetter >::findEndOfGroup().

◆ operator++() [2/2]

template<typename Iterator , typename KeyGetter >
GroupIterator acts_examples::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 >
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 >
bool operator== ( const GroupIterator & lhs,
const GroupEndIterator & rhs )
friend

Definition at line 91 of file GroupBy.h.

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

Member Data Documentation

◆ m_group_begin_

template<typename Iterator , typename KeyGetter >
Iterator acts_examples::GroupBy< Iterator, KeyGetter >::GroupIterator::m_group_begin_
private

Definition at line 88 of file GroupBy.h.

◆ m_group_by_

template<typename Iterator , typename KeyGetter >
const GroupBy& acts_examples::GroupBy< Iterator, KeyGetter >::GroupIterator::m_group_by_
private

Definition at line 87 of file GroupBy.h.

◆ m_group_end_

template<typename Iterator , typename KeyGetter >
Iterator acts_examples::GroupBy< Iterator, KeyGetter >::GroupIterator::m_group_end_
private

Definition at line 89 of file GroupBy.h.


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