public void AddChild(FmlNode l) { if (l == null) { return; } if (ChildList.Count > ChildCount) { for (int i = 0, imax = ChildList.Count; i < imax; ++i) { if (ChildList[i] == null) { ChildList[i] = l; break; } } } else { ChildList.Add(l); } l.AddBranch(this); ++ChildCount; SetDirty(); }
public int ReplaceAllChild(FmlNode from, FmlNode to) { if (from == to) { return(0); } int count = 0; for (int i = 0, imax = ChildList.Count; i < imax; ++i) { if (ChildList[i] == from) { ChildList[i] = to; ++count; } } if (count > 0) { if (from == null) { to.AddBranch(this, count); ChildCount += count; } else if (to == null) { from.RemoveBranch(this, count); ChildCount -= count; RemoveNullTail(); } else { to.AddBranch(this, count); from.RemoveBranch(this, count); } SetDirty(); } return(count); }
public bool ReplaceChild(FmlNode from, FmlNode to) { if (from == to) { return(false); } for (int i = 0, imax = ChildList.Count; i < imax; ++i) { if (ChildList[i] == from) { ChildList[i] = to; if (from == null) { to.AddBranch(this); ++ChildCount; } else if (to == null) { from.RemoveBranch(this); --ChildCount; RemoveNullTail(); } else { to.AddBranch(this); from.RemoveBranch(this); } SetDirty(); return(true); } } return(false); }