35#include <gtest/gtest.h>
58 Point pt(
const int x,
const int y)
63 template <
typename Tree>
75 for (
const auto &[b,
id] : ref)
86 for (
const auto &[b,
id] : ref)
93 template <
typename Tree>
102 template <
size_t Max,
size_t Min>
107 std::uniform_int_distribution<int>
op_dist(0, 2);
108 std::uniform_int_distribution<int> coord(0,
space);
109 std::uniform_int_distribution<int> extent(0,
ext);
117 const int x1 = coord(
rng);
118 const int y1 = coord(
rng);
130 ref.
append(std::make_pair(b,
id));
134 std::uniform_int_distribution<size_t> pick(0, ref.
size() - 1);
135 const size_t k = pick(
rng);
137 std::swap(ref(
k), ref(ref.
size() - 1));
152 for (
int x = 0; x <=
space; x += 9)
189 for (
int i = 0; i < 500; ++i)
191 tree.
insert(
rect(i % 50, i / 50, i % 50 + 3, i / 50 + 3), i);
198 for (
int i = 0; i < 500; ++i)
200 const Rectangle b =
rect(i % 50, i / 50, i % 50 + 3, i / 50 + 3);
209 for (
int i = 0; i < 500; ++i)
210 tree.
insert(
rect(i % 50, i / 50, i % 50 + 3, i / 50 + 3), i);
222 for (
int i = 0; i < 25; ++i)
235 for (
int i = 0; i < 40; ++i)
237 for (
int i = 0; i < 20; ++i)
250 for (
int i = 0; i < 60; ++i)
256 for (
int i = 0; i < 30; ++i)
269 copy.insert(
rect(-5, -5, -4, -4), -5);
277 for (
int i = 0; i < 40; ++i)
278 tree.
insert(
rect(i, i, i + 1, i + 1), std::make_unique<int>(i));
284 [&](
const Rectangle &,
const std::unique_ptr<int> &) { ++
seen; });
292 for (
int i = 0; i < 100; ++i)
294 const Rectangle b =
rect(i % 20, i / 20, i % 20 + 3, i / 20 + 2);
296 ref.
append(std::make_pair(b, i));
317 for (
const auto &[b,
id] : ref)
High-level sorting functions for Aleph containers.
size_t size_t int32_t * out
Simple dynamic array with automatic resizing and functional operations.
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
constexpr bool is_empty() const noexcept
Checks if the container is empty.
T & append(const T &data)
Append a copy of data
Represents a point with rectangular coordinates in a 2D plane.
Dynamic R-tree indexing axis-aligned rectangles by payload.
DebugSnapshot debug_snapshot() const
Capture the full tree structure for visualization/debugging.
void insert(const Rectangle &bbox, const Payload &value)
Insert a (bbox, value) entry, copying value.
bool erase(const Rectangle &bbox, const Payload &value)
Remove one entry equal to (bbox, value).
size_t height() const noexcept
Return the number of node levels (0 when empty, 1 for a lone leaf).
bool is_empty() const noexcept
Return true when the tree has no entries.
size_t size() const noexcept
Return the number of stored entries.
void for_each_intersecting(const Rectangle &rect, F &&f) const
Invoke f for every entry whose bbox intersects rect.
bool verify() const
Verify the R-tree structural invariants.
void clear() noexcept
Remove all entries.
An axis-aligned rectangle.
QuadTree - Hierarchical spatial index for 2D points.
iterator end() noexcept
Return an STL-compatible end iterator.
iterator begin() noexcept
Return an STL-compatible iterator to the first element.
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_y1_function > > y1(const __gmp_expr< T, U > &expr)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
size_t check_snapshot_node(const Snapshot &snap, const size_t idx, const size_t expected_depth)
Recursively validates the structural invariants of a DebugSnapshot produced by RTree::debug_snapshot(...
Main namespace for Aleph-w library functions.
size_t size(Node *root) noexcept
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
bool contains(const std::string_view &str, const std::string_view &substr)
Check if substr appears inside str.
DynArray< T > & in_place_sort(DynArray< T > &c, Cmp cmp=Cmp())
Sorts a DynArray in place.
mpq_class Geom_Number
Numeric type used by the geometry module.
Shared DebugSnapshot structural-invariant checker for RTree and RStarTree unit tests.
static Rectangle box(const int x1, const int y1, const int x2, const int y2)
R*-tree: an R-tree tuned with the Beckmann-Kriegel-Schneider-Seeger heuristics.