SpiecsEngine
 
Loading...
Searching...
No Matches

◆ search_recursive()

template<uint32_t K>
bool scl::kd_tree< K >::search_recursive ( Node * node,
const item & point,
int depth ) const
inlineprivate

Recursive function to search for a point in the kd_tree.

Parameters
[in]noderecursive node.
[in]pointSearched point in k d.
[in]depthrecursive depth.
Returns
Returns true if found.

Base case: If node is null, the point is not found.

If the current node matches the point, return true.

Calculate current dimension (cd).

Compare point with current node and decide to go left or right.

Definition at line 421 of file KDTree.h.

427 {
431 if (node == nullptr)
432 {
433 return false;
434 }
435
439 if (node->m_Point == point)
440 {
441 return true;
442 }
443
447 int cd = depth % K;
448
452 if (point[cd] < node->m_Point[cd])
453 {
454 return search_recursive(node->m_Left, point, depth + 1);
455 }
456 else
457 {
458 return search_recursive(node->m_Right, point, depth + 1);
459 }
460 }
bool search_recursive(Node *node, const item &point, int depth) const
Recursive function to search for a point in the kd_tree.
Definition KDTree.h:421

References scl::kd_tree< K >::search_recursive().

Referenced by scl::kd_tree< K >::search(), and scl::kd_tree< K >::search_recursive().