28constexpr auto Max(
const C& container)
30 using V = std::decay_t<
decltype(container)>;
31 using T =
typename V::value_type;
32 T ret = std::numeric_limits<T>::lowest();
33 for (
auto& iter : container)
35 ret = (std::max)(ret, iter);
45constexpr auto Min(
const C& container)
47 using V = std::decay_t<
decltype(container)>;
48 using T =
typename V::value_type;
49 T ret = (std::numeric_limits<T>::max)();
50 for (
auto& iter : container)
52 ret = (std::min)(ret, iter);
63template<
typename C,
typename F>
64constexpr auto Max(
const C& container,
F func)
66 using V = std::decay_t<
decltype(container)>;
67 using T =
typename V::value_type;
68 using T1 =
decltype(func(
T{}));
69 T1 ret = (std::numeric_limits<T1>::min)();
70 for (
auto& iter : container)
72 ret = (std::max)(ret, func(iter));
81template<
typename C,
typename F>
82constexpr auto Min(
const C& container,
F func)
84 using V = std::decay_t<
decltype(container)>;
85 using T =
typename V::value_type;
86 using T1 =
decltype(func(
T{}));
87 T1 ret = (std::numeric_limits<T1>::max)();
88 for (
auto& iter : container)
90 ret = (std::min)(ret, func(iter));
101template<
typename C,
typename F>
104 using V = std::decay_t<
decltype(container)>;
105 using T =
typename V::value_type;
106 using T_RET = std::invoke_result_t<F, T&>;
107 T_RET v_max = (std::numeric_limits<T_RET>::min)();
108 T& ret = *container.begin();
109 for (
auto& iter : container)
111 T_RET v = func(iter);
125template<
typename C,
typename F>
128 using V = std::decay_t<
decltype(container)>;
129 using T =
typename V::value_type;
130 using T_RET = std::invoke_result_t<F, T&>;
131 T_RET v_min = (std::numeric_limits<T_RET>::max)();
132 T& ret = *container.begin();
133 for (
auto& iter : container)
135 T_RET v = func(iter);
165 if (n >= vec->size())
173T&
CreateIfEmpty(std::vector<std::vector<T>>& vec, std::size_t n0, std::size_t n1)
175 if (n0 >= vec.size())
constexpr auto & MinRef(C &container, F func)
返回容器最小值
T & CreateIfEmpty(std::vector< T > &vec, std::size_t n)
获取容器元素,如果小了,就扩容
constexpr auto Max(const C &container)
返回容器最大值
constexpr auto & MaxRef(C &container, F func)
返回容器最大值
constexpr auto Min(const C &container)
返回容器最小值