Document MathHelper.binarySearch (#2956)

* Document MathHelper.binarySearch

* Apply suggestions from code review

Co-authored-by: liach <7806504+liach@users.noreply.github.com>

Co-authored-by: liach <7806504+liach@users.noreply.github.com>
This commit is contained in:
enbrain 2022-01-18 06:23:49 +09:00 committed by GitHub
parent 3dec7b22c7
commit b8d5ad7dda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 3 deletions

View File

@ -86,9 +86,28 @@ CLASS net/minecraft/class_3532 net/minecraft/util/math/MathHelper
METHOD method_15357 floor (D)I
ARG 0 value
METHOD method_15360 binarySearch (IILjava/util/function/IntPredicate;)I
ARG 0 start
ARG 1 end
ARG 2 leftPredicate
COMMENT Finds the minimum value in {@code [min, max)} that satisfies the
COMMENT monotonic {@code predicate}.
COMMENT
COMMENT <p>The {@code predicate} must be monotonic, i.e. if for any {@code a},
COMMENT {@code predicate.test(a)} is {@code true}, then for all {@code b > a},
COMMENT {@code predicate.test(b)} must also be {@code true}.
COMMENT
COMMENT <p>Examples:
COMMENT <ul>
COMMENT <li>{@code binarySearch(3, 7, x -> true)} returns {@code 3}.
COMMENT <li>{@code binarySearch(3, 7, x -> x >= 5)} returns {@code 5}.
COMMENT <li>{@code binarySearch(3, 7, x -> false)} returns {@code 7}.
COMMENT </ul>
COMMENT
COMMENT @return the minimum value if such value is found, otherwise {@code max}
ARG 0 min
COMMENT the minimum value (inclusive) to be tested
ARG 1 max
COMMENT the maximum value (exclusive) to be tested
ARG 2 predicate
COMMENT the predicate that returns {@code true} for integers greater than or
COMMENT equal to the value to be searched for
METHOD method_15362 cos (F)F
ARG 0 value
METHOD method_15363 clamp (FFF)F