SpiecsEngine
 
Loading...
Searching...
No Matches

◆ insert()

template<uint32_t K>
void scl::kd_tree< K >::insert ( const std::vector< item > & points)
inline

Insert a point into the kd_tree. Start at the root, comparing the new point’s first dimension with the root’s first dimension. If the new point’s value is less than the root’s, go to the left child; otherwise, go to the right child. At the next level, compare the second dimension. Continue this process, cycling through dimensions. When a leaf is reached, create a new node and insert the new point.

Parameters
[in]pointsInserted points in k d.

Definition at line 602 of file KDTree.h.

603 {
604 insert_recursive(m_Root, std::make_shared<std::vector<item>>(points), 0);
605 }
void insert_recursive(Node *&node, std::shared_ptr< std::vector< item > > points, int depth)
Recursive function to insert a point into the kd_tree.
Definition KDTree.h:241
Node * m_Root
Pointer to the root node of the tree.
Definition KDTree.h:76