Class KdTree
Convenience class for k-dimensional tree static methods. To
create a new KdTree, specify the generic parameter as in
KdTree<T>.
Inheritance
Mars.Common.Core.Collections.SimpleTree.BinaryTree<
KdTreeNode>
KdTree
Inherited Members
KdTreeBase<KdTreeNode>.Nearest<T1, T2, T3>(Double[], Double, Int32, Func<KdTreeNode, T1, T2, T3, Boolean>, T1, T2, T3)
Mars.Common.Core.Collections.SimpleTree.BinaryTree<Mars.Common.Collections.KdTreeNode>.Root
Mars.Common.Core.Collections.SimpleTree.BinaryTree<Mars.Common.Collections.KdTreeNode>.GetEnumerator()
Mars.Common.Core.Collections.SimpleTree.BinaryTree<Mars.Common.Collections.KdTreeNode>.SerializeJson()
Mars.Common.Core.Collections.SimpleTree.BinaryTree<Mars.Common.Collections.KdTreeNode>.Deserialize(System.String)
Mars.Common.Core.Collections.SimpleTree.BinaryTree<Mars.Common.Collections.KdTreeNode>.Traverse(Mars.Common.Core.Collections.SimpleTree.BinaryTraversalMethod<Mars.Common.Collections.KdTreeNode>)
Assembly: Mars.Common.dll
Syntax
public class KdTree : KdTreeBase<KdTreeNode>
Constructors
KdTree(Int32)
Declaration
public KdTree(int dimensions)
Parameters
Type |
Name |
Description |
System.Int32 |
dimensions |
The number of dimensions in the tree. |
KdTree(Int32, KdTreeNode)
Declaration
public KdTree(int dimension, KdTreeNode root)
Parameters
Type |
Name |
Description |
System.Int32 |
dimension |
The number of dimensions in the tree. |
KdTreeNode |
root |
The root node, if already existent. |
KdTree(Int32, KdTreeNode, Int32, Int32)
Declaration
public KdTree(int dimension, KdTreeNode root, int count, int leaves)
Parameters
Type |
Name |
Description |
System.Int32 |
dimension |
The number of dimensions in the tree. |
KdTreeNode |
root |
The root node, if already existent. |
System.Int32 |
count |
The number of elements in the root node. |
System.Int32 |
leaves |
The number of leaves linked through the root node. |
Methods
Add(Position)
Declaration
public void Add(Position position)
Parameters
Type |
Name |
Description |
Position |
position |
A Position with respective coordinate, geospatial or not |
Add(Double[])
Adds a new point to this tree.
Declaration
public void Add(double[] position)
Parameters
Type |
Name |
Description |
System.Double[] |
position |
A double-vector with the same number of elements as dimensions in the tree. |
FromData(Double[][], IMetric<Double[]>, Boolean)
Creates a new k-dimensional tree from the given points.
Declaration
public static KdTree FromData(double[][] points, IMetric<double[]> distance, bool inPlace = false)
Parameters
Type |
Name |
Description |
System.Double[][] |
points |
The points to be added to the tree. |
IMetric<System.Double[]> |
distance |
The distance function to use. |
System.Boolean |
inPlace |
Whether the given points vector
can be ordered in place. Passing true will change the original order of
the vector. If set to false, all operations will be performed on an extra
copy of the vector.
|
Returns
FromData(Double[][], Boolean)
Creates a new k-dimensional tree from the given points.
Declaration
public static KdTree FromData(double[][] points, bool inPlace = false)
Parameters
Type |
Name |
Description |
System.Double[][] |
points |
The points to be added to the tree. |
System.Boolean |
inPlace |
Whether the given points vector
can be ordered in place. Passing true will change the original order of
the vector. If set to false, all operations will be performed on an extra
copy of the vector.
|
Returns
FromData<T>(Double[][], T[], IMetric<Double[]>, Boolean)
Creates a new k-dimensional tree from the given points.
Declaration
public static KdTree<T> FromData<T>(double[][] points, T[] values, IMetric<double[]> distance, bool inPlace = false)
Parameters
Type |
Name |
Description |
System.Double[][] |
points |
The points to be added to the tree. |
T[] |
values |
The corresponding values at each data point. |
IMetric<System.Double[]> |
distance |
The distance function to use. |
System.Boolean |
inPlace |
Whether the given points vector
can be ordered in place. Passing true will change the original order of
the vector. If set to false, all operations will be performed on an extra
copy of the vector.
|
Returns
Type |
Description |
KdTree<T> |
A KdTree<T> populated with the given data points. |
Type Parameters
Name |
Description |
T |
The type of the value to be stored. |
FromData<T>(Double[][], T[], Boolean)
Creates a new k-dimensional tree from the given points.
Declaration
public static KdTree<T> FromData<T>(double[][] points, T[] values, bool inPlace = false)
Parameters
Type |
Name |
Description |
System.Double[][] |
points |
The points to be added to the tree. |
T[] |
values |
The corresponding values at each data point. |
System.Boolean |
inPlace |
Whether the given points vector
can be ordered in place. Passing true will change the original order of
the vector. If set to false, all operations will be performed on an extra
copy of the vector.
|
Returns
Type |
Description |
KdTree<T> |
A KdTree<T> populated with the given data points. |
Type Parameters
Name |
Description |
T |
The type of the value to be stored. |
FromData<T>(Double[][], IMetric<Double[]>, Boolean)
Creates a new k-dimensional tree from the given points.
Declaration
public static KdTree<T> FromData<T>(double[][] points, IMetric<double[]> distance, bool inPlace = false)
Parameters
Type |
Name |
Description |
System.Double[][] |
points |
The points to be added to the tree. |
IMetric<System.Double[]> |
distance |
The distance function to use. |
System.Boolean |
inPlace |
Whether the given points vector
can be ordered in place. Passing true will change the original order of
the vector. If set to false, all operations will be performed on an extra
copy of the vector.
|
Returns
Type |
Description |
KdTree<T> |
A KdTree<T> populated with the given data points. |
Type Parameters
Name |
Description |
T |
The type of the value to be stored. |
FromData<T>(Double[][], Boolean)
Creates a new k-dimensional tree from the given points.
Declaration
public static KdTree<T> FromData<T>(double[][] points, bool inPlace = false)
Parameters
Type |
Name |
Description |
System.Double[][] |
points |
The points to be added to the tree. |
System.Boolean |
inPlace |
Whether the given points vector
can be ordered in place. Passing true will change the original order of
the vector. If set to false, all operations will be performed on an extra
copy of the vector.
|
Returns
Type |
Description |
KdTree<T> |
A KdTree<T> populated with the given data points. |
Type Parameters
Name |
Description |
T |
The type of the value to be stored. |
FromData2D<T>(Double[][], T[], Boolean)
Creates a new 2-dimensional tree from the given points.
Declaration
public static K2DTree<T> FromData2D<T>(double[][] points, T[] values, bool inPlace = false)
Parameters
Type |
Name |
Description |
System.Double[][] |
points |
The 2-dimensional points to be added to the tree. |
T[] |
values |
The corresponding values at each data point. |
System.Boolean |
inPlace |
Whether the given points vector
can be ordered in place. Passing true will change the original order of
the vector. If set to false, all operations will be performed on an extra
copy of the vector.
|
Returns
Type Parameters
Name |
Description |
T |
The type of the value to be stored. |
Extension Methods
See Also