public NearestNeighbourList(ITypeMath <TDistance> distanceMath)
        {
            this.maxCapacity  = int.MaxValue;
            this.distanceMath = distanceMath;

            queue = new PriorityQueue <TItem, TDistance>(distanceMath);
        }
        public NearestNeighbourList(int maxCapacity, ITypeMath <TDistance> distanceMath)
        {
            this.maxCapacity  = maxCapacity;
            this.distanceMath = distanceMath;

            queue = new PriorityQueue <TItem, TDistance>(maxCapacity, distanceMath);
        }
示例#3
0
        ///<remarks>
        ///This constructor will use a default capacity of 4.
        ///</remarks>
        public PriorityQueue(ITypeMath <TPriority> priorityMath)
        {
            this.capacity = 4;
            queue         = new ItemPriority <TItem, TPriority> [capacity];

            this.priorityMath = priorityMath;
        }
        public PriorityQueue(int capacity, ITypeMath <TPriority> priorityMath)
        {
            if (capacity <= 0)
            {
                throw new ArgumentException("Capacity must be greater than zero");
            }

            this.capacity = capacity;
            queue         = new ItemPriority <TItem, TPriority> [capacity];

            this.priorityMath = priorityMath;
        }
示例#5
0
        public static HyperRect <T> Infinite(int dimensions, ITypeMath <T> math)
        {
            var rect = new HyperRect <T>();

            rect.MinPoint = new T[dimensions];
            rect.MaxPoint = new T[dimensions];

            for (var dimension = 0; dimension < dimensions; dimension++)
            {
                rect.MinPoint[dimension] = math.NegativeInfinity;
                rect.MaxPoint[dimension] = math.PositiveInfinity;
            }

            return(rect);
        }
示例#6
0
        public T[] GetClosestPoint(T[] toPoint, ITypeMath <T> math)
        {
            T[] closest = new T[toPoint.Length];

            for (var dimension = 0; dimension < toPoint.Length; dimension++)
            {
                if (math.Compare(minPoint[dimension], toPoint[dimension]) > 0)
                {
                    closest[dimension] = minPoint[dimension];
                }
                else if (math.Compare(maxPoint[dimension], toPoint[dimension]) < 0)
                {
                    closest[dimension] = maxPoint[dimension];
                }
                else
                {
                    // Point is within rectangle, at least on this dimension
                    closest[dimension] = toPoint[dimension];
                }
            }

            return(closest);
        }
示例#7
0
 public KdTree(int dimensions, ITypeMath <TKey> typeMath, AddDuplicateBehavior addDuplicateBehavior)
     : this(dimensions, typeMath)
 {
     AddDuplicateBehavior = addDuplicateBehavior;
 }
示例#8
0
 public KdTree(int dimensions, ITypeMath <TKey> typeMath)
 {
     this.dimensions = dimensions;
     this.typeMath   = typeMath;
     Count           = 0;
 }
示例#9
0
 public static void Register <DataType>(ITypeMath <DataType> math)
 {
     registeredMath.Add(typeof(DataType), math);
 }
示例#10
0
 public TypesComparer(ITypeMath <TKey> typeMath, int byDimension)
 {
     this.typeComparer = typeMath;
     this.byDimension  = byDimension;
 }
示例#11
0
 public KdTree(int dimensions, ITypeMath <TKey> typeMath, AddDuplicateBehavior addDuplicateBehavior, onUpdateDelegate onNodeUpdate)
     : this(dimensions, typeMath, addDuplicateBehavior)
 {
     OnNodeUpdate = onNodeUpdate;
 }
示例#12
0
 public PriorityQueue2(ITypeMath <TPriority> priorityMath, int capacity = 512)
 {
     this.priorityMath = priorityMath;
     //maxPriority = priorityMath.Max;
     Initialize(capacity);
 }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:com.kiranpatel.crimecluster.framework.KdTreeWrapper`2"/> class.
 /// </summary>
 /// <param name="mathType">Math type.</param>
 public KdTreeWrapper(ITypeMath <TKey> mathType)
 {
     this._kdTree = new KdTree <TKey, TVal>(2, mathType);
 }