Exemple #1
0
        public KDTree(IEnumerable <KeyValuePair <TPoint, TValue> > points, IKDPointComparer <TPoint> comparer)
            : this(comparer)
        {
            if (points == null)
            {
                throw new ArgumentNullException(nameof(points));
            }

            var pointsArray = points.ToArray();
            if (pointsArray.Any(kvp => kvp.Key == null))
            {
                throw new ArgumentNullException(nameof(points), "keys must be non-null");
            }

            if (pointsArray.Length > 0)
            {
                this.EnsureInitialized(pointsArray[0].Key);
                this.root  = this.BuildTree(pointsArray, 0, pointsArray.Length - 1, dimension: 0);
                this.Count = pointsArray.Length;
            }
        }
Exemple #2
0
 public PointAndValueComparer(IKDPointComparer <TPoint> comparer, int dimension)
 {
     this.comparer  = comparer;
     this.dimension = dimension;
 }
Exemple #3
0
 public KDTree(IKDPointComparer <TPoint> comparer = null)
 {
     this.comparer = comparer; // todo null
 }