public void BreadthFirstTraversal(Action <CocosLuaNode <T> > action) { List <CocosLuaNode <T> > root = _root.childs; Queue <CocosLuaNode <T> > queue = new Queue <CocosLuaNode <T> >(); for (int i = 0; i < root.Count; i++) { queue.Enqueue(root[i]); } while (queue.Count > 0) { CocosLuaNode <T> node = queue.Dequeue(); action(node); if (node.childs != null) { for (int i = 0; i < node.childs.Count; i++) { queue.Enqueue(node.childs[i]); } } } }
public void DepthFirstTraversal(Action <CocosLuaNode <T> > begin, Action <CocosLuaNode <T> > end, CocosLuaNode <T> node) { begin(node); for (int i = 0; i < node.childs.Count; i++) { DepthFirstTraversal(begin, end, node.childs[i]); } end(node); }
public CocosLuaTree() { _root = new CocosLuaNode <T>(); _list = new List <CocosLuaNode <T> >(); }