Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use LinkedHashSet for Breadth First Search. #2697

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class BreadthFirstBlockSearch {

public static Set<BlockPos> search(Predicate<BlockPos> value, BlockPos start, int limit) {
Set<BlockPos> alreadyVisited = new HashSet<>();
Set<BlockPos> valid = new HashSet<>();
Set<BlockPos> valid = new LinkedHashSet<>();
int iteration = 0;

Queue<BlockPos> queue = new ArrayDeque<>();
Expand Down Expand Up @@ -58,7 +58,7 @@ public static <T extends BlockEntity> Set<T> conditionalBlockEntitySearch(Class<
var level = start.getLevel();
if (level == null) return Set.of();

var passed = new HashSet<T>();
var passed = new LinkedHashSet<T>();
var queue = new ObjectArrayFIFOQueue<Triple<T, T, Direction>>(16);
queue.enqueue(new ImmutableTriple<>(null, start, null));

Expand Down Expand Up @@ -87,7 +87,7 @@ public static <T extends BlockEntity> Set<T> conditionalBlockEntitySearch(Class<

public static Set<BlockPos> conditionalBlockPosSearch(BlockPos start, BiPredicate<BlockPos, BlockPos> condition,
int blockLimit, int iterationLimit) {
var passed = new HashSet<BlockPos>();
var passed = new LinkedHashSet<BlockPos>();
var queue = new ObjectArrayFIFOQueue<Tuple<BlockPos, BlockPos>>(16);
queue.enqueue(new Tuple<>(null, start));

Expand Down
Loading