35#include <gtest/gtest.h>
61 Point pt(
const int x,
const int y)
66 template <
typename Tree>
74 template <
typename Tree>
86 for (
const auto &[b,
id] : ref)
97 for (
const auto &[b,
id] : ref)
104 struct CopyConstructibleNonCopyAssignablePayload
108 CopyConstructibleNonCopyAssignablePayload() =
default;
109 explicit CopyConstructibleNonCopyAssignablePayload(
const int v) :
value(v) {}
111 CopyConstructibleNonCopyAssignablePayload(
112 const CopyConstructibleNonCopyAssignablePayload &) =
default;
113 CopyConstructibleNonCopyAssignablePayload(
116 CopyConstructibleNonCopyAssignablePayload &
operator = (
117 const CopyConstructibleNonCopyAssignablePayload &) =
delete;
118 CopyConstructibleNonCopyAssignablePayload &
operator = (
180 for (
int i = 0; i < 200; ++i)
189 for (
int i = 0; i < 200; ++i)
207 for (
int i = 0; i < 200; ++i)
233 for (
int i = 0; i < 20; ++i)
252 for (
int i = 0; i < 30; ++i)
254 for (
int i = 0; i < 30; ++i)
269 for (
int i = 0; i < 50; ++i)
277 for (
int i = 0; i < 25; ++i)
291 for (
int i = 0; i < 30; ++i)
304 for (
int i = 0; i < 20; ++i)
305 tree.
insert(
rect(i, i, i + 1, i + 1), std::make_unique<int>(i));
313 [&](
const Rectangle &,
const std::unique_ptr<int> &v)
324 using Payload = CopyConstructibleNonCopyAssignablePayload;
347 for (
int i = 0; i < 90; ++i)
349 const Rectangle b =
rect(i % 15, i / 15, i % 15 + 2, i / 15 + 2);
351 ref.
append(std::make_pair(b, i));
360 for (
int i = 0; i < 30; ++i)
379 for (
const auto &[b,
id] : ref)
390 std::mt19937
rng(20260714u);
391 std::uniform_int_distribution<int>
op_dist(0, 2);
392 std::uniform_int_distribution<int> coord(0, 80);
393 std::uniform_int_distribution<int> extent(0, 12);
401 const int x1 = coord(
rng);
402 const int y1 = coord(
rng);
414 ref.
append(std::make_pair(b,
id));
418 std::uniform_int_distribution<size_t> pick(0, ref.
size() - 1);
419 const size_t k = pick(
rng);
421 std::swap(ref(
k), ref(ref.
size() - 1));
437 for (
int x = 0; x < 90; x += 7)
438 for (
int y = 0;
y < 90;
y += 7)
High-level sorting functions for Aleph containers.
size_t size_t int32_t value
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.
Array< Payload > search_intersects(const Rectangle &rect) const
Return the payloads of every entry whose bbox intersects rect.
Array< Payload > search_contains(const Point &p) const
Return the payloads of every entry whose bbox contains p.
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.
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.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
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)
Dynamic R-tree spatial index over axis-aligned rectangles.