Juggler
Juggling algorithms and event processing using gaudi framework
|
Go to the documentation of this file.
38 template <
typename Iterator,
typename KeyGetter>
42 using Key = std::decay_t<decltype(KeyGetter()(*Iterator()))>;
44 using Group = std::pair<Key, Range<Iterator>>;
62 m_groupBegin(groupBegin),
63 m_groupEnd(groupBy.findEndOfGroup(groupBegin)) {}
67 std::swap(m_groupBegin, m_groupEnd);
69 m_groupEnd = m_groupBy.findEndOfGroup(m_groupBegin);
80 const Key key = (m_groupBegin != m_groupEnd)
81 ? m_groupBy.m_keyGetter(*m_groupBegin)
88 Iterator m_groupBegin;
93 return lhs.m_groupBegin == rhs;
97 return not(lhs == rhs);
103 KeyGetter keyGetter = KeyGetter())
104 : m_begin(
begin), m_end(
end), m_keyGetter(std::move(keyGetter)) {}
109 constexpr
bool empty()
const {
return m_begin == m_end; }
114 KeyGetter m_keyGetter;
121 constexpr Iterator findEndOfGroup(Iterator start)
const {
123 if (start == m_end) {
127 return std::find_if_not(std::next(start), m_end,
128 [
this, start](
const auto& x) {
129 return m_keyGetter(x) == m_keyGetter(*start);
135 template <
typename Container,
typename KeyGetter>
136 GroupBy<typename Container::const_iterator, KeyGetter>
makeGroupBy(
137 const Container& container, KeyGetter keyGetter) {
138 return {container.begin(), container.end(), std::move(keyGetter)};
Iterator GroupEndIterator
Definition: GroupBy.hpp:50
constexpr friend bool operator!=(const GroupIterator &lhs, const GroupEndIterator &rhs)
Definition: GroupBy.hpp:95
auto makeGroupBy(const Container &container, KeyGetter keyGetter) -> GroupBy< decltype(std::begin(container)), KeyGetter >
Construct the group-by proxy for a container.
Definition: GroupBy.hpp:136
key
Definition: example_calodigi.py:28
Group value_type
Definition: GroupBy.hpp:55
constexpr bool empty() const
Definition: GroupBy.hpp:109
constexpr GroupIterator begin() const
Definition: GroupBy.hpp:105
std::ptrdiff_t difference_type
Definition: GroupBy.hpp:56
constexpr GroupEndIterator end() const
Definition: GroupBy.hpp:108
Iterator type representing a group of elements.
Definition: GroupBy.hpp:52
constexpr GroupBy(Iterator begin, Iterator end, KeyGetter keyGetter=KeyGetter())
Construct the group-by proxy for an iterator range.
Definition: GroupBy.hpp:102
Group * pointer
Definition: GroupBy.hpp:57
Definition: DD4hepBField.h:22
Definition: GroupBy.hpp:39
constexpr Group operator*() const
Derefence operator that returns the pointed-to group of elements.
Definition: GroupBy.hpp:79
Range< Iterator > makeRange(Iterator begin, Iterator end)
Definition: Range.hpp:47
constexpr GroupIterator operator++(int)
Post-increment operator to advance to the next group.
Definition: GroupBy.hpp:73
std::input_iterator_tag iterator_category
Definition: GroupBy.hpp:54
std::pair< Key, Range< Iterator > > Group
A Group is an iterator range with the associated key.
Definition: GroupBy.hpp:44
std::decay_t< decltype(KeyGetter()(*Iterator()))> Key
The key type that identifies elements within a group.
Definition: GroupBy.hpp:42
constexpr GroupIterator(const GroupBy &groupBy, Iterator groupBegin)
Definition: GroupBy.hpp:60
Group & reference
Definition: GroupBy.hpp:58
constexpr friend bool operator==(const GroupIterator &lhs, const GroupEndIterator &rhs)
Definition: GroupBy.hpp:91
constexpr GroupIterator & operator++()
Pre-increment operator to advance to the next group.
Definition: GroupBy.hpp:65