/// <summary>Constructor for cloning purposes.</summary> /// <param name="tree">The tree to be cloned.</param> internal RedBlackTreeLinked(RedBlackTreeLinked <T, Compare> tree) { Node Clone(Node node, Node parent) { if (node == _sentinelNode) { return(_sentinelNode); } Node clone = new Node { Value = node.Value, Color = node.Color, Parent = parent }; clone.LeftChild = node.LeftChild is null ? null : Clone(node.LeftChild, clone); clone.RightChild = node.RightChild is null ? null : Clone(node.RightChild, clone); return(clone); } _compare = tree._compare; _count = tree._count; _root = tree._root is null ? null : Clone(tree._root, null); }
/// <summary>Constructor for cloning purposes.</summary> /// <param name="tree">The tree to be cloned.</param> internal RedBlackTreeLinked(RedBlackTreeLinked <T> tree) { _compare = tree._compare; _count = tree._count; _root = tree._root.Clone(null); }