1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // This file was modified by Oracle on 2017.
6 // Modifications copyright (c) 2017, Oracle and/or its affiliates.
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
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)
14 #ifndef BOOST_GEOMETRY_POLICIES_COMPARE_HPP
15 #define BOOST_GEOMETRY_POLICIES_COMPARE_HPP
20 #include <boost/geometry/strategies/compare.hpp>
21 #include <boost/geometry/util/math.hpp>
24 namespace boost { namespace geometry
29 \brief Less functor, to sort points in ascending order.
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
41 typename Point = void,
46 typedef Point first_argument_type;
47 typedef Point second_argument_type;
48 typedef bool result_type;
50 inline bool operator()(Point const& left, Point const& right) const
52 typedef typename strategy::compare::services::default_strategy
54 strategy::compare::less,
57 >::type strategy_type;
59 return strategy_type::apply(left, right);
63 template <int Dimension>
64 struct less<void, Dimension>
66 template <typename Point1, typename Point2>
67 inline bool operator()(Point1 const& left, Point2 const& right) const
69 typedef typename strategy::compare::services::default_strategy
71 strategy::compare::less,
74 >::type strategy_type;
76 return strategy_type::apply(left, right);
82 \brief Greater functor
84 \details Can be used to sort points in reverse order
89 typename Point = void,
94 typedef Point first_argument_type;
95 typedef Point second_argument_type;
96 typedef bool result_type;
98 bool operator()(Point const& left, Point const& right) const
100 typedef typename strategy::compare::services::default_strategy
102 strategy::compare::greater,
105 >::type strategy_type;
107 return strategy_type::apply(left, right);
111 template <int Dimension>
112 struct greater<void, Dimension>
114 template <typename Point1, typename Point2>
115 bool operator()(Point1 const& left, Point2 const& right) const
117 typedef typename strategy::compare::services::default_strategy
119 strategy::compare::greater,
122 >::type strategy_type;
124 return strategy_type::apply(left, right);
130 \brief Equal To functor, to compare if points are equal
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
144 typedef Point first_argument_type;
145 typedef Point second_argument_type;
146 typedef bool result_type;
148 bool operator()(Point const& left, Point const& right) const
150 typedef typename strategy::compare::services::default_strategy
152 strategy::compare::equal_to,
155 >::type strategy_type;
157 return strategy_type::apply(left, right);
161 template <int Dimension>
162 struct equal_to<void, Dimension>
164 template <typename Point1, typename Point2>
165 bool operator()(Point1 const& left, Point2 const& right) const
167 typedef typename strategy::compare::services::default_strategy
169 strategy::compare::equal_to,
172 >::type strategy_type;
174 return strategy_type::apply(left, right);
179 }} // namespace boost::geometry
182 #endif // BOOST_GEOMETRY_POLICIES_COMPARE_HPP