示例#1
0
        public void Add(T Value)
        {
            if (this._Root == null)
            {
                this._Root = new BinaryNode <T>(null, Value);
                return;
            }

            bool Exists = (this._Option == BinaryTreeOption.Wild ? false : BinaryNode <T> .Exists(this._Root, Value, this._Comparer));

            if (Exists && this._Option == BinaryTreeOption.Distinct)
            {
                return;
            }
            else if (Exists && this._Option == BinaryTreeOption.Unique)
            {
                throw new Exception("Element already exists");
            }

            BinaryNode <T> Element = new BinaryNode <T>(null, Value);

            BinaryNode <T> .Insert(this._Root, Element, this._Comparer);
        }