Esempio n. 1
0
        public static Tuple <TPoint[], TNode>[] LinearRadialSearch <TPoint, TNode>(TPoint[][] points, TNode[] nodes, TPoint[] target, Func <TPoint[], TPoint[], double> metric, double radius)
        {
            var pointsInRadius = new BoundedPriorityList <int, double>(points.Length, true);

            for (int i = 0; i < points.Length; i++)
            {
                var currentDist = metric(target, points[i]);
                if (radius >= currentDist)
                {
                    pointsInRadius.Add(i, currentDist);
                }
            }

            return(pointsInRadius.Select(idx => new Tuple <TPoint[], TNode>(points[idx], nodes[idx])).ToArray());
        }
Esempio n. 2
0
        public static T[][] LinearRadialSearch <T>(T[][] data, T[] point, Func <T[], T[], double> metric, double radius)
        {
            var pointsInRadius = new BoundedPriorityList <T[], double>(data.Length, true);

            for (int i = 0; i < data.Length; i++)
            {
                var currentDist = metric(point, data[i]);
                if (radius >= currentDist)
                {
                    pointsInRadius.Add(data[i], currentDist);
                }
            }

            return(pointsInRadius.ToArray());
        }