Belle II Software development
__group< T > Struct Template Reference

Static Public Member Functions

template<typename VEC_T , typename FUNC_T >
static auto apply_append (const std::vector< VEC_T > &vec, FUNC_T &&fun)
 
template<typename VEC_T , typename FUNC_T >
static auto apply (const std::vector< VEC_T > &vec, FUNC_T &&fun)
 

Static Private Member Functions

template<typename VEC_T , typename FUNC_T >
static auto create_empty_vector ()
 
template<typename VEC_T , typename FUNC_T >
static auto __apply__internal__ (const std::vector< VEC_T > &vec, FUNC_T &&fun_c)
 

Detailed Description

template<typename... T>
struct nt::algorithms::__group< T >

Definition at line 766 of file ntuples_full.h.

Member Function Documentation

◆ __apply__internal__()

static auto __apply__internal__ ( const std::vector< VEC_T > &  vec,
FUNC_T &&  fun_c 
)
inlinestaticprivate

Definition at line 795 of file ntuples_full.h.

796 {
797 static constexpr auto lt = nt::comparators::lessThan<T...>();
798 static constexpr auto eq = nt::comparators::equal<T...>();
799 auto ret = create_empty_vector<VEC_T, FUNC_T>();
800
801
802
803 if (vec.empty()) {
804 return ret;
805 }
806 auto min_element = vec[0];
807 auto max_element = vec[0];
808
809 for (const auto& e : vec) {
810 if (lt(e, min_element)) {
811 min_element = e;
812 }
813
814 if (lt(max_element, e)) {
815 max_element = e;
816 }
817 }
818
819 if (eq(min_element, max_element)) {
820 ret.push_back(
821 fun_c(vec)
822 );
823 return ret;
824 }
825
826 std::vector<VEC_T> buff{};
827 buff.reserve(vec.size());
828
829
830
831 auto process = [&]() {
832 buff.clear();
833 VEC_T next_min_element{};
834 next_min_element = max_element;
835
836 for (const auto& e : vec) {
837 if (eq(min_element, e)) {
838 buff.push_back(e);
839 } else if (lt(min_element, e) && lt(e, next_min_element)) {
840 next_min_element = e;
841 }
842
843 }
844
845 min_element = next_min_element;
846
847
848 ret.push_back(fun_c(buff));
849 };
850
851 while (lt(min_element, max_element)) {
852 process();
853
854 }
855
856 process();
857
858
859 return ret;
860 }

◆ apply()

static auto apply ( const std::vector< VEC_T > &  vec,
FUNC_T &&  fun 
)
inlinestatic

Definition at line 778 of file ntuples_full.h.

779 {
780 auto fun_c = [&](const auto & rng) {
781 return fun(rng);
782 };
783 return __apply__internal__(vec, fun_c);
784 }

◆ apply_append()

static auto apply_append ( const std::vector< VEC_T > &  vec,
FUNC_T &&  fun 
)
inlinestatic

Definition at line 768 of file ntuples_full.h.

769 {
770 auto fun_c = [&](const auto & rng) {
771 auto tail = rng.begin();
772 return nt::ntuple<T...>(T::get(*tail)...) | fun(rng);
773 };
774 return __apply__internal__(vec, fun_c);
775 }

◆ create_empty_vector()

static auto create_empty_vector ( )
inlinestaticprivate

Definition at line 789 of file ntuples_full.h.

790 {
791 return std::vector< decltype(std::declval<FUNC_T>()(std::declval<const std::vector<VEC_T>& >())) > {};
792 }

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