Skip to content

Commit

Permalink
simplify KDTree.ComputeForces()
Browse files Browse the repository at this point in the history
  • Loading branch information
levnach committed Aug 20, 2022
1 parent 43aa158 commit ddfdd45
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions GraphLayout/MSAGL/Layout/Incremental/Multipole/KDTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ public KDTree(Particle[] particles, int bucketSize)
foreach (var l in leaves)
{
l.ComputeForces();
List<KdNode> stack = new List<KdNode>();
stack.Add(root);
var stack = new Stack<KdNode>();
stack.Push(root);
while (stack.Count > 0)
{
KdNode v = stack.Last();
stack.RemoveAt(stack.Count - 1);
KdNode v = stack.Pop();
if (!l.intersects(v))
{
foreach (var p in l.particles[0])
Expand All @@ -86,8 +85,8 @@ public KDTree(Particle[] particles, int bucketSize)
else
{
var n = v as InternalKdNode;
stack.Add(n.leftChild);
stack.Add(n.rightChild);
stack.Push(n.leftChild);
stack.Push(n.rightChild);
}
}
}
Expand Down

0 comments on commit ddfdd45

Please sign in to comment.