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 854 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 883 of file ntuples_full.h.

884 {
885 static constexpr auto lt = nt::comparators::lessThan<T...>();
886 static constexpr auto eq = nt::comparators::equal<T...>();
887 auto ret = create_empty_vector<VEC_T, FUNC_T>();
888
889
890
891 if (vec.empty()) {
892 return ret;
893 }
894 auto min_element = vec[0];
895 auto max_element = vec[0];
896
897 for (const auto& e : vec) {
898 if (lt(e, min_element)) {
899 min_element = e;
900 }
901
902 if (lt(max_element, e)) {
903 max_element = e;
904 }
905 }
906
907 if (eq(min_element, max_element)) {
908 ret.push_back(
909 fun_c(vec)
910 );
911 return ret;
912 }
913
914 std::vector<VEC_T> buff{};
915 buff.reserve(vec.size());
916
917
918
919 auto process = [&]() {
920 buff.clear();
921 VEC_T next_min_element{};
922 next_min_element = max_element;
923
924 for (const auto& e : vec) {
925 if (eq(min_element, e)) {
926 buff.push_back(e);
927 } else if (lt(min_element, e) && lt(e, next_min_element)) {
928 next_min_element = e;
929 }
930
931 }
932
933 min_element = next_min_element;
934
935
936 ret.push_back(fun_c(buff));
937 };
938
939 while (lt(min_element, max_element)) {
940 process();
941
942 }
943
944 process();
945
946
947 return ret;
948 }

◆ apply()

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

Definition at line 866 of file ntuples_full.h.

867 {
868 auto fun_c = [&](const auto & rng) {
869 return fun(rng);
870 };
871 return __apply__internal__(vec, fun_c);
872 }

◆ apply_append()

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

Definition at line 856 of file ntuples_full.h.

857 {
858 auto fun_c = [&](const auto & rng) {
859 auto tail = rng.begin();
860 return nt::ntuple<T...>(T::get(*tail)...) | fun(rng);
861 };
862 return __apply__internal__(vec, fun_c);
863 }

◆ create_empty_vector()

static auto create_empty_vector ( )
inlinestaticprivate

Definition at line 877 of file ntuples_full.h.

878 {
879 return std::vector< decltype(std::declval<FUNC_T>()(std::declval<const std::vector<VEC_T>& >())) > {};
880 }

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