stlab.adobe.com Adobe Systems Incorporated
algorithm/select.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2005-2008 Adobe Systems Incorporated
3  Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
4  or a copy at http://stlab.adobe.com/licenses.html)
5 */
6 /**************************************************************************************************/
7 
8 #ifndef ADOBE_ALGORITHM_SELECT_HPP
9 #define ADOBE_ALGORITHM_SELECT_HPP
10 
12 
13 namespace adobe {
14 
15 /**************************************************************************************************/
42 /**************************************************************************************************/
47 template <typename T, typename R>
48 inline const T& select_1_ac(const T& a, const T& b, const T& c, R r)
49 {
50  assert(!r(c, a) && "WARNING (sparent) : a and c must be non-decreasing");
51  return r(b, a) ? a : (adobe::min)(b, c, r);
52 }
53 
58 template <typename T, typename R>
59 inline T& select_1_ac(T& a, T& b, T& c, R r)
60 {
61  assert(!r(c, a) && "WARNING (sparent) : a and c must be non-decreasing");
62  return r(b, a) ? a : (adobe::min)(b, c, r);
63 }
64 
69 template <typename T, typename R>
70 inline const T& select_1_ab(const T& a, const T& b, const T& c, R r)
71 {
72  assert(!r(b, a) && "WARNING (sparent) : a and b must be non-decreasing");
73  return r(c, b) ? (adobe::max)(a, c, r) : b;
74 }
75 
80 template <typename T, typename R>
81 inline T& select_1_ab(T& a, T& b, T& c, R r)
82 {
83  assert(!r(b, a) && "WARNING (sparent) : a and b must be non-decreasing");
84  return r(c, b) ? (adobe::max)(a, c, r) : b;
85 }
86 
91 template <typename T, typename R>
92 inline const T& select_1(const T& a, const T& b, const T& c, R r)
93 { return r(b, a) ? select_1_ab(b, a, c, r) : select_1_ab(a, b, c, r); }
94 
99 template <typename T, typename R>
100 inline T& select_1(T& a, T& b, T& c, R r)
101 { return r(b, a) ? select_1_ab(b, a, c, r) : select_1_ab(a, b, c, r); }
102 
103 /**************************************************************************************************/
104 
105 } // namespace adobe
106 
107 #endif

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google