using System.Collections.Generic; namespace HeuristicLab.Problems.ProgramSynthesis.Push.Data.Tree { public class TreeNode { public T Value { get; set; } public IList> Children { get; private set; } public int Count { get; private set; } public TreeNode() { Children = new List>(); Count = 1; } public TreeNode(T value) : this() { Value = value; } public void Add(T value) { Children.Add(new TreeNode(value)); Count++; } public void AddNode(TreeNode node) { Children.Add(node); Count += node.Count; } public void ReplaceNode(int index, TreeNode node) { Count -= Children[index].Count; Children[index] = node; Count += node.Count; } } }