Class KdTreeNodeCollection<TNode>
Collection of k-dimensional tree nodes.
Namespace: Mars.Common.Collections
Assembly: Mars.Common.dll
Syntax
public class KdTreeNodeCollection<TNode> : ICollection<NodeDistance<TNode>> where TNode : KdTreeNodeBase<TNode>, IComparable<TNode>, IEquatable<TNode>
Type Parameters
Name | Description |
---|---|
TNode | The class type for the nodes of the tree. |
Remarks
This class is used to store neighbor nodes when running one of the
search algorithms for KdTree<T>.
Constructors
KdTreeNodeCollection(Int32)
Creates a new KdTreeNodeCollection<TNode> with a maximum size.
Declaration
public KdTreeNodeCollection(int size)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | size | The maximum number of elements allowed in this collection. |
Properties
Capacity
Gets or sets the maximum number of elements on this
collection, if specified. A value of zero indicates
this instance has no upper limit of elements.
Declaration
public int Capacity { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Count
Gets the number of elements in this collection.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Farthest
Gets the farthest node in the collection (with greatest distance).
Declaration
public TNode Farthest { get; }
Property Value
Type | Description |
---|---|
TNode |
IsReadOnly
Gets a value indicating whether this instance is read only.
For this collection, always returns false.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
true if this instance is read only; otherwise, false .
|
Item[Int32]
Gets the NodeDistance<TNode>
at the specified index. Note: this method will iterate over the entire collection
until the given position is found.
Declaration
public NodeDistance<TNode> this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type | Description |
---|---|
NodeDistance<TNode> |
Maximum
Gets the maximum distance between a node
in this collection and the query point.
Declaration
public double Maximum { get; }
Property Value
Type | Description |
---|---|
System.Double |
Minimum
Gets the minimum distance between a node
in this collection and the query point.
Declaration
public double Minimum { get; }
Property Value
Type | Description |
---|---|
System.Double |
Nearest
Gets the nearest node in the collection (with smallest distance).
Declaration
public TNode Nearest { get; }
Property Value
Type | Description |
---|---|
TNode |
Methods
Add(TNode, Double)
Attempts to add a value to the collection. If the list is full
and the value is more distant than the farthest node in the
collection, the value will not be added.
Declaration
public bool Add(TNode value, double distance)
Parameters
Type | Name | Description |
---|---|---|
TNode | value | The node to be added. |
System.Double | distance | The node distance. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the node has been added; false otherwise. |
Add(NodeDistance<TNode>)
Adds the specified item to this collection.
Declaration
public void Add(NodeDistance<TNode> item)
Parameters
Type | Name | Description |
---|---|---|
NodeDistance<TNode> | item | The item. |
AddFarthest(TNode, Double)
Attempts to add a value to the collection. If the list is full
and the value is more distant than the farthest node in the
collection, the value will not be added.
Declaration
public bool AddFarthest(TNode value, double distance)
Parameters
Type | Name | Description |
---|---|---|
TNode | value | The node to be added. |
System.Double | distance | The node distance. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the node has been added; false otherwise. |
Clear()
Removes all elements from this collection.
Declaration
public void Clear()
Contains(NodeDistance<TNode>)
Determines whether this instance contains the specified item.
Declaration
public bool Contains(NodeDistance<TNode> item)
Parameters
Type | Name | Description |
---|---|---|
NodeDistance<TNode> | item | The object to locate in the collection. The value can be null for reference types. |
Returns
Type | Description |
---|---|
System.Boolean |
true if the item is found in the collection; otherwise, false .
|
CopyTo(NodeDistance<TNode>[], Int32)
Copies the entire collection to a compatible one-dimensional , starting
at the specified
arrayIndex
of the
array
.
Declaration
public void CopyTo(NodeDistance<TNode>[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
NodeDistance<TNode>[] | array |
The one-dimensional |
System.Int32 | arrayIndex | The zero-based index in array at which copying begins. |
GetEnumerator()
Returns an enumerator that iterates through this collection.
Declaration
public IEnumerator<NodeDistance<TNode>> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<NodeDistance<TNode>> | An System.Collections.IEnumerator object that can be used to iterate through the collection. |
Remove(NodeDistance<TNode>)
Not supported.
Declaration
public bool Remove(NodeDistance<TNode> item)
Parameters
Type | Name | Description |
---|---|---|
NodeDistance<TNode> | item |
Returns
Type | Description |
---|---|
System.Boolean |
RemoveFarthest()
Removes the farthest tree node from this collection.
Declaration
public void RemoveFarthest()
RemoveNearest()
Removes the nearest tree node from this collection.
Declaration
public void RemoveNearest()
Extension Methods
See Also
KdTree<T>
NodeDistance<TNode>