Documentation
¶
Overview ¶
Package node implements a K-D tree node.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type N ¶
type N struct {
// contains filtered or unexported fields
}
N represents a K-D tree node. Child nodes are sorted along the same axis, with coordinates in the left node preceeding right node coordinates (along the given axis).
func (*N) Axis ¶
Axis is the discriminant dimension for this tree node -- if the node is split on the X-axis, then all points with X-coordinates less than the node value will be in the left child (and vice versa for the right).
func (*N) Child ¶
Child is the appropriately expanded child node given the input coordinates -- that is, this function wraps the normal branching pattern for e.g. search operations.
func (*N) L ¶
L is the meaningful left child node of the current node.
This function returns nil if the left subtree does not encapsulate data.
func (*N) P ¶ added in v0.2.0
P is the point in the K-dimensional ambient space to which this node is embedded. All data in this node are located at the same spacial coordinate, within a small margin of error.
func (*N) R ¶
R is the meaningful right child node of the current node.
This function returns nil if the right subtree does not encapsulate data.
func (*N) Remove ¶
Remove deletes a data point from the node or child nodes. A returned value of false indicates the given point was not found.
N.B.: Remove does not actually delete the underlying K-D tree node. Manually removing and shifting the nodes is a non-trivial task. We generally expect these trees to be relatively stable once created, and that insert and remove operations are kept at a minimum.