template<typename T, index_t N, typename Object, typename NodeData>
class geom::KDTree< T, N, Object, NodeData >
A hierarchical spatial index.
- Template Parameters
-
T | Numeric type. |
N | Dimensionality of data. |
Object | Spatial object to be indexed. May be a Vec<T,N> , a Bounded<T,N> , or a std::pair<K,V> with K either of the former. |
NodeData | Optional data to store with each internal node of the tree. |
template<typename T, index_t N, typename Object, typename NodeData>
Return an iterator pointing at the root tree node. Use +i
and -i
to ascend and descend to the first-child and parent nodes respectively. ++i
and --i
navigate the tree in breadth-first order, and can therefore be used to find the next and previous siblings.
template<typename T, index_t N, typename Object, typename NodeData>
Return a const iterator pointing at the root tree node. Use +i
and -i
to ascend and descend to the first-child and parent nodes respectively. ++i
and --i
navigate the tree in breadth-first order, and can therefore be used to find the next and previous siblings.
template<typename T, index_t N, typename Object, typename NodeData>
Empty the given node of all its objects, and delete all its child nodes. Runs in O(n)
time on the node count of the emptied subtree.
Any iterators pointing to nodes or objects in the deleted subtree are invalidated.
template<typename T, index_t N, typename Object, typename NodeData>
Remove the given node, all of its children, and all the objects it contains. Runs in O(n)
time on the node count of the deleted subtree.
The root node cannot be erased. If it is passed as an argument, it is returned without deletion.
Any iterators pointing to this node, any of its descendents, or the objects contained therein are invalidated. If deleting this node leaves one remaining sibling, then the sibling will be absorbed into its parent and its iterator will be invalidated.
- Returns
- The node after the deleted node, in breadth-first order.
template<typename T, index_t N, typename Object, typename NodeData>
Remove the object at the given iterator from the given leaf node.
If the node is not a leaf or does not contain the object, no change is made and the original iterator is returned. Otherwise, an iterator to the next object is returned.
Both iterators may be invalidated by this operation.
template<typename T, index_t N, typename Object, typename NodeData>
Delete all the child nodes of the given node, and assign all the objects below to it. Runs in O(n)
time on the node count of the emptied subtree.
Any iterators pointing to nodes in the deleted subtree are invalidated.
template<typename T, index_t N, typename Object, typename NodeData>
Rebuild the given subtree according to its current balancing parameters, in O(n log(n))
time. If rebuilding from the root, it is more efficient to call rebalance()
with no args.
Any iterators pointing to descendents of the given node are invalidated.