|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Static 2D range tree for orthogonal range queries. More...
#include <geom_algorithms.H>
Classes | |
| struct | DebugNode |
| Represents a node in the range tree for debugging. More... | |
| struct | DebugSnapshot |
| A complete snapshot of the range tree for debugging. More... | |
| struct | Node |
| Internal node structure containing the y-sorted secondary array. More... | |
Public Member Functions | |
| void | build (const DynList< Point > &points) |
| Build the range tree from a point set. | |
| DynList< Point > | query (const Geom_Number &xmin, const Geom_Number &xmax, const Geom_Number &ymin, const Geom_Number &ymax) const |
| Query: return all points inside [xmin,xmax] × [ymin,ymax]. | |
| size_t | size () const noexcept |
| bool | is_empty () const noexcept |
| DebugSnapshot | debug_snapshot () const |
| Return structural snapshot for visualization/debug. | |
Private Member Functions | |
| size_t | lower_bound_x (const Geom_Number &xval) const |
| Binary search: first index i in pts_ where pts_(i).get_x() >= xval. | |
| size_t | upper_bound_x (const Geom_Number &xval) const |
| Binary search: first index i in pts_ where pts_(i).get_x() > xval. | |
| void | build_node (const size_t node, const size_t lo, const size_t hi) |
| void | query_range (const size_t node, const size_t lo, const size_t hi, const size_t qlo, const size_t qhi, const Geom_Number &ymin, const Geom_Number &ymax, DynList< Point > &out) const |
Static Private Member Functions | |
| static size_t | lower_bound_y (const Array< Point > &arr, const Geom_Number &ymin) |
| Binary search: first index i in arr where arr(i).get_y() >= ymin. | |
| static size_t | upper_bound_y (const Array< Point > &arr, const Geom_Number &ymax) |
| Binary search: first index i in arr where arr(i).get_y() > ymax. | |
Private Attributes | |
| Array< Point > | pts_ |
| points sorted by x (primary key) | |
| Array< Node > | tree_ |
| implicit binary tree (1-indexed) | |
| size_t | n_ = 0 |
| bool | built_ = false |
Static 2D range tree for orthogonal range queries.
Supports axis-aligned rectangle queries: given [xmin,xmax] × [ymin,ymax], find all points inside.
Definition at line 8603 of file geom_algorithms.H.
Build the range tree from a point set.
Definition at line 8753 of file geom_algorithms.H.
References Aleph::and, build_node(), built_, Aleph::divide_and_conquer_partition_dp(), Aleph::Point::get_x(), Aleph::Point::get_y(), Aleph::HTList::Iterator::has_curr(), n_, pts_, Aleph::quicksort_op(), and tree_.
Referenced by main(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inlineprivate |
Definition at line 8696 of file geom_algorithms.H.
References Aleph::and, build_node(), Aleph::divide_and_conquer_partition_dp(), pts_, and tree_.
Referenced by build(), and build_node().
|
inline |
Return structural snapshot for visualization/debug.
Definition at line 8806 of file geom_algorithms.H.
References built_, Aleph::divide_and_conquer_partition_dp(), Aleph::RangeTree2D::DebugNode::hi, Aleph::RangeTree2D::DebugNode::is_leaf, Aleph::RangeTree2D::DebugNode::left, Aleph::RangeTree2D::DebugNode::lo, n_, pts_, Aleph::RangeTree2D::DebugNode::right, Aleph::RangeTree2D::DebugNode::split_x, tree_, Aleph::RangeTree2D::DebugNode::tree_index, Aleph::RangeTree2D::DebugSnapshot::x_sorted_points, Aleph::RangeTree2D::DebugNode::xmax, Aleph::RangeTree2D::DebugNode::xmin, and Aleph::RangeTree2D::DebugNode::y_sorted_size.
Referenced by TEST_F(), Aleph::visualize_range_tree(), and Aleph::visualize_range_tree_query().
|
inlinenoexcept |
|
inlineprivate |
Binary search: first index i in pts_ where pts_(i).get_x() >= xval.
Definition at line 8673 of file geom_algorithms.H.
References Aleph::divide_and_conquer_partition_dp(), n_, and pts_.
Referenced by query().
|
inlinestaticprivate |
Binary search: first index i in arr where arr(i).get_y() >= ymin.
Definition at line 8647 of file geom_algorithms.H.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::Array< T >::size().
Referenced by query_range().
|
inline |
Query: return all points inside [xmin,xmax] × [ymin,ymax].
Definition at line 8783 of file geom_algorithms.H.
References built_, Aleph::divide_and_conquer_partition_dp(), lower_bound_x(), n_, query_range(), and upper_bound_x().
Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and Aleph::visualize_range_tree_query().
|
inlineprivate |
Definition at line 8728 of file geom_algorithms.H.
References Aleph::and, Aleph::divide_and_conquer_partition_dp(), lower_bound_y(), query_range(), tree_, and upper_bound_y().
Referenced by query(), and query_range().
|
inlinenoexcept |
|
inlineprivate |
Binary search: first index i in pts_ where pts_(i).get_x() > xval.
Definition at line 8685 of file geom_algorithms.H.
References Aleph::divide_and_conquer_partition_dp(), n_, and pts_.
Referenced by query().
|
inlinestaticprivate |
Binary search: first index i in arr where arr(i).get_y() > ymax.
Definition at line 8660 of file geom_algorithms.H.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::Array< T >::size().
Referenced by query_range().
Definition at line 8644 of file geom_algorithms.H.
Referenced by build(), debug_snapshot(), and query().
|
private |
Definition at line 8643 of file geom_algorithms.H.
Referenced by build(), debug_snapshot(), is_empty(), lower_bound_x(), query(), size(), and upper_bound_x().
points sorted by x (primary key)
Definition at line 8641 of file geom_algorithms.H.
Referenced by build(), build_node(), debug_snapshot(), lower_bound_x(), and upper_bound_x().
implicit binary tree (1-indexed)
Definition at line 8642 of file geom_algorithms.H.
Referenced by build(), build_node(), debug_snapshot(), and query_range().