|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Reusable event-driven sweep line framework. More...
#include <geom_algorithms.H>
Classes | |
| struct | CmpSeqEvent |
| Comparator for SeqEvent, ensuring a strict weak ordering. More... | |
| struct | SeqEvent |
| Internal event wrapper that adds a sequence number for tie-breaking. More... | |
Public Member Functions | |
| void | enqueue (const Event &e) |
| Enqueue an event. | |
| void | enqueue (Event &&e) |
| Enqueue an event (move version). | |
| bool | has_events () const noexcept |
| True if the event queue is non-empty. | |
| size_t | pending () const noexcept |
| Number of pending events. | |
| Event | dequeue () |
| Remove and return the next (minimum) event. | |
| const Event & | peek () const |
| Peek at the next event without removing it. | |
| void | clear () noexcept |
| Discard all pending events. | |
| template<typename Handler > | |
| void | run (Handler &&handler) |
Run the sweep: process every event through handler. | |
| template<typename Handler > | |
| void | run (Handler &&handler, Array< Event > &out) |
Run the sweep, collecting every event into out. | |
Private Attributes | |
| DynSetTree< SeqEvent, Avl_Tree, CmpSeqEvent > | queue_ |
| size_t | seq_ = 0 |
Reusable event-driven sweep line framework.
This template manages an event queue backed by a balanced BST (DynSetTree<Avl_Tree>). The user supplies:
The framework does not own the sweep-line status structure — the handler is free to use whatever data structure is appropriate (array, BST, linked list, etc.).
run(): processes all events; total cost depends on the handler.| Event | Event payload type. |
| CmpEvent | Strict-weak-order comparator on Event. |
Definition at line 5741 of file geom_algorithms.H.
|
inlinenoexcept |
Discard all pending events.
Definition at line 5810 of file geom_algorithms.H.
References Aleph::LineSweepFramework< Event, CmpEvent >::queue_, and Aleph::LineSweepFramework< Event, CmpEvent >::seq_.
|
inline |
Remove and return the next (minimum) event.
Definition at line 5796 of file geom_algorithms.H.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::LineSweepFramework< Event, CmpEvent >::queue_.
Referenced by Aleph::LineSweepFramework< Event, CmpEvent >::run(), and Aleph::LineSweepFramework< Event, CmpEvent >::run().
|
inline |
Enqueue an event.
Definition at line 5772 of file geom_algorithms.H.
References Aleph::LineSweepFramework< Event, CmpEvent >::queue_, and Aleph::LineSweepFramework< Event, CmpEvent >::seq_.
Referenced by Aleph::SweepLineSegmentIntersection::operator()(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inline |
Enqueue an event (move version).
Definition at line 5778 of file geom_algorithms.H.
References Aleph::LineSweepFramework< Event, CmpEvent >::queue_, and Aleph::LineSweepFramework< Event, CmpEvent >::seq_.
|
inlinenoexcept |
True if the event queue is non-empty.
Definition at line 5784 of file geom_algorithms.H.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::LineSweepFramework< Event, CmpEvent >::queue_.
Referenced by Aleph::LineSweepFramework< Event, CmpEvent >::run(), and Aleph::LineSweepFramework< Event, CmpEvent >::run().
|
inline |
Peek at the next event without removing it.
Definition at line 5804 of file geom_algorithms.H.
References Aleph::LineSweepFramework< Event, CmpEvent >::queue_.
|
inlinenoexcept |
Number of pending events.
Definition at line 5790 of file geom_algorithms.H.
References Aleph::LineSweepFramework< Event, CmpEvent >::queue_.
|
inline |
Run the sweep: process every event through handler.
The handler signature must be compatible with:
The handler may call fw.enqueue() to schedule new events discovered during processing (e.g. intersection events).
Definition at line 5829 of file geom_algorithms.H.
References Aleph::LineSweepFramework< Event, CmpEvent >::dequeue(), and Aleph::LineSweepFramework< Event, CmpEvent >::has_events().
|
inline |
Run the sweep, collecting every event into out.
Each dequeued event is appended to out before the handler is invoked, providing a full processing log.
Definition at line 5842 of file geom_algorithms.H.
References Aleph::LineSweepFramework< Event, CmpEvent >::dequeue(), Aleph::divide_and_conquer_partition_dp(), and Aleph::LineSweepFramework< Event, CmpEvent >::has_events().
|
private |
Definition at line 5767 of file geom_algorithms.H.
Referenced by Aleph::LineSweepFramework< Event, CmpEvent >::clear(), Aleph::LineSweepFramework< Event, CmpEvent >::dequeue(), Aleph::LineSweepFramework< Event, CmpEvent >::enqueue(), Aleph::LineSweepFramework< Event, CmpEvent >::enqueue(), Aleph::LineSweepFramework< Event, CmpEvent >::has_events(), Aleph::LineSweepFramework< Event, CmpEvent >::peek(), and Aleph::LineSweepFramework< Event, CmpEvent >::pending().
|
private |
Definition at line 5768 of file geom_algorithms.H.
Referenced by Aleph::LineSweepFramework< Event, CmpEvent >::clear(), Aleph::LineSweepFramework< Event, CmpEvent >::enqueue(), and Aleph::LineSweepFramework< Event, CmpEvent >::enqueue().