Пример #1
0
        /// <summary>
        /// Adds the specified <see cref="BraidedTreeNode{TKey, TValue}"/> to the tree structure, as
        /// a leaf node of the current instance.</summary>
        /// <param name="node">
        /// The <see cref="BraidedTreeNode{TKey, TValue}"/> to add.</param>
        /// <param name="isRight">
        /// <c>true</c> to add <paramref name="node"/> as the <see cref="Right"/> descendant;
        /// <c>false</c> to add <paramref name="node"/> as the <see cref="Left"/> descendant. The
        /// corresponding property must be a null reference.</param>
        /// <remarks>
        /// <b>AddTree</b> also sets the <see cref="Parent"/> reference of the specified <paramref
        /// name="node"/> to the current instance, and updates the chains of <see cref="Previous"/>
        /// and <see cref="Next"/> references to include <paramref name="node"/>.</remarks>

        internal void AddTree(BraidedTreeNode <TKey, TValue> node, bool isRight)
        {
            Debug.Assert(node._parent == null);
            node._parent = this;

            if (isRight)
            {
                Debug.Assert(_right == null);
                _right = node;
                AddList(node);
            }
            else
            {
                Debug.Assert(_left == null);
                _left = node;
                _previous.AddList(node);
            }
        }