ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
|
#include <acts/blob/master/Examples/Framework/include/ACTFW/Utilities/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. | |
using | Group = std::pair< Key, Range< Iterator >> |
A Group is an iterator range with the associated key. | |
using | GroupEndIterator = Iterator |
Public Member Functions | |
constexpr | GroupBy (Iterator begin, Iterator end, KeyGetter keyGetter=KeyGetter()) |
Construct the group-by proxy for an iterator range. | |
constexpr GroupIterator | begin () const |
constexpr GroupEndIterator | end () const |
constexpr bool | empty () const |
Private Member Functions | |
constexpr Iterator | findEndOfGroup (Iterator start) const |
Private Attributes | |
Iterator | m_begin |
Iterator | m_end |
KeyGetter | m_keyGetter |
Proxy for iterating over groups of elements within a container.
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) { ... }
Definition at line 39 of file GroupBy.hpp.
View newest version in sPHENIX GitHub at line 39 of file GroupBy.hpp
using FW::GroupBy< Iterator, KeyGetter >::Group = std::pair<Key, Range<Iterator>> |
A Group is an iterator range with the associated key.
Definition at line 44 of file GroupBy.hpp.
View newest version in sPHENIX GitHub at line 44 of file GroupBy.hpp
using FW::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.
Definition at line 50 of file GroupBy.hpp.
View newest version in sPHENIX GitHub at line 50 of file GroupBy.hpp
using FW::GroupBy< Iterator, KeyGetter >::Key = std::decay_t<decltype(KeyGetter()(*Iterator()))> |
The key type that identifies elements within a group.
Definition at line 42 of file GroupBy.hpp.
View newest version in sPHENIX GitHub at line 42 of file GroupBy.hpp
|
inline |
Construct the group-by proxy for an iterator range.
Definition at line 102 of file GroupBy.hpp.
View newest version in sPHENIX GitHub at line 102 of file GroupBy.hpp
|
inline |
Definition at line 105 of file GroupBy.hpp.
View newest version in sPHENIX GitHub at line 105 of file GroupBy.hpp
References FW::GroupBy< Iterator, KeyGetter >::m_begin.
|
inline |
Definition at line 109 of file GroupBy.hpp.
View newest version in sPHENIX GitHub at line 109 of file GroupBy.hpp
References FW::GroupBy< Iterator, KeyGetter >::m_begin, and FW::GroupBy< Iterator, KeyGetter >::m_end.
|
inline |
Definition at line 108 of file GroupBy.hpp.
View newest version in sPHENIX GitHub at line 108 of file GroupBy.hpp
References FW::GroupBy< Iterator, KeyGetter >::m_end.
|
inlineprivate |
Find the end of the group that starts at the given position.
This uses a linear search from the start position and thus has linear complexity in the group size. It does not assume any ordering of the underlying container and is a cache-friendly access pattern.
Definition at line 121 of file GroupBy.hpp.
View newest version in sPHENIX GitHub at line 121 of file GroupBy.hpp
References FW::GroupBy< Iterator, KeyGetter >::m_end, FW::GroupBy< Iterator, KeyGetter >::m_keyGetter, start(), and x.
Referenced by FW::GroupBy< Iterator, KeyGetter >::GroupIterator::operator++().
|
private |
Definition at line 112 of file GroupBy.hpp.
View newest version in sPHENIX GitHub at line 112 of file GroupBy.hpp
Referenced by FW::GroupBy< Iterator, KeyGetter >::begin(), and FW::GroupBy< Iterator, KeyGetter >::empty().
|
private |
Definition at line 113 of file GroupBy.hpp.
View newest version in sPHENIX GitHub at line 113 of file GroupBy.hpp
Referenced by FW::GroupBy< Iterator, KeyGetter >::empty(), FW::GroupBy< Iterator, KeyGetter >::end(), and FW::GroupBy< Iterator, KeyGetter >::findEndOfGroup().
|
private |
Definition at line 114 of file GroupBy.hpp.
View newest version in sPHENIX GitHub at line 114 of file GroupBy.hpp
Referenced by FW::GroupBy< Iterator, KeyGetter >::findEndOfGroup(), and FW::GroupBy< Iterator, KeyGetter >::GroupIterator::operator*().