Belle II Software release-09-00-01
__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 866 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 895 of file ntuples_full.h.

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

◆ apply()

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

Definition at line 878 of file ntuples_full.h.

879 {
880 auto fun_c = [&](const auto & rng) {
881 return fun(rng);
882 };
883 return __apply__internal__(vec, fun_c);
884 }

◆ apply_append()

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

Definition at line 868 of file ntuples_full.h.

869 {
870 auto fun_c = [&](const auto & rng) {
871 auto tail = rng.begin();
872 return nt::ntuple<T...>(T::get(*tail)...) | fun(rng);
873 };
874 return __apply__internal__(vec, fun_c);
875 }

◆ create_empty_vector()

static auto create_empty_vector ( )
inlinestaticprivate

Definition at line 889 of file ntuples_full.h.

890 {
891 return std::vector< decltype(std::declval<FUNC_T>()(std::declval<const std::vector<VEC_T>& >())) > {};
892 }

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