1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2014, Oracle and/or its affiliates.
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
10 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_DUPLICATES_HPP
11 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_DUPLICATES_HPP
13 #include <boost/range.hpp>
15 #include <boost/geometry/core/closure.hpp>
17 #include <boost/geometry/policies/compare.hpp>
19 #include <boost/geometry/views/closeable_view.hpp>
22 namespace boost { namespace geometry
26 #ifndef DOXYGEN_NO_DETAIL
27 namespace detail { namespace is_valid
30 template <typename Range, closure_selector Closure>
33 static inline bool apply(Range const& range)
35 typedef typename closeable_view<Range const, Closure>::type view_type;
36 typedef typename boost::range_iterator<view_type const>::type iterator;
38 view_type view(range);
40 if ( boost::size(view) < 2 )
45 geometry::equal_to<typename boost::range_value<Range>::type> equal;
47 iterator it = boost::begin(view);
48 iterator next = ++boost::begin(view);
49 for (; next != boost::end(view); ++it, ++next)
51 if ( equal(*it, *next) )
62 }} // namespace detail::is_valid
63 #endif // DOXYGEN_NO_DETAIL
66 }} // namespace boost::geometry
70 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_DUPLICATES_HPP