stlab.adobe.com Adobe Systems Incorporated

select.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2008 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 /**************************************************************************************************/
00007 
00008 #ifndef ADOBE_ALGORITHM_SELECT_HPP
00009 #define ADOBE_ALGORITHM_SELECT_HPP
00010 
00011 #include <adobe/algorithm/minmax.hpp>
00012 
00013 namespace adobe {
00014 
00015 /**************************************************************************************************/
00042 /**************************************************************************************************/
00047 template <typename T, typename R>
00048 inline const T& select_1_ac(const T& a, const T& b, const T& c, R r)
00049 {
00050     assert(!r(c, a) && "WARNING (sparent) : a and c must be non-decreasing");
00051     return r(b, a) ? a : (adobe::min)(b, c, r);
00052 }
00053 
00058 template <typename T, typename R>
00059 inline T& select_1_ac(T& a, T& b, T& c, R r)
00060 {
00061     assert(!r(c, a) && "WARNING (sparent) : a and c must be non-decreasing");
00062     return r(b, a) ? a : (adobe::min)(b, c, r);
00063 }
00064 
00069 template <typename T, typename R>
00070 inline const T& select_1_ab(const T& a, const T& b, const T& c, R r)
00071 {
00072     assert(!r(b, a) && "WARNING (sparent) : a and b must be non-decreasing");
00073     return r(c, b) ? (adobe::max)(a, c, r) : b;
00074 }
00075 
00080 template <typename T, typename R>
00081 inline T& select_1_ab(T& a, T& b, T& c, R r)
00082 {
00083     assert(!r(b, a) && "WARNING (sparent) : a and b must be non-decreasing");
00084     return r(c, b) ? (adobe::max)(a, c, r) : b;
00085 }
00086 
00091 template <typename T, typename R>
00092 inline const T& select_1(const T& a, const T& b, const T& c, R r)
00093 { return r(b, a) ? select_1_ab(b, a, c, r) : select_1_ab(a, b, c, r); }
00094 
00099 template <typename T, typename R>
00100 inline T& select_1(T& a, T& b, T& c, R r)
00101 { return r(b, a) ? select_1_ab(b, a, c, r) : select_1_ab(a, b, c, r); }
00102 
00103 /**************************************************************************************************/
00104 
00105 } // namespace adobe
00106 
00107 #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