Example #1
0
        public static BinaryTreeNode <T> OrderByOneList(IList <T> datas, ListFlagStruc <T> flags)
        {
            BinaryTreeNode <T> node = null;
            T nodedata = datas[index];

            if (IsData(nodedata, flags))
            {
                node = new BinaryTreeNode <T>(nodedata);
                index++;
                nodedata = datas[index];
                if (nodedata.Equals(flags.LeftDeLimit))
                {
                    index++;
                    node.Left = OrderByOneList(datas, flags);
                    index++;
                    node.Right = OrderByOneList(datas, flags);
                    index++;
                }
            }
            if (nodedata.Equals(flags.NullSubTree))
            {
                index++;
            }
            return(node);
        }
Example #2
0
        public static BinaryTree <T> ByOneList(IList <T> datas, ListFlagStruc <T> flags)
        {
            BinaryTree <T> tree = new BinaryTree <T>();

            BinaryTree <T> .index = 0;
            if (datas.Count > 0)
            {
                tree.Root = OrderByOneList(datas, flags);
            }
            return(tree);
        }
Example #3
0
 private static bool IsData(T nodeData, ListFlagStruc <T> flags)
 {
     if (nodeData.Equals(flags.NullSubTree) ||
         nodeData.Equals(flags.LeftDeLimit) ||
         nodeData.Equals(flags.RightDeLimit) ||
         nodeData.Equals(flags.MiddleDeLimit))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }