Skip to content

Commit d1ff189

Browse files
committed
Fix Checkstyle violations in BTree and BTreeTest
1 parent 9b6c1a0 commit d1ff189

File tree

2 files changed

+12
-9
lines changed
  • src
    • main/java/com/thealgorithms/datastructures/trees
    • test/java/com/thealgorithms/datastructures/trees

2 files changed

+12
-9
lines changed

src/main/java/com/thealgorithms/datastructures/trees/BTree.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.thealgorithms.datastructures.trees;
22

33
import java.util.ArrayList;
4-
import java.util.Arrays;
54

65
public class BTree {
76
static class BTreeNode {
@@ -36,8 +35,8 @@ BTreeNode search(int key) {
3635
while (i < n && key > keys[i]) {
3736
i++;
3837
}
39-
if (i < n && keys[i] == key) return this;
40-
if (leaf) return null;
38+
if (i < n && keys[i] == key) {return this;}
39+
if (leaf) {return null;}
4140
return children[i].search(key);
4241
}
4342

@@ -115,7 +114,7 @@ void remove(int key) {
115114

116115
private int findKey(int key) {
117116
int idx = 0;
118-
while (idx < n && keys[idx] < key) ++idx;
117+
while (idx < n && keys[idx] < key) {++idx;}
119118
return idx;
120119
}
121120

@@ -262,7 +261,7 @@ public BTree(int t) {
262261
}
263262

264263
public void traverse(ArrayList<Integer> result) {
265-
if (root != null) root.traverse(result);
264+
if (root != null) {root.traverse(result);}
266265
}
267266

268267
public boolean search(int key) {
@@ -280,7 +279,7 @@ public void insert(int key) {
280279
s.children[0] = root;
281280
s.splitChild(0, root);
282281
int i = 0;
283-
if (s.keys[0] < key) i++;
282+
if (s.keys[0] < key) {i++;}
284283
s.children[i].insertNonFull(key);
285284
root = s;
286285
} else {
@@ -290,7 +289,7 @@ public void insert(int key) {
290289
}
291290

292291
public void delete(int key) {
293-
if (root == null) return;
292+
if (root == null) {return;}
294293
root.remove(key);
295294
if (root.n == 0) {
296295
root = root.leaf ? null : root.children[0];

src/test/java/com/thealgorithms/datastructures/trees/BTreeTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package com.thealgorithms.datastructures.trees;
22

3-
import static org.junit.jupiter.api.Assertions.*;
4-
import java.util.*;
3+
import static org.junit.jupiter.api.Assertions.assertTrue;
4+
import static org.junit.jupiter.api.Assertions.assertFalse;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
7+
import java.util.ArrayList;
8+
import java.util.Arrays;
59
import org.junit.jupiter.api.Test;
610

711
public class BTreeTest {

0 commit comments

Comments
 (0)