Esempio n. 1
0
        public static BinaryTree <T> Create <T>(params T[] values) where T : IComparable
        {
            var tree = new BinaryTree <T>();

            foreach (var value in values)
            {
                tree.Add(value);
            }
            return(tree);
        }
Esempio n. 2
0
        public static BinaryTree <TParametrs> Create(params TParametrs[] value)
        {
            BinaryTree <TParametrs> tree = new BinaryTree <TParametrs>();

            for (int i = 0; i < value.Length; i++)
            {
                tree.Add(value[i]);
            }
            return(tree);
        }
Esempio n. 3
0
        public static BinaryTree <T> Create(params T[] elements)
        {
            BinaryTree <T> tree = new BinaryTree <T>();

            foreach (var element in elements)
            {
                tree.Add(element);
            }
            return(tree);
        }
Esempio n. 4
0
        public static BinaryTree <T> Create <T>(params T[] items) where T : IComparable
        {
            var tree = new BinaryTree <T>();

            foreach (T item in items)
            {
                tree.Add(item);
            }
            return(tree);
        }
Esempio n. 5
0
 public void Add(T value)
 {
     if (tree.Count == 0)
     {
         Value = value;
     }
     else if (Value.CompareTo(value) >= 0)
     {
         Left = Left ?? new BinaryTree <T>();
         Left.Add(value);
     }
     else
     {
         Right = Right ?? new BinaryTree <T>();
         Right.Add(value);
     }
     tree.Add(value);
 }