示例#1
0
    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]);
                }
            }
        }
    }
示例#2
0
    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);
    }
示例#3
0
 public CocosLuaTree()
 {
     _root = new CocosLuaNode <T>();
     _list = new List <CocosLuaNode <T> >();
 }