/// <summary> /// Fixes parent links after deserializing a json file into a tree. /// </summary> /// <param name="root"></param> private static void FixParentLinks(QTreeNode <T> root) { foreach (var child in root._children) { child.Parent = root; FixParentLinks(child); } }
/// <summary> /// Inserts a QTreeNode into this node. The inserted node becomes a child of this node. /// </summary> /// <param name="child">The child node to insert</param> public void Insert(QTreeNode <T> child) { if (_children.Count < 4) { _children.Add(child); child.Parent = this; } else { throw new IndexOutOfRangeException("There are already four children in this node."); } }
/// <inheritdoc /> /// <param name="parent">The parent node</param> /// <param name="content">The content at this node</param> public QTreeNode(QTreeNode <T> parent, T content) : this(parent) { Content = content; }
/// <summary> /// Creates a new QuadTree node /// </summary> /// <param name="parent">The parent node</param> public QTreeNode(QTreeNode <T> parent) { Parent = parent; }