style: enable NeedBraces in checkstyle (#5227)

* enable style NeedBraces

* style: enable NeedBraces in checkstyle

---------

Co-authored-by: Samuel Facchinello <samuel.facchinello@piksel.com>
This commit is contained in:
Samuel Facchinello
2024-06-13 21:00:16 +02:00
committed by GitHub
parent 51fcc66345
commit 87b17e0571
68 changed files with 629 additions and 261 deletions

View File

@ -24,22 +24,23 @@ public final class OrderAgnosticBinarySearch {
int middle = start + (end - start) / 2;
// Check if the desired element is present at the middle position
if (arr[middle] == target) return middle; // returns the index of the middle element
// Ascending order
if (ascOrd) {
if (arr[middle] < target)
start = middle + 1;
else
end = middle - 1;
if (arr[middle] == target) {
return middle; // returns the index of the middle element
}
// Descending order
else {
if (arr[middle] > target)
if (ascOrd) {
// Ascending order
if (arr[middle] < target) {
start = middle + 1;
else
} else {
end = middle - 1;
}
} else {
// Descending order
if (arr[middle] > target) {
start = middle + 1;
} else {
end = middle - 1;
}
}
}
// Element is not present