public LowestCommonAncestor(TNode[] tree) { if (tree.Length == 0) { throw new ArgumentException(nameof(tree)); } this.tree = tree; var roots = new int[tree.Length]; for (int v = 0; v < tree.Length; v++) { roots[v] = tree[v].Root.To; } doubling = new PathDoubling(roots, tree.Length); }
public LowestCommonAncestorWithData(TNode[] tree, T[] data, TOp op = default) { if (tree.Length == 0) { throw new ArgumentException(nameof(tree)); } if (tree.Length != data.Length) { throw new ArgumentException("データと木の長さが異なります", nameof(data)); } this.tree = tree; var roots = new int[tree.Length]; for (int v = 0; v < tree.Length; v++) { roots[v] = tree[v].Root.To; } doubling = new PathDoubling <T, TOp>(roots, data, tree.Length, op); }