perf fixes
This commit is contained in:
@@ -21,7 +21,8 @@ namespace TMI_practicum
|
|||||||
return Math.Round(Math.Sqrt(Math.Pow(X - otherCircle.X, 2) + Math.Pow(Y - otherCircle.Y, 2)), 15);
|
return Math.Round(Math.Sqrt(Math.Pow(X - otherCircle.X, 2) + Math.Pow(Y - otherCircle.Y, 2)), 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<Intersection> FindIntersections(Circle c1)
|
public
|
||||||
|
IEnumerable<Intersection> FindIntersections(Circle c1)
|
||||||
{
|
{
|
||||||
IList<Intersection> intersections;
|
IList<Intersection> intersections;
|
||||||
double d = Distance(c1);
|
double d = Distance(c1);
|
||||||
|
@@ -6,7 +6,7 @@ namespace TMI_practicum
|
|||||||
{
|
{
|
||||||
public static IEnumerable<Intersection> Solve(IList<Circle> circles)
|
public static IEnumerable<Intersection> Solve(IList<Circle> circles)
|
||||||
{
|
{
|
||||||
var intersections = new HashSet<Intersection>();
|
var intersections = new Stack<Intersection>();
|
||||||
|
|
||||||
for (int i = 0; i < circles.Count - 1; i++)
|
for (int i = 0; i < circles.Count - 1; i++)
|
||||||
{
|
{
|
||||||
@@ -18,7 +18,7 @@ namespace TMI_practicum
|
|||||||
if (intersects == null) continue;
|
if (intersects == null) continue;
|
||||||
foreach (var intersect in intersects)
|
foreach (var intersect in intersects)
|
||||||
{
|
{
|
||||||
intersections.Add(intersect);
|
intersections.Push(intersect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,10 +6,10 @@ namespace TMI_practicum
|
|||||||
{
|
{
|
||||||
public static class SweepLineAlgorithm
|
public static class SweepLineAlgorithm
|
||||||
{
|
{
|
||||||
public static IEnumerable<Intersection> Solve(IList<Circle> circles)
|
public static IEnumerable<Intersection> Solve(IEnumerable<Circle> circles)
|
||||||
{
|
{
|
||||||
var events = new PriorityQueue<Event>();
|
var events = new PriorityQueue<Event>();
|
||||||
var intersections = new HashSet<Intersection>();
|
var intersections = new Stack<Intersection>();
|
||||||
var active = new List<Circle>();
|
var active = new List<Circle>();
|
||||||
|
|
||||||
foreach (var circle in circles)
|
foreach (var circle in circles)
|
||||||
@@ -38,7 +38,7 @@ namespace TMI_practicum
|
|||||||
return intersections;
|
return intersections;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CheckIntersections(IEnumerable<Circle> active, Circle circle, HashSet<Intersection> intersections)
|
private static void CheckIntersections(IEnumerable<Circle> active, Circle circle, Stack<Intersection> intersections)
|
||||||
{
|
{
|
||||||
foreach (var otherCircle in active)
|
foreach (var otherCircle in active)
|
||||||
{
|
{
|
||||||
@@ -49,7 +49,7 @@ namespace TMI_practicum
|
|||||||
|
|
||||||
foreach (var intersection in intersects)
|
foreach (var intersection in intersects)
|
||||||
{
|
{
|
||||||
intersections.Add(intersection);
|
intersections.Push(intersection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user