public int CompareTo(object obj) { WeightedIndex pointIndex = obj as WeightedIndex; if (pointIndex == null) { return(-1); } if (this.Weight < pointIndex.Weight) { return(-1); } if (this.Weight > pointIndex.Weight) { return(1); } if (this.Index < pointIndex.Index) { return(-1); } if (this.Index > pointIndex.Index) { return(1); } return(0); }
IList <double> CalculateWeightsCore(IList <CoordPoint> points) { int[] previousPointIndex = new int[points.Count]; int[] nextPointIndex = new int[points.Count]; double maxValue = double.NegativeInfinity; double[] weights = InicializeWeights(points); InicializeIndices(previousPointIndex, nextPointIndex); SortedSet <WeightedIndex> sortedSet = InicializeSortedSet(weights); while (sortedSet.Count > 0) { WeightedIndex minWeightIndex = sortedSet.Min; sortedSet.Remove(minWeightIndex); if (minWeightIndex.Weight == double.PositiveInfinity) { break; } if (minWeightIndex.Weight < maxValue) { weights[minWeightIndex.Index] = maxValue; } else { maxValue = minWeightIndex.Weight; } int previousIndex = previousPointIndex[minWeightIndex.Index]; int nextIndex = nextPointIndex[minWeightIndex.Index]; if (previousIndex > 0) { UpdatePointWeight(previousIndex, MathUtils.CalculateSquare(points[previousPointIndex[previousIndex]], points[previousIndex], points[nextIndex]), weights, sortedSet); } if (nextIndex < points.Count - 1) { UpdatePointWeight(nextIndex, MathUtils.CalculateSquare(points[previousIndex], points[nextIndex], points[nextPointIndex[nextIndex]]), weights, sortedSet); } previousPointIndex[nextIndex] = previousIndex; nextPointIndex[previousIndex] = nextIndex; } return(weights); }