Skip to content

Commit c368341

Browse files
author
sailok.chinta
committed
feat: fix clang format issues & checkstyle issues
1 parent c23a556 commit c368341

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ class BoundingBox {
4343
* @return true if the point is inside the bounding box, false otherwise
4444
*/
4545
public boolean containsPoint(Point point) {
46-
return point.x >= center.x - halfWidth
47-
&& point.x <= center.x + halfWidth
48-
&& point.y >= center.y - halfWidth
49-
&& point.y <= center.y + halfWidth;
46+
return point.x >= center.x - halfWidth && point.x <= center.x + halfWidth && point.y >= center.y - halfWidth && point.y <= center.y + halfWidth;
5047
}
5148

5249
/**
@@ -56,10 +53,8 @@ public boolean containsPoint(Point point) {
5653
* @return true if the bounding box intersects with the other bounding box, false otherwise
5754
*/
5855
public boolean intersectsBoundingBox(BoundingBox otherBoundingBox) {
59-
return otherBoundingBox.center.x - otherBoundingBox.halfWidth <= center.x + halfWidth
60-
&& otherBoundingBox.center.x + otherBoundingBox.halfWidth >= center.x - halfWidth
61-
&& otherBoundingBox.center.y - otherBoundingBox.halfWidth <= center.y + halfWidth
62-
&& otherBoundingBox.center.y + otherBoundingBox.halfWidth >= center.y - halfWidth;
56+
return otherBoundingBox.center.x - otherBoundingBox.halfWidth <= center.x + halfWidth && otherBoundingBox.center.x + otherBoundingBox.halfWidth >= center.x - halfWidth && otherBoundingBox.center.y - otherBoundingBox.halfWidth <= center.y + halfWidth
57+
&& otherBoundingBox.center.y + otherBoundingBox.halfWidth >= center.y - halfWidth;
6358
}
6459
}
6560

@@ -123,10 +118,21 @@ public boolean insert(Point point) {
123118
}
124119

125120
// try to add the point in one of the four quadrants
126-
if (northWest.insert(point)) return true;
127-
if (northEast.insert(point)) return true;
128-
if (southWest.insert(point)) return true;
129-
if (southEast.insert(point)) return true;
121+
if (northWest.insert(point)) {
122+
return true;
123+
}
124+
125+
if (northEast.insert(point)) {
126+
return true;
127+
}
128+
129+
if (southWest.insert(point)) {
130+
return true;
131+
}
132+
133+
if (southEast.insert(point)) {
134+
return true;
135+
}
130136

131137
return false;
132138
}

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

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

3+
import java.util.List;
34
import org.junit.jupiter.api.Assertions;
45
import org.junit.jupiter.api.Test;
56

6-
import java.util.List;
7-
87
public class QuadTreeTest {
98
int quadTreeCapacity = 4;
109
BoundingBox boundingBox = new BoundingBox(new Point(0, 0), 500);

0 commit comments

Comments
 (0)