Juggler
Juggling algorithms and event processing using gaudi framework
Jug::GroupBy< Iterator, KeyGetter > Class Template Reference

#include <GroupBy.hpp>

Classes

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

Public Types

using Key = std::decay_t< decltype(KeyGetter()(*Iterator()))>
 The key type that identifies elements within a group. More...
 
using Group = std::pair< Key, Range< Iterator > >
 A Group is an iterator range with the associated key. More...
 
using GroupEndIterator = Iterator
 
using Key = std::decay_t< decltype(KeyGetter()(*Iterator()))>
 The key type that identifies elements within a group. More...
 
using Group = std::pair< Key, Range< Iterator > >
 A Group is an iterator range with the associated key. More...
 
using GroupEndIterator = Iterator
 
using Key = std::decay_t< decltype(KeyGetter()(*Iterator()))>
 The key type that identifies elements within a group. More...
 
using Group = std::pair< Key, Range< Iterator > >
 A Group is an iterator range with the associated key. More...
 
using GroupEndIterator = Iterator
 

Public Member Functions

constexpr GroupBy (Iterator begin, Iterator end, KeyGetter keyGetter=KeyGetter())
 Construct the group-by proxy for an iterator range. More...
 
constexpr GroupIterator begin () const
 
constexpr GroupEndIterator end () const
 
constexpr bool empty () const
 
constexpr GroupBy (Iterator begin, Iterator end, KeyGetter keyGetter=KeyGetter())
 Construct the group-by proxy for an iterator range. More...
 
constexpr GroupIterator begin () const
 
constexpr GroupEndIterator end () const
 
constexpr bool empty () const
 
constexpr GroupBy (Iterator begin, Iterator end, KeyGetter keyGetter=KeyGetter())
 Construct the group-by proxy for an iterator range. More...
 
constexpr GroupIterator begin () const
 
constexpr GroupEndIterator end () const
 
constexpr bool empty () const
 

Detailed Description

template<typename Iterator, typename KeyGetter>
class Jug::GroupBy< Iterator, KeyGetter >

Proxy for iterating over groups of elements within a container.

Note
Each group will contain at least one element.

Consecutive elements with the same key (as defined by the KeyGetter) are placed in one group. The proxy should always be used as part of a range-based for loop. In combination with structured bindings to reduce the boilerplate, the group iteration can be written as

for (auto&& [key, elements] : GroupBy<...>(...)) {
    // do something with just the key
    ...

    // iterate over the group elements
    for (const auto& element : elements) {
        ...
    }
}

Member Typedef Documentation

◆ Group [1/3]

template<typename Iterator , typename KeyGetter >
using Jug::GroupBy< Iterator, KeyGetter >::Group = std::pair<Key, Range<Iterator> >

A Group is an iterator range with the associated key.

◆ Group [2/3]

template<typename Iterator , typename KeyGetter >
using Jug::GroupBy< Iterator, KeyGetter >::Group = std::pair<Key, Range<Iterator> >

A Group is an iterator range with the associated key.

◆ Group [3/3]

template<typename Iterator , typename KeyGetter >
using Jug::GroupBy< Iterator, KeyGetter >::Group = std::pair<Key, Range<Iterator> >

A Group is an iterator range with the associated key.

◆ GroupEndIterator [1/3]

template<typename Iterator , typename KeyGetter >
using Jug::GroupBy< Iterator, KeyGetter >::GroupEndIterator = Iterator

Iterator type representing the end of the groups.

The end iterator will not be dereferenced in C++17 range-based loops. It can thus be a simpler type without the overhead of the full group iterator below.

◆ GroupEndIterator [2/3]

template<typename Iterator , typename KeyGetter >
using Jug::GroupBy< Iterator, KeyGetter >::GroupEndIterator = Iterator

Iterator type representing the end of the groups.

The end iterator will not be dereferenced in C++17 range-based loops. It can thus be a simpler type without the overhead of the full group iterator below.

◆ GroupEndIterator [3/3]

template<typename Iterator , typename KeyGetter >
using Jug::GroupBy< Iterator, KeyGetter >::GroupEndIterator = Iterator

Iterator type representing the end of the groups.

The end iterator will not be dereferenced in C++17 range-based loops. It can thus be a simpler type without the overhead of the full group iterator below.

◆ Key [1/3]

template<typename Iterator , typename KeyGetter >
using Jug::GroupBy< Iterator, KeyGetter >::Key = std::decay_t<decltype(KeyGetter()(*Iterator()))>

The key type that identifies elements within a group.

◆ Key [2/3]

template<typename Iterator , typename KeyGetter >
using Jug::GroupBy< Iterator, KeyGetter >::Key = std::decay_t<decltype(KeyGetter()(*Iterator()))>

The key type that identifies elements within a group.

◆ Key [3/3]

template<typename Iterator , typename KeyGetter >
using Jug::GroupBy< Iterator, KeyGetter >::Key = std::decay_t<decltype(KeyGetter()(*Iterator()))>

The key type that identifies elements within a group.

Constructor & Destructor Documentation

◆ GroupBy() [1/3]

template<typename Iterator , typename KeyGetter >
constexpr Jug::GroupBy< Iterator, KeyGetter >::GroupBy ( Iterator  begin,
Iterator  end,
KeyGetter  keyGetter = KeyGetter() 
)
inlineconstexpr

Construct the group-by proxy for an iterator range.

◆ GroupBy() [2/3]

template<typename Iterator , typename KeyGetter >
constexpr Jug::GroupBy< Iterator, KeyGetter >::GroupBy ( Iterator  begin,
Iterator  end,
KeyGetter  keyGetter = KeyGetter() 
)
inlineconstexpr

Construct the group-by proxy for an iterator range.

◆ GroupBy() [3/3]

template<typename Iterator , typename KeyGetter >
constexpr Jug::GroupBy< Iterator, KeyGetter >::GroupBy ( Iterator  begin,
Iterator  end,
KeyGetter  keyGetter = KeyGetter() 
)
inlineconstexpr

Construct the group-by proxy for an iterator range.

Member Function Documentation

◆ begin() [1/3]

template<typename Iterator , typename KeyGetter >
constexpr GroupIterator Jug::GroupBy< Iterator, KeyGetter >::begin ( ) const
inlineconstexpr

◆ begin() [2/3]

template<typename Iterator , typename KeyGetter >
constexpr GroupIterator Jug::GroupBy< Iterator, KeyGetter >::begin ( ) const
inlineconstexpr

◆ begin() [3/3]

template<typename Iterator , typename KeyGetter >
constexpr GroupIterator Jug::GroupBy< Iterator, KeyGetter >::begin ( ) const
inlineconstexpr

◆ empty() [1/3]

template<typename Iterator , typename KeyGetter >
constexpr bool Jug::GroupBy< Iterator, KeyGetter >::empty ( ) const
inlineconstexpr

◆ empty() [2/3]

template<typename Iterator , typename KeyGetter >
constexpr bool Jug::GroupBy< Iterator, KeyGetter >::empty ( ) const
inlineconstexpr

◆ empty() [3/3]

template<typename Iterator , typename KeyGetter >
constexpr bool Jug::GroupBy< Iterator, KeyGetter >::empty ( ) const
inlineconstexpr

◆ end() [1/3]

template<typename Iterator , typename KeyGetter >
constexpr GroupEndIterator Jug::GroupBy< Iterator, KeyGetter >::end ( ) const
inlineconstexpr

◆ end() [2/3]

template<typename Iterator , typename KeyGetter >
constexpr GroupEndIterator Jug::GroupBy< Iterator, KeyGetter >::end ( ) const
inlineconstexpr

◆ end() [3/3]

template<typename Iterator , typename KeyGetter >
constexpr GroupEndIterator Jug::GroupBy< Iterator, KeyGetter >::end ( ) const
inlineconstexpr

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