Пример #1
0
        /// <summary>
        /// Inserts point value pairs in a way that produces a balanced tree.
        /// </summary>
        public static KdTree <T> CreateBalanced(double[][] points, T[] values)
        {
            KdTree <T> result = new KdTree <T>(points[0].Length);
            var        nodes  = points.Convert((p, i) => new Node(p, values[i]));

            result._root  = result.InsertBalanced(nodes, 0, nodes.Length - 1, 0);
            result._count = nodes.Length;
            return(result);
        }
Пример #2
0
        /// <summary>
        /// Inserts point value pairs in a way that produces a balanced tree.
        /// </summary>
        public static KdTree <T> CreateBalanced(IEnumerable <double[]> points, IEnumerable <T> values)
        {
            KdTree <T> result = new KdTree <T>(points.First().Length);
            var        nodes  = points.Zip(values, (p, v) => new Node(p, v)).ToArray();

            result._root  = result.InsertBalanced(nodes, 0, nodes.Length - 1, 0);
            result._count = nodes.Length;
            return(result);
        }