public Node[] RadialSearch(Get <K> center, K radius, int count) { var nearestNeighbours = new NearestNeighbourList <Node, K>(count, this._minValue, this._compareKey); AddNearestNeighbours( _root, center, HyperRect <K> .Infinite(_dimensions, this._minValue, this._maxValue), 0, nearestNeighbours, this._multiply(radius, radius)); count = nearestNeighbours.Count; var neighbourArray = new Node[count]; for (var index = 0; index < count; index++) { neighbourArray[count - index - 1] = nearestNeighbours.RemoveFurtherest(); } return(neighbourArray); }
public Node[] GetNearestNeighbours(Get <K> point, int count) { if (count > Count) { count = Count; } if (count < 0) { throw new ArgumentException("Number of neighbors cannot be negative"); } if (count == 0) { return(new Node[0]); } var neighbours = new Node[count]; var nearestNeighbours = new NearestNeighbourList <Node, K>(count, this._minValue, this._compareKey); var rect = HyperRect <K> .Infinite(_dimensions, this._minValue, this._maxValue); AddNearestNeighbours(_root, point, rect, 0, nearestNeighbours, this._maxValue); count = nearestNeighbours.Count; var neighbourArray = new Node[count]; for (var index = 0; index < count; index++) { neighbourArray[count - index - 1] = nearestNeighbours.RemoveFurtherest(); } return(neighbourArray); }