Skip to content

Commit

Permalink
Don't use HashSet where FlutePoint is the item
Browse files Browse the repository at this point in the history
  • Loading branch information
joelverhagen committed Jan 14, 2024
1 parent ae7fb8d commit d56e319
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ private static ILocationDictionary<ILocationSet> GetConnectedPumpjacksWithFLUTE(
{
otherCenters.UnionWith(point.Centers);

foreach (var neighbor in point.Neighbors)
foreach (var neighbor in point.Neighbors.EnumerateItems())
{
queue.Enqueue(neighbor);
queue.Enqueue(locationToPoint[neighbor]);
}
}
}
Expand All @@ -59,14 +59,15 @@ public FlutePoint(Context context, Location location)
{
Location = location;
Centers = context.GetLocationSet(allowEnumerate: true);
Neighbors = context.GetLocationSet(allowEnumerate: true);
}

public bool IsEliminated { get; set; }
public bool IsSteinerPoint => Centers.Count == 0;
public Location Location { get; }
public ILocationSet Centers { get; }
public List<TerminalLocation> Terminals { get; } = new List<TerminalLocation>();
public HashSet<FlutePoint> Neighbors { get; } = new HashSet<FlutePoint>();
public ILocationSet Neighbors { get; }

#if ENABLE_GRID_TOSTRING
public override string ToString()
Expand Down Expand Up @@ -108,8 +109,8 @@ FlutePoint GetOrAddPoint(ILocationDictionary<FlutePoint> locationToPoint, Branch
var currentPoint = GetOrAddPoint(locationToPoint, current);
var nextPoint = GetOrAddPoint(locationToPoint, next);

currentPoint.Neighbors.Add(nextPoint);
nextPoint.Neighbors.Add(currentPoint);
currentPoint.Neighbors.Add(nextPoint.Location);
nextPoint.Neighbors.Add(currentPoint.Location);

if (current.N == next.N)
{
Expand All @@ -123,7 +124,7 @@ FlutePoint GetOrAddPoint(ILocationDictionary<FlutePoint> locationToPoint, Branch
// Remove self from neighbors
foreach (var point in locationToPoint.Values)
{
point.Neighbors.Remove(point);
point.Neighbors.Remove(point.Location);
}

// Add in pumpjack information
Expand Down

0 comments on commit d56e319

Please sign in to comment.