using System; using System.Collections.Generic; namespace Stary.Evo { public class TreeNode { public Dictionary childs; public ulong id; public object data; public TreeNode Get(ulong id) { if (childs == null) { return null; } childs.TryGetValue(id, out var node); return node; } public TreeNode GetOrAdd(ulong id) { if (childs == null) { childs = new Dictionary(); } if (!childs.TryGetValue(id, out var node)) { node = ObjectPool.Get(); node.id = id; childs.Add(id, node); } return node; } public void CleanUp() { if (childs != null) { foreach (var item in childs.Values) { item.CleanUp(); ObjectPool.Release(item); } childs.Clear(); } id = 0; data = default; } } }