public Mould() { Root = new MouldItem <T>() { Level = -1, Parent = -1, Value = default(T) }; Items = new List <MouldItem <T> >(); Items.Add(Root); Relationships = new List <List <IRelationship> >(); }
public void AddChild(MouldItem <T> newChild, T newChildValue) { newChild.Parent = Index; newChild.Level = Level + 1; newChild.Index = Index + 1; newChild.Value = newChildValue; if (children == 0) { Mould.Items.Add(newChild); } else { Mould.Items.Insert(Index + children, newChild); } children++; if (children > 1) { newChild.NextSibling = Mould.Items[Index + children]; } }
public Mould <T> MouldFrom(MouldItem <T> element) { int index = Items.IndexOf(element); return(SubMould(index)); }