]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/policies/compare.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / geometry / policies / compare.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4
5 // This file was modified by Oracle on 2017.
6 // Modifications copyright (c) 2017, Oracle and/or its affiliates.
7
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
13
14 #ifndef BOOST_GEOMETRY_POLICIES_COMPARE_HPP
15 #define BOOST_GEOMETRY_POLICIES_COMPARE_HPP
16
17
18 #include <cstddef>
19
20 #include <boost/geometry/strategies/compare.hpp>
21 #include <boost/geometry/util/math.hpp>
22
23
24 namespace boost { namespace geometry
25 {
26
27
28 /*!
29 \brief Less functor, to sort points in ascending order.
30 \ingroup compare
31 \details This functor compares points and orders them on x,
32 then on y, then on z coordinate.
33 \tparam Point the geometry
34 \tparam Dimension the dimension to sort on, defaults to -1,
35 indicating ALL dimensions. That's to say, first on x,
36 on equal x-es then on y, etc.
37 If a dimension is specified, only that dimension is considered
38 */
39 template
40 <
41 typename Point = void,
42 int Dimension = -1
43 >
44 struct less
45 {
46 typedef Point first_argument_type;
47 typedef Point second_argument_type;
48 typedef bool result_type;
49
50 inline bool operator()(Point const& left, Point const& right) const
51 {
52 typedef typename strategy::compare::services::default_strategy
53 <
54 strategy::compare::less,
55 Point, Point,
56 Dimension
57 >::type strategy_type;
58
59 return strategy_type::apply(left, right);
60 }
61 };
62
63 template <int Dimension>
64 struct less<void, Dimension>
65 {
66 template <typename Point1, typename Point2>
67 inline bool operator()(Point1 const& left, Point2 const& right) const
68 {
69 typedef typename strategy::compare::services::default_strategy
70 <
71 strategy::compare::less,
72 Point1, Point2,
73 Dimension
74 >::type strategy_type;
75
76 return strategy_type::apply(left, right);
77 }
78 };
79
80
81 /*!
82 \brief Greater functor
83 \ingroup compare
84 \details Can be used to sort points in reverse order
85 \see Less functor
86 */
87 template
88 <
89 typename Point = void,
90 int Dimension = -1
91 >
92 struct greater
93 {
94 typedef Point first_argument_type;
95 typedef Point second_argument_type;
96 typedef bool result_type;
97
98 bool operator()(Point const& left, Point const& right) const
99 {
100 typedef typename strategy::compare::services::default_strategy
101 <
102 strategy::compare::greater,
103 Point, Point,
104 Dimension
105 >::type strategy_type;
106
107 return strategy_type::apply(left, right);
108 }
109 };
110
111 template <int Dimension>
112 struct greater<void, Dimension>
113 {
114 template <typename Point1, typename Point2>
115 bool operator()(Point1 const& left, Point2 const& right) const
116 {
117 typedef typename strategy::compare::services::default_strategy
118 <
119 strategy::compare::greater,
120 Point1, Point2,
121 Dimension
122 >::type strategy_type;
123
124 return strategy_type::apply(left, right);
125 }
126 };
127
128
129 /*!
130 \brief Equal To functor, to compare if points are equal
131 \ingroup compare
132 \tparam Geometry the geometry
133 \tparam Dimension the dimension to compare on, defaults to -1,
134 indicating ALL dimensions.
135 If a dimension is specified, only that dimension is considered
136 */
137 template
138 <
139 typename Point,
140 int Dimension = -1
141 >
142 struct equal_to
143 {
144 typedef Point first_argument_type;
145 typedef Point second_argument_type;
146 typedef bool result_type;
147
148 bool operator()(Point const& left, Point const& right) const
149 {
150 typedef typename strategy::compare::services::default_strategy
151 <
152 strategy::compare::equal_to,
153 Point, Point,
154 Dimension
155 >::type strategy_type;
156
157 return strategy_type::apply(left, right);
158 }
159 };
160
161 template <int Dimension>
162 struct equal_to<void, Dimension>
163 {
164 template <typename Point1, typename Point2>
165 bool operator()(Point1 const& left, Point2 const& right) const
166 {
167 typedef typename strategy::compare::services::default_strategy
168 <
169 strategy::compare::equal_to,
170 Point1, Point2,
171 Dimension
172 >::type strategy_type;
173
174 return strategy_type::apply(left, right);
175 }
176 };
177
178
179 }} // namespace boost::geometry
180
181
182 #endif // BOOST_GEOMETRY_POLICIES_COMPARE_HPP