mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
More recursion -> queue for #4703
This commit is contained in:
1 parent
92829acef3
commit
dd93c4c900
1 file changed
+12
-3
@@ -1,7 +1,9 @@
|
||||
package mekanism.common.multiblock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -35,7 +37,7 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
* Recursively loops through each node connected to the given TileEntity.
|
||||
* @param coord - the TileEntity coords to loop over
|
||||
*/
|
||||
public void loopThrough(Coord4D coord)
|
||||
public void loopThrough(Coord4D coord, Deque<Coord4D> queue)
|
||||
{
|
||||
int origX = coord.x, origY = coord.y, origZ = coord.z;
|
||||
|
||||
@@ -221,7 +223,7 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
{
|
||||
if(!iteratedNodes.contains(sideCoord))
|
||||
{
|
||||
loopThrough(sideCoord);
|
||||
queue.addLast(sideCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -453,7 +455,14 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
*/
|
||||
public void doUpdate()
|
||||
{
|
||||
loopThrough(Coord4D.get(pointer));
|
||||
Deque<Coord4D> pathingQueue = new LinkedList<>();
|
||||
pathingQueue.add(Coord4D.get(pointer));
|
||||
while (pathingQueue.peek() != null) {
|
||||
Coord4D next = pathingQueue.removeFirst();
|
||||
if (!iteratedNodes.contains(next)) {
|
||||
loopThrough(next, pathingQueue);
|
||||
}
|
||||
}
|
||||
|
||||
if(structureFound != null)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user