update
This commit is contained in:
@@ -9,7 +9,7 @@ namespace TMI_practicum
|
||||
public static IEnumerable<Intersection> Solve(IList<Circle> circles)
|
||||
{
|
||||
var events = new PriorityQueue<Event>();
|
||||
var intersections = new List<Intersection>();
|
||||
var intersections = new HashSet<Intersection>();
|
||||
var active = new List<Circle>();
|
||||
|
||||
foreach (var circle in circles)
|
||||
@@ -21,7 +21,6 @@ namespace TMI_practicum
|
||||
while (events.Count != 0)
|
||||
{
|
||||
Event e = events.Dequeue();
|
||||
|
||||
switch (e.Type)
|
||||
{
|
||||
case Event.EventType.Start:
|
||||
@@ -39,7 +38,7 @@ namespace TMI_practicum
|
||||
return intersections;
|
||||
}
|
||||
|
||||
private static void CheckIntersections(IEnumerable<Circle> active, Circle circle, List<Intersection> intersections)
|
||||
private static void CheckIntersections(IEnumerable<Circle> active, Circle circle, HashSet<Intersection> intersections)
|
||||
{
|
||||
foreach (var otherCircle in active)
|
||||
{
|
||||
@@ -48,7 +47,10 @@ namespace TMI_practicum
|
||||
var intersects = circle.FindIntersections(otherCircle);
|
||||
if (intersects == null) continue;
|
||||
|
||||
intersections.AddRange(intersects);
|
||||
foreach (var intersection in intersects)
|
||||
{
|
||||
intersections.Add(intersection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user