Adobe Source Libraries 2.0.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
median.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5*/
6/**************************************************************************************************/
7
8#ifndef ADOBE_ALGORITHM_MEDIAN_HPP
9#define ADOBE_ALGORITHM_MEDIAN_HPP
10
12#include <adobe/functional.hpp>
13
14#include <functional>
15
16namespace adobe {
17
18/**************************************************************************************************/
33
34/**************************************************************************************************/
35
40template <typename T, typename R>
41inline const T& median(const T& a, const T& b, const T& c, R r) {
42 return select_1_3(a, b, c, std::bind(r, std::placeholders::_1, std::placeholders::_2));
43}
44
49template <typename T, typename R>
50inline T& median(T& a, T& b, T& c, R r) {
51 return select_1_3(a, b, c, std::bind(r, std::placeholders::_1, std::placeholders::_2));
52}
53
58template <typename T>
59inline const T& median(const T& a, const T& b, const T& c) {
60 return select_1_3(a, b, c, less());
61}
62
67template <typename T>
68inline T& median(T& a, T& b, T& c) {
69 return select_1_3(a, b, c, less());
70}
71
72/**************************************************************************************************/
73
74} // namespace adobe
75#endif
const T & median(const T &a, const T &b, const T &c, R r)
median implementation
Definition median.hpp:41
const T & select_1_3(const T &a, const T &b, const T &c, R r)
select_1 implementation