10 #ifndef LARCOREALG_COREUTILS_ZIP_H 11 #define LARCOREALG_COREUTILS_ZIP_H 19 #include <type_traits> 74 template <std::size_t Lead,
typename... Iterables>
75 auto zip(Iterables&&... iterables);
79 template <
typename... Iterables>
80 auto zip(Iterables&&... iterables)
81 {
return zip<0U>(std::forward<Iterables>(iterables)...); }
100 template <std::size_t Lead,
typename... Iters>
103 static_assert(Lead <
sizeof...(Iters),
104 "The index (Lead) of the leading iterator is invalid.");
118 = std::tuple<typename std::iterator_traits<Iters>::reference...>;
120 using pointer = std::add_pointer_t<std::remove_reference_t<reference>>;
152 template <std::
size_t Index>
165 {
increment_impl(std::index_sequence_for<Iters...>());
return *
this; }
181 template <std::size_t OtherLead,
typename... OtherIter>
183 {
return get<Lead>() != other.template get<OtherLead>(); }
186 template <std::size_t OtherLead,
typename... OtherIter>
188 {
return get<Lead>() == other.template get<OtherLead>(); }
201 template <
typename... Args>
204 template <std::size_t... Indices>
208 template <std::size_t... Indices>
217 return std::tuple<decltype(*std::get<Indices>(
fIterators))...>
227 template <std::
size_t Lead>
239 using pointer = std::add_pointer_t<std::remove_reference_t<reference>>;
254 template <std::size_t OtherLead,
typename... OtherIter>
259 template <std::size_t OtherLead,
typename... OtherIter>
267 template <std::size_t Lead,
typename... Iterables>
272 {
begin(iterables)... };
278 template <std::size_t Lead,
typename... Iterables>
283 {
end(iterables)... };
294 template <std::size_t Lead ,
typename... Iterables>
298 details::make_zip_begin_iterator<Lead>(iterables...),
299 details::make_zip_end_iterator<Lead>(iterables...)
308 #endif // LARCOREALG_COREUTILS_ZIP_H end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
span(IterB &&b, IterE &&e, Adaptor &&adaptor) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) >
void increment_impl(std::index_sequence< Indices... >)
Namespace for general, non-LArSoft-specific utilities.
zip_iterator()=default
Constructor: all iterators are default-constructed.
bool operator!=(zip_iterator< OtherLead, OtherIter... > const &other) const
Comparison (based on the Lead iterator only).
An object with a begin and end iterator.
std::tuple< Iters... > fIterators
Tuple of all zipped iterators.
std::add_pointer_t< std::remove_reference_t< reference >> pointer
auto dereference_impl(std::index_sequence< Indices... >) const
bool operator==(zip_iterator< OtherLead, OtherIter... > const &other) const
Comparison (based on the Lead iterator only).
auto make_zip_begin_iterator(Iterables &&...iterables)
decltype(auto) get() const
Returns the iterator at the specified Index.
std::ptrdiff_t difference_type
std::remove_cv_t< reference > value_type
std::tuple< typename std::iterator_traits< Iters >::reference... > reference
std::add_pointer_t< std::remove_reference_t< reference >> pointer
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
static void expandStatements(Args &...args)
Helper to trigger parameter pack expansion in expressions.
std::forward_iterator_tag iterator_category
auto operator*() const
Returns a tuple with values from all dereferenced iterators.
std::ptrdiff_t difference_type
std::remove_cv_t< reference > value_type
this_iterator_t & operator++()
Increments all the iterators.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
zip_iterator(Iters &&...iterators)
Constructor: copies all iterator values.
auto make_zip_end_iterator(Iterables &&...iterables)
std::forward_iterator_tag iterator_category