Hierarchy

Hierarchy is a public generic class in the SMLimitless Namespace. It is a collection type that contains a single generic member, a reference to the parent Hierarchy, and a List, making this collection recursive.

Data
The data of type T in this node.

Parent
The parent node of this one, assigned when Add is called on the parent.

Children
A list of all the child nodes owned by this one.

Constructor
Constructs a new Hierarchy instance with the data. There is no set parent until this node is added to another.

Add
Adds a node to this node's children, and sets this node as the parent.

Add
Creates and returns a new node with the data, and also adds it to this node's children using the above method.

Remove
Removes the specified node. If the node is not found within the child nodes, an Exception is thrown.

GetDepth
Gets the number of levels of nodes at this level in the hierarchy. Returns 0 if there are no children. This method acts recursively.

Search
Searches a hierarchy for the given data. Returns either the node containing this data, or null if the data was not found. This method acts recursively.