Class STreeNode<TBound, TItem>

Namespace
Elegy.Common.SpatialCollections
Assembly
Elegy.Common.dll

N-dimensional tree node, stores a list of TItems from its parent tree that intersect with its TBound.

public class STreeNode<TBound, TItem> where TBound : struct

Type Parameters

TBound

For example: Box3 or Rect2.

TItem

For example: Vector3 or anything, really!

Inheritance
STreeNode<TBound, TItem>
Inherited Members

Constructors

STreeNode(TBound, int)

The constructor of this tree node.

public STreeNode(TBound bound, int dimensions)

Parameters

bound TBound

The bounding volume to bind a subset of items to.

dimensions int

Dimensionality of the tree. (2 or 3 usually)

Properties

Bound

The bounding volume of this node.

public TBound Bound { get; }

Property Value

TBound

Children

This node's children.

public STreeNode<TBound, TItem>[] Children { get; }

Property Value

STreeNode<TBound, TItem>[]

Combinations

How many child nodes there can be.

public int Combinations { get; }

Property Value

int

Dimensions

The dimensionality of this node.

public int Dimensions { get; }

Property Value

int

ItemIndices

The items of this node.

public IReadOnlyList<int> ItemIndices { get; }

Property Value

IReadOnlyList<int>

NumItems

Number of items currently linked to this node.

public int NumItems { get; }

Property Value

int

Methods

Add(int, bool)

Adds an item to the node. The unique parameter can affect performance and is needless if your indices are guaranteed to be unique.

public void Add(int itemIndex, bool unique = false)

Parameters

itemIndex int
unique bool

CreateChildren(List<STreeNode<TBound, TItem>>, GetChildVolumeFn)

Creates children for this node, not recursive though!

public void CreateChildren(List<STreeNode<TBound, TItem>> treeNodes, STree<TBound, TItem>.GetChildVolumeFn boundSubdivisionMethod)

Parameters

treeNodes List<STreeNode<TBound, TItem>>
boundSubdivisionMethod STree<TBound, TItem>.GetChildVolumeFn

ForEachChildNode(Action<STreeNode<TBound, TItem>>)

Executes the method for each child node.

public void ForEachChildNode(Action<STreeNode<TBound, TItem>> method)

Parameters

method Action<STreeNode<TBound, TItem>>

ForEachItem(IReadOnlyList<TItem>, Action<TItem>)

Executes the method for each item.

public void ForEachItem(IReadOnlyList<TItem> treeItems, Action<TItem> method)

Parameters

treeItems IReadOnlyList<TItem>
method Action<TItem>

IsEmpty()

Returns whether this node is empty.

public bool IsEmpty()

Returns

bool

IsLeaf()

Returns whether this node is a leaf or not.

public bool IsLeaf()

Returns

bool