KDTreeNode

class KDTreeNode<T>(val dimensions: Int, val mapper: (T, Int) -> Double)(source)

Represents a node in a KD-Tree, a data structure for organizing points in a k-dimensional space.

Parameters

T

The type of the items stored in the KD-Tree.

Constructors

Link copied to clipboard
constructor(dimensions: Int, mapper: (T, Int) -> Double)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The number of dimensions for the tree.

Link copied to clipboard
var item: T?
Link copied to clipboard
val mapper: (T, Int) -> Double

A function that extracts a coordinate value for a specific dimension from a data item.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun findAllInRadius(query: T, radius: Double, includeQuery: Boolean = false): List<T>

Retrieves all items within a specified radius around a query point in the KD-Tree.

Link copied to clipboard
fun findKNearest(query: T, k: Int, includeQuery: Boolean = false): List<T>

Finds the k-nearest neighbors to a given query point within the KD-Tree.

Link copied to clipboard
fun findNearest(query: T, includeQuery: Boolean = false): T?

Finds the nearest neighbor to the given query within the KD-Tree.

Link copied to clipboard
fun insert(item: T): KDTreeNode<T>

Inserts an item into the KD-Tree.

Link copied to clipboard
fun remove(node: KDTreeNode<T>): KDTreeNode<T>?

Removes a specified KDTreeNode from the KD-Tree.

Link copied to clipboard
open override fun toString(): String