• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 
3 // Copyright (c) 2015, Oracle and/or its affiliates.
4 
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
6 
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
9 
10 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SWEEP_HPP
11 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SWEEP_HPP
12 
13 #include <boost/core/ignore_unused.hpp>
14 
15 
16 namespace boost { namespace geometry
17 {
18 
19 #ifndef DOXYGEN_NO_DETAIL
20 namespace detail { namespace sweep
21 {
22 
23 struct no_interrupt_policy
24 {
25     static bool const enabled = false;
26 
27     template <typename Event>
applyboost::geometry::detail::sweep::no_interrupt_policy28     static inline bool apply(Event const&)
29     {
30         return false;
31     }
32 };
33 
34 }} // namespace detail::sweep
35 #endif // DOXYGEN_NO_DETAIL
36 
37 
38 template
39 <
40     typename Range,
41     typename PriorityQueue,
42     typename InitializationVisitor,
43     typename EventVisitor,
44     typename InterruptPolicy
45 >
sweep(Range const & range,PriorityQueue & queue,InitializationVisitor & initialization_visitor,EventVisitor & event_visitor,InterruptPolicy const & interrupt_policy)46 inline void sweep(Range const& range, PriorityQueue& queue,
47                   InitializationVisitor& initialization_visitor,
48                   EventVisitor& event_visitor,
49                   InterruptPolicy const& interrupt_policy)
50 {
51     typedef typename PriorityQueue::value_type event_type;
52 
53     initialization_visitor.apply(range, queue, event_visitor);
54     while (! queue.empty())
55     {
56         event_type event = queue.top();
57         queue.pop();
58         event_visitor.apply(event, queue);
59         if (interrupt_policy.enabled && interrupt_policy.apply(event))
60         {
61             break;
62         }
63     }
64 
65     boost::ignore_unused(interrupt_policy);
66 }
67 
68 
69 template
70 <
71     typename Range,
72     typename PriorityQueue,
73     typename InitializationVisitor,
74     typename EventVisitor
75 >
sweep(Range const & range,PriorityQueue & queue,InitializationVisitor & initialization_visitor,EventVisitor & event_visitor)76 inline void sweep(Range const& range, PriorityQueue& queue,
77                   InitializationVisitor& initialization_visitor,
78                   EventVisitor& event_visitor)
79 {
80     sweep(range, queue, initialization_visitor, event_visitor,
81           detail::sweep::no_interrupt_policy());
82 }
83 
84 
85 }} // namespace boost::geometry
86 
87 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_SWEEP_HPP
88