Adobe Source Libraries 2.0.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
algorithm/select.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_SELECT_HPP
9#define ADOBE_ALGORITHM_SELECT_HPP
10
11#include <cassert>
12
13namespace adobe {
14
15/**************************************************************************************************/
42
43/**************************************************************************************************/
44
49template <class T, class R>
50inline const T& select_0_2(const T& a, const T& b, R r) {
51 return r(b, a) ? b : a;
52}
53
58template <class T, class R>
59inline T& select_0_2(T& a, T& b, R r) {
60 return r(b, a) ? b : a;
61}
62
67template <class T, class R>
68inline const T& select_1_2(const T& a, const T& b, R r) {
69 return r(b, a) ? a : b;
70}
71
76template <class T, class R>
77inline T& select_1_2(T& a, T& b, R r) {
78 return r(b, a) ? a : b;
79}
80
85template <typename T, typename R>
86inline const T& select_1_3_ac(const T& a, const T& b, const T& c, R r) {
87 assert(!r(c, a) && "WARNING (sparent) : a and b must be non-decreasing");
88 return r(b, a) ? a : select_0_2(b, c, r);
89}
90
95template <typename T, typename R>
96inline T& select_1_3_ac(T& a, T& b, T& c, R r) {
97 assert(!r(c, a) && "WARNING (sparent) : a and b must be non-decreasing");
98 return r(b, a) ? a : select_0_2(b, c, r);
99}
100
105template <typename T, typename R>
106inline const T& select_1_3_ab(const T& a, const T& b, const T& c, R r) {
107 assert(!r(b, a) && "WARNING (sparent) : a and b must be non-decreasing");
108 return r(c, b) ? select_1_2(a, c, r) : b;
109}
110
115template <typename T, typename R>
116inline T& select_1_3_ab(T& a, T& b, T& c, R r) {
117 assert(!r(b, a) && "WARNING (sparent) : a and b must be non-decreasing");
118 return r(c, b) ? select_1_2(a, c, r) : b;
119}
120
125template <typename T, typename R>
126inline const T& select_1_3(const T& a, const T& b, const T& c, R r) {
127 return r(b, a) ? select_1_3_ab(b, a, c, r) : select_1_3_ab(a, b, c, r);
128}
129
134template <typename T, typename R>
135inline T& select_1_3(T& a, T& b, T& c, R r) {
136 return r(b, a) ? select_1_3_ab(b, a, c, r) : select_1_3_ab(a, b, c, r);
137}
138
139/**************************************************************************************************/
140
141} // namespace adobe
142
143#endif
const T & select_1_3_ab(const T &a, const T &b, const T &c, R r)
select_1_ab implementation
const T & select_1_3_ac(const T &a, const T &b, const T &c, R r)
select_1_ab implementation
const T & select_1_3(const T &a, const T &b, const T &c, R r)
select_1 implementation
const T & select_0_2(const T &a, const T &b, R r)
select_0 implementation
const T & select_1_2(const T &a, const T &b, R r)
select_0 implementation