A C++ implementation of QuadTree Data Structure. Old tests and other form of implementations (less performance) can be found in "refs" directory.
Please see .cpp
and .h
file for latest updates and more information as README might not be up to date.
Quadtree Iterator is not yet implemented
T
is a data type;
Vertex
is a custom class, which is an alias of Vec2<long double>
with vector and scalar operations and comparators.
PairT
is std::pair<Vertex, T>
.
ContainerT
is std::vector<PairT>
, for storing points and data in Tree Nodes.
QuadTree<T, PairT, ContainerT>(Vertex m_center = Vertex{0, 0},
Vertex m_range = Vertex{1, 1},
unsigned bucket_size = 1,
unsigned depth = 16,
bool sort = false);
The constructor has default parameters in it. Set each field if you want to increase its performance and features (sort within region).
bool insert(const Vertex &point, const T &data);
bool update(const Vertex &point, const T &data);
bool contains(const Vertex &point);
bool remove(const Vertex &point);
std::vector<std::pair<Vertex, T>> extract();
std::vector<std::pair<Vertex, T>> data_in_region(const Vertex &bottom_left, const Vertex &top_right);
void print_preorder()
void print_data()