1 #include <thrust/extrema.h>
2 
3 template <class Policy,
4           typename Container,
5           typename BinaryPredicate = thrust::less<typename Container::value_type> >
6 struct MinElement
7 {
8   Container A;
9   BinaryPredicate binary_pred;
10   Policy policy;
11 
12   template <typename Range>
13   MinElement(Policy policy_, const Range& X, BinaryPredicate binary_pred = BinaryPredicate())
14     : A(X.begin(), X.end()),
15       binary_pred(binary_pred),
16       policy(policy_)
17   {}
18 
operatorMinElement19   void operator()(void)
20   {
21     thrust::min_element(policy,A.begin(), A.end(), binary_pred);
22   }
23 };
24 
25 
26 template <class Policy,
27           typename Container,
28           typename BinaryPredicate = thrust::less<typename Container::value_type> >
29 struct MaxElement
30 {
31   Container A;
32   BinaryPredicate binary_pred;
33   Policy policy;
34 
35   template <typename Range>
36   MaxElement(Policy policy_, const Range& X, BinaryPredicate binary_pred = BinaryPredicate())
37     : A(X.begin(), X.end()),
38       binary_pred(binary_pred),
39       policy(policy_)
40   {}
41 
operatorMaxElement42   void operator()(void)
43   {
44     thrust::max_element(policy,A.begin(), A.end(), binary_pred);
45   }
46 };
47 
48 
49 template <class Policy,
50           typename Container,
51           typename BinaryPredicate = thrust::less<typename Container::value_type> >
52 struct MinMaxElement
53 {
54   Container A;
55   BinaryPredicate binary_pred;
56   Policy policy;
57 
58   template <typename Range>
59   MinMaxElement(Policy policy_, const Range& X, BinaryPredicate binary_pred = BinaryPredicate())
60     : A(X.begin(), X.end()),
61       binary_pred(binary_pred),
62       policy(policy_)
63   {}
64 
operatorMinMaxElement65   void operator()(void)
66   {
67     thrust::minmax_element(policy,A.begin(), A.end(), binary_pred);
68   }
69 };
70 
71