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

@@ -231,7 +231,9 @@ public class FibonacciHeap {
private void cascadingCuts(HeapNode curr) {
if (!curr.isMarked()) { // stop the recursion
curr.mark();
if (!curr.isRoot()) this.markedHeapNoodesCounter++;
if (!curr.isRoot()) {
this.markedHeapNoodesCounter++;
}
} else {
if (curr.isRoot()) {
return;

View File

@@ -56,9 +56,13 @@ public class LeftistHeap {
// Function merge with two Nodes a and b
public Node merge(Node a, Node b) {
if (a == null) return b;
if (a == null) {
return b;
}
if (b == null) return a;
if (b == null) {
return a;
}
// Violates leftist property, so must do a swap
if (a.element > b.element) {
@@ -93,7 +97,9 @@ public class LeftistHeap {
// Returns and removes the minimum element in the heap
public int extractMin() {
// If is empty return -1
if (isEmpty()) return -1;
if (isEmpty()) {
return -1;
}
int min = root.element;
root = merge(root.left, root.right);
@@ -109,7 +115,9 @@ public class LeftistHeap {
// Auxiliary function for in_order
private void inOrderAux(Node n, ArrayList<Integer> lst) {
if (n == null) return;
if (n == null) {
return;
}
inOrderAux(n.left, lst);
lst.add(n.element);
inOrderAux(n.right, lst);

View File

@@ -98,11 +98,13 @@ public class MaxHeap implements Heap {
@Override
public void deleteElement(int elementIndex) {
if (maxHeap.isEmpty()) try {
if (maxHeap.isEmpty()) {
try {
throw new EmptyHeapException("Attempt to delete an element from an empty heap");
} catch (EmptyHeapException e) {
e.printStackTrace();
}
}
if ((elementIndex > maxHeap.size()) || (elementIndex <= 0)) {
throw new IndexOutOfBoundsException("Index out of heap range");
}

View File

@@ -92,11 +92,13 @@ public class MinHeap implements Heap {
@Override
public void deleteElement(int elementIndex) {
if (minHeap.isEmpty()) try {
if (minHeap.isEmpty()) {
try {
throw new EmptyHeapException("Attempt to delete an element from an empty heap");
} catch (EmptyHeapException e) {
e.printStackTrace();
}
}
if ((elementIndex > minHeap.size()) || (elementIndex <= 0)) {
throw new IndexOutOfBoundsException("Index out of heap range");
}