Ejemplo n.º 1
0
            public void Add(T t)
            {
                if (t.CompareTo(Value) > 0)
                {
                    if (Greater == null)
                    {
                        Greater = new TreeNode(t, this);
                        return;
                    }

                    Greater.Add(t);
                }
                else if (t.CompareTo(Value) < 0)
                {
                    if (Smaller == null)
                    {
                        Smaller = new TreeNode(t, this);
                        return;
                    }

                    Smaller.Add(t);
                }
                else // t = Value
                {
                    throw new ArgumentException("Can not have two elements with this same value.");
                }
            }