mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-26 20:38:45 +08:00
33 lines
1006 B
Plaintext
33 lines
1006 B
Plaintext
Limiter
|
|
20.9.0
|
|
Limits an input range.
|
|
|
|
template <typename TInput, typename TCompare = etl::less<TInput> >
|
|
class limit : public etl::unary_function<TInput, TInput>
|
|
|
|
TInput The input data type.
|
|
TCompare The functor type used to compare values to the threshold. The default is etl::less
|
|
____________________________________________________________________________________________________
|
|
limit(TInput lowest, TInput highest)
|
|
lowest The lowest limit.
|
|
highest The highest limit.
|
|
____________________________________________________________________________________________________
|
|
TInput operator()(TInput value) const
|
|
Limit a value.
|
|
____________________________________________________________________________________________________
|
|
Example
|
|
|
|
std::array<int, 10> input =
|
|
{
|
|
10, 11, 12, 13, 14, 15, 16, 17, 18, 19
|
|
};
|
|
|
|
std::array<int, 10> output;
|
|
|
|
etl::limiter<int> limiter(13, 16);
|
|
|
|
std::transform(input.begin(), input.end(), output.begin(), limiter);
|
|
|
|
// output = 13, 13, 13, 13, 14, 15, 16, 16, 16, 16
|
|
|