39#include <gtest/gtest.h>
43#include <unordered_set>
205 for (
int i = 1; i <= 10; ++i)
274 std::vector<Point> points = {
279 for (
const auto & p : points)
286 for (
const auto & p : points)
359 std::mt19937
gen(12345);
360 std::uniform_real_distribution<>
dis(0, 1000);
363 std::vector<Point> points;
374 for (
const auto & p : points)
384 std::mt19937
gen(54321);
385 std::uniform_real_distribution<>
dis(0, 100);
387 const size_t cycles = 100;
392 std::vector<Point> points;
419 for (
int x = 40; x <= 60; ++x)
421 for (
int y = 40;
y <= 60; ++
y)
428 for (
int x = 40; x <= 60; ++x)
430 for (
int y = 40;
y <= 60; ++
y)
514 for (
int i = 0; i < 10; ++i)
519 size_t node_count = 0;
554 std::mt19937
gen(99999);
556 std::uniform_int_distribution<int>
coord_dis(0, 999);
557 std::uniform_int_distribution<>
op_dis(0, 2);
562 for (
int i = 0; i < 1000; ++i)
566 if (op == 0 || op == 1)
570 if (result !=
nullptr)
587 <<
"Point (" << p.get_x() <<
", " << p.get_y() <<
") should be in tree";
596 ::testing::InitGoogleTest(&
argc,
argv);
T & insert(const T &item)
Insert a new item by copy.
void empty() noexcept
empty the list
size_t size() const noexcept
Count the number of elements of the list.
Rectangular point in the plane.
Node for QuadTree spatial data structure.
Point * search_point(const Point &p) noexcept
Search for a point in this node.
bool is_leaf() const noexcept
Check if this node is a leaf (has no children).
QuadTree - Hierarchical spatial index for 2D points.
void empty(Node *&r) noexcept
Recursively delete all nodes.
void for_each(Op &op)
Apply an operation to each node in the tree.
void remove(const Point &p)
Remove a point from the tree.
Point * search(const Point &p) noexcept
Search for a point in the tree.
Node * search_container_node(const Point &p) noexcept
Find the leaf node containing a point.
bool contains(const Point &p) const noexcept
Check if a point is within the tree's region.
Point * insert(Node *&r, const Point &p)
Recursive insert helper.
size_t get_max_num_points_per_node() const noexcept
Get the maximum points per leaf node.
Node * get_root() noexcept
Get the root node.
iterator begin() noexcept
Return an STL-compatible iterator to the first element.
__gmp_expr< T, __gmp_binary_expr< __gmp_expr< T, U >, unsigned long int, __gmp_root_function > > root(const __gmp_expr< T, U > &expr, unsigned long int l)
static bool is_leaf(BinNode< std::string > *p) noexcept
DynList< T > maps(const C &c, Op op)
Classic map operation.
QuadTree spatial data structure for efficient 2D point indexing.
void test(unsigned long n, gsl_rng *r)