18 #ifndef INCLUDED_UHD_UTILS_ALGORITHM_HPP 19 #define INCLUDED_UHD_UTILS_ALGORITHM_HPP 22 #include <boost/cstdint.hpp> 23 #include <boost/range/begin.hpp> 24 #include <boost/range/end.hpp> 42 template<
typename Range>
inline Range
sorted(
const Range &range){
43 Range r(range); std::sort(boost::begin(r), boost::end(r));
return r;
56 template<
typename Range>
inline Range
reversed(
const Range &range){
57 Range r(range); std::reverse(boost::begin(r), boost::end(r));
return r;
69 template<
typename Range,
typename T>
inline 70 bool has(
const Range &range,
const T &value){
71 return boost::end(range) != std::find(boost::begin(range), boost::end(range), value);
81 template<
typename T>
inline T
clip(
const T &val,
const T &bound1,
const T &bound2){
82 const T minimum = std::min(bound1, bound2);
83 if (val < minimum)
return minimum;
84 const T maximum = std::max(bound1, bound2);
85 if (val > maximum)
return maximum;
bool has(const Range &range, const T &value)
Definition: algorithm.hpp:70
Range reversed(const Range &range)
Definition: algorithm.hpp:56
Range sorted(const Range &range)
Definition: algorithm.hpp:42
Definition: convert.hpp:28
T clip(const T &val, const T &bound1, const T &bound2)
Definition: algorithm.hpp:81