Пример #1
0
        /// <summary>
        /// Добавление ключа и связанного с ним потомка.
        /// </summary>
        /// <param name="key">Ключ.</param>
        /// <param name="child">Потомок.</param>
        private void InsertChild(T key, TreeNode <T> child)
        {
            int location   = Keys.IndexInSorted(key);
            int childIndex = location >= 0 ? location + 1 : -location - 1;

            if (location >= 0)
            {
                Children[childIndex] = child;
            }
            else
            {
                Keys.Insert(childIndex, key);
                Children.Insert(childIndex + 1, child);
            }
        }