/// <summary> /// This will add a node to the collection. /// </summary> /// <param name="node">Specifies a node to be added.</param> /// <returns>Returns index of the newly added item.</returns> public int Add(TmxNode node) { if (this.parent != null) { node.SetParent(this.parent); } return(this.List.Add(node)); }
/// <summary> /// This will insert a node at the given position. /// </summary> /// <param name="index">The position at which to insert the node.</param> /// <param name="node">The node to insert.</param> public void Insert(int index, TmxNode node) { if (this.parent != null) { node.SetParent(this.parent); } this.InnerList.Insert(index, node); }
/// <summary> /// This will return true if the node passed is a descendent of this node. /// </summary> /// <param name="node">The node that might be the parent or grandparent (etc).</param> /// <returns>True if this node is a descendent of the one passed in.</returns> public bool IsDescendentOf(TmxNode node) { TmxNode parent = this.Parent; while (parent != null) { if (parent == node) { return(true); } parent = parent.Parent; } return(false); }
/// <summary> /// This will return the ancstor that is common to this node and the one specified. /// </summary> /// <param name="node">The possible node that is relative.</param> /// <returns>The common ancestor, or null if there is none.</returns> public TmxNode GetCommonAncestor(TmxNode node) { TmxNode thisParent = this; while (thisParent != null) { TmxNode thatParent = node; while (thatParent != null) { if (thisParent == thatParent) { return(thisParent); } thatParent = thatParent.Parent; } thisParent = thisParent.Parent; } return(null); }
/// <summary> /// This will return true if the node passed is a descendent of this node. /// </summary> /// <param name="node">The node that might be the parent or grandparent (etc).</param> /// <returns>True if this node is a descendent of the one passed in.</returns> public bool IsDescendentOf(TmxNode node) { TmxNode parent = this.Parent; while (parent != null) { if (parent == node) { return true; } parent = parent.Parent; } return false; }
/// <summary> /// This will return true if the node passed is one of the children or grandchildren of this node. /// </summary> /// <param name="node">The node that might be a child.</param> /// <returns>True if this node is an ancestor of the one specified.</returns> public bool IsAncestorOf(TmxNode node) { return node.IsDescendentOf(this); }
/// <summary> /// This will return the ancstor that is common to this node and the one specified. /// </summary> /// <param name="node">The possible node that is relative.</param> /// <returns>The common ancestor, or null if there is none.</returns> public TmxNode GetCommonAncestor(TmxNode node) { TmxNode thisParent = this; while (thisParent != null) { TmxNode thatParent = node; while (thatParent != null) { if (thisParent == thatParent) { return thisParent; } thatParent = thatParent.Parent; } thisParent = thisParent.Parent; } return null; }
/// <summary> /// This is used to identify the index of this node as it appears in the collection. /// </summary> /// <param name="node">The node to test.</param> /// <returns>The index of the node, or -1 if it is not in this collection.</returns> public int IndexOf(TmxNode node) { return this.List.IndexOf(node); }
/// <summary> /// This will add a node to the collection. /// </summary> /// <param name="node">Specifies a node to be added.</param> /// <returns>Returns index of the newly added item.</returns> public int Add(TmxNode node) { if (this.parent != null) { node.SetParent(this.parent); } return this.List.Add(node); }
/// <summary> /// This is used to identify the index of this node as it appears in the collection. /// </summary> /// <param name="node">The node to test.</param> /// <returns>The index of the node, or -1 if it is not in this collection.</returns> public int IndexOf(TmxNode node) { return(this.List.IndexOf(node)); }
/// <summary> /// This will return true if the node passed is one of the children or grandchildren of this node. /// </summary> /// <param name="node">The node that might be a child.</param> /// <returns>True if this node is an ancestor of the one specified.</returns> public bool IsAncestorOf(TmxNode node) { return(node.IsDescendentOf(this)); }