Exemple #1
0
        /// <summary>
        /// Initializes a RedBlackTree from a list that is already sorted.
        /// The tree is balanced as best as possible, and only nodes in the lowest row are red.
        /// </summary>
        public static RedBlackTree <TKey, TValue> FromSorted(IList <KeyValuePair <TKey, TValue> > entries)
        {
            var tree = new RedBlackTree <TKey, TValue>();

            tree.root = tree.MakeSubTree(0, entries, 0, entries.Count);
            if (tree.root != null)
            {
                tree.root.IsBlack = true;
            }
            return(tree);
        }