SerializableTreeBase< T >.Node Class Reference

The Node class, is the runtime Node used by the tree that has references to children and parent. This class is declared INSIDE the Serializable tree because it references T. It contains reference to it's parent and data, as well as Enumerators to iterate though descendants. This class is NOT serializable.

Classes

class  AllDecendantsByLevelEnumerator
 A NodeEnumberator that iterates though all the descendants of a node. First it will loop through all children, then all grand children, then all great-grandchildren, etc...
 
class  AllDecendantsEnumerator
 A NodeEnumberator that iterates though all the descendants of a node, before moving on to siblings.
 
class  LeavesOnlyEnumerator
 A NodeEnumberator that iterates though all the leaves (childless-descendants) of a node, before moving on to siblings.
 
class  NodeAndAllDecendantsByLevelEnumerator
 A NodeEnumberator that iterates though the node itself, and all it's descendants. First it will loop through all children, then all grand children, then all great-grandchildren, etc...
 
class  NodeAndAllDecendantsEnumerator
 A NodeEnumberator that iterates though the node itself, and all it's descendants, before moving on to siblings.
 
class  NodeAndChildrenEnumerator
 A NodeEnumberator that iterates though the node itself, and all it's children. It will not iterate any further/deeper than children.
 
class  NodeChildrenEnumerator
 A NodeEnumberator that iterates though all the children of a node. It will not iterate any further/deeper than children.
 
class  NodeEnumerator
 This abstract class is used to iterate through Nodes, by applying the IEnumerable-Node- Interface. The order in which the nodes are iterated is defined in a (not-abstract) class derived from this one. you may derive your own version to perform a custom iteration method.
 

Public Member Functions

 Node (Node parent, T data)
 creates a new node, that holds the provided data. Adds this new node as a child of the specified parent.
 
IEnumerable< NodeAllDecendants ()
 Provides and IEnumerable<Node> that will iterate though all the descendants of a node.
 
IEnumerable< NodeAllDecendantsByLevel ()
 Provides and IEnumerable<Node> that will iterate though all the descendants of a node. First it will loop through all children, then all grand children, then all great-grandchildren, etc...
 
IEnumerable< NodeChildren ()
 Provides and IEnumerable<Node> that will iterate though the children of the node.
 
bool Contains (Node nodeToCheck)
 recursively checks all children of this node to see if they contain a reference to the provided node.
Note: data is ignored for this operation- only references to the same Node object is checked.
 
void GetAllDecendantsList (IList< Node > genericListInterface, bool groupByLevel=true)
 This function will Add, to the provided genericListInterface, all the descendants of this node. CREDIT: grouping by Level/Generation code, created by LordOfDuct, of Unity Forums
 
void GetAllLeavesList (IList< Node > genericListInterface, bool groupByLevel=true)
 This function will Add, to the provided genericListInterface, all the leaves (childless-descendants) of this node. CREDIT: grouping by Level/Generation code, created by LordOfDuct, of Unity Forums
 
Node GetChild (int childIndex)
 Returns the child of this Node. Which child to return, is specified by the provided index.
 
virtual IEnumerator< NodeGetEnumerator ()
 Default GetEnumbertor function. Iterates through all children of a node
 
virtual IEnumerable< NodeGetEnumeratorByMethod (TreeNodeEnumerationMethod method)
 This function returns the appropriate NodeEnumerator, given the provided TreeNodeEnumerationMethod. You may override this function if you want to change or add more enumeration methods.
 
int GetSiblingIndex ()
 Determines the index number of this node, relative to it's siblings (nodes with the same parent).
 
IEnumerable< NodeLeavesOnly ()
 Provides and IEnumerable<Node> that will iterate though the node and the children of the node.
 
IEnumerable< NodeNodeAndAllDecendants ()
 Provides and IEnumerable<Node> that will iterate though a node, and all its descendants.
 
IEnumerable< NodeNodeAndAllDecendantsByLevel ()
 Provides and IEnumerable<Node> that will iterate though all the descendants of a node. First it will loop through the node, then all children, then all grand children, then all great-grandchildren, etc...
 
IEnumerable< NodeNodeAndChildren ()
 Provides and IEnumerable<Node> that will iterate though the node and the children of the node.
 
bool ReorderChildIndex (int indexToMove, int newIndexToMoveTo)
 Use this function to change the order children are indexed, and iterated through. Takes the index of node to move, and the destination index; siblings between these two will change their index, but the order of all siblings will otherwise remain the same.
 
SerializableTreeNode SerializableIndexNode ()
 This function is used to Create a serializedIndexNode instance, based on this runtime node.
 
bool SetParent (Node newParent)
 This function will set this node as a child of the newParent node. If this node is already a child of a different node, it will be removed as a child, from that, original, parent. This function may fail, and return false under certain conditions: In particular if the newParent node, is currently a descendant of this node, the move will fail. This avoids circular parent->child->parent references. Passing a null for newParent will orphan this node, making it a root node.
 

Public Attributes

List< Nodechildren
 a dynamic list of all the nodes that are children of this one. It is through these lists, that the runtime shape of the tree is defined.
 
dataValue
 direct reference to the Data Value this node stores (an object of type T).
 
bool openForInspection
 Used by UI to determine if the node should be opened (showing children), or not.
 
Node parent
 Reference to this node's parent node. Only the root node, will have a null value here.
 
int serializableDataIndex
 Only used when serializing-deserializing; specifies where, (what index) in the serializable list of the tree, to find the data for this node.
 

Properties

int childCount [get]
 Number of Children this node has, read-only.
 

Inherits IEnumerable< Node >.

+ Collaboration diagram for SerializableTreeBase< T >.Node: