Contents
Class AsyncSpatialSearch
java.lang.Object
com.hypixel.hytale.builtin.portals.utils.posqueries.AsyncSpatialSearch
Runs an
AsyncPositionPredicate over candidate positions and returns the first accepted
one.-
Method Summary
Modifier and TypeMethodDescriptionstatic CompletableFuture<org.joml.Vector3d> firstMatch(World world, Iterator<org.joml.Vector3d> candidates, AsyncPositionPredicate predicate) Tests candidates in order and returns the first the predicate accepts.
-
Method Details
-
firstMatch
@Nonnull public static CompletableFuture<org.joml.Vector3d> firstMatch(@Nonnull World world, @Nonnull Iterator<org.joml.Vector3d> candidates, @Nonnull AsyncPositionPredicate predicate) Tests candidates in order and returns the first the predicate accepts.Candidates the predicate answers without loading are consumed in the loop, so a search whose data is already in memory completes without leaving the calling thread. Chaining every candidate with
thenComposeinstead would nest one stack frame per candidate, becausethenComposeruns its function inline on an already-completed future.- Parameters:
world- The world to test in. Also the executor that resumes a suspended search.candidates- The candidate positions, consumed lazily.predicate- The predicate to test each candidate with.- Returns:
- a future completing with the first accepted candidate, or
nullif none.
-