mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-30 07:54:05 +08:00
Format code with prettier (#3375)
This commit is contained in:
@ -1,24 +1,24 @@
|
||||
package com.thealgorithms.datastructures.trees;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class KDTreeTest {
|
||||
|
||||
KDTree.Point pointOf(int x, int y) {
|
||||
return new KDTree.Point(new int[]{x, y});
|
||||
return new KDTree.Point(new int[] { x, y });
|
||||
}
|
||||
|
||||
@Test
|
||||
void findMin() {
|
||||
int[][] coordinates = {
|
||||
{30, 40},
|
||||
{5, 25},
|
||||
{70, 70},
|
||||
{10, 12},
|
||||
{50, 30},
|
||||
{35, 45}
|
||||
{ 30, 40 },
|
||||
{ 5, 25 },
|
||||
{ 70, 70 },
|
||||
{ 10, 12 },
|
||||
{ 50, 30 },
|
||||
{ 35, 45 },
|
||||
};
|
||||
KDTree kdTree = new KDTree(coordinates);
|
||||
|
||||
@ -29,12 +29,12 @@ public class KDTreeTest {
|
||||
@Test
|
||||
void delete() {
|
||||
int[][] coordinates = {
|
||||
{30, 40},
|
||||
{5, 25},
|
||||
{70, 70},
|
||||
{10, 12},
|
||||
{50, 30},
|
||||
{35, 45}
|
||||
{ 30, 40 },
|
||||
{ 5, 25 },
|
||||
{ 70, 70 },
|
||||
{ 10, 12 },
|
||||
{ 50, 30 },
|
||||
{ 35, 45 },
|
||||
};
|
||||
KDTree kdTree = new KDTree(coordinates);
|
||||
|
||||
@ -46,12 +46,12 @@ public class KDTreeTest {
|
||||
@Test
|
||||
void findNearest() {
|
||||
int[][] coordinates = {
|
||||
{2, 3},
|
||||
{5, 4},
|
||||
{9, 6},
|
||||
{4, 7},
|
||||
{8, 1},
|
||||
{7, 2}
|
||||
{ 2, 3 },
|
||||
{ 5, 4 },
|
||||
{ 9, 6 },
|
||||
{ 4, 7 },
|
||||
{ 8, 1 },
|
||||
{ 7, 2 },
|
||||
};
|
||||
KDTree kdTree = new KDTree(coordinates);
|
||||
|
||||
@ -60,5 +60,4 @@ public class KDTreeTest {
|
||||
assertEquals(pointOf(2, 3), kdTree.findNearest(pointOf(1, 1)));
|
||||
assertEquals(pointOf(5, 4), kdTree.findNearest(pointOf(5, 5)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package com.thealgorithms.datastructures.trees;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class LazySegmentTreeTest {
|
||||
|
||||
@Test
|
||||
void build() {
|
||||
int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
LazySegmentTree lazySegmentTree = new LazySegmentTree(arr);
|
||||
assertEquals(55, lazySegmentTree.getRoot().getValue());
|
||||
assertEquals(15, lazySegmentTree.getRoot().getLeft().getValue());
|
||||
@ -17,7 +17,7 @@ public class LazySegmentTreeTest {
|
||||
|
||||
@Test
|
||||
void update() {
|
||||
int[] arr = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
int[] arr = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||
LazySegmentTree lazySegmentTree = new LazySegmentTree(arr);
|
||||
assertEquals(10, lazySegmentTree.getRoot().getValue());
|
||||
|
||||
@ -36,7 +36,7 @@ public class LazySegmentTreeTest {
|
||||
|
||||
@Test
|
||||
void get() {
|
||||
int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
LazySegmentTree lazySegmentTree = new LazySegmentTree(arr);
|
||||
assertEquals(55, lazySegmentTree.getRange(0, 10));
|
||||
assertEquals(3, lazySegmentTree.getRange(0, 2));
|
||||
@ -46,7 +46,7 @@ public class LazySegmentTreeTest {
|
||||
|
||||
@Test
|
||||
void updateAndGet() {
|
||||
int[] arr = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
int[] arr = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
LazySegmentTree lazySegmentTree = new LazySegmentTree(arr);
|
||||
|
||||
for (int i = 0; i < 10; i++) for (int j = i + 1; j < 10; j++) {
|
||||
@ -56,5 +56,4 @@ public class LazySegmentTreeTest {
|
||||
assertEquals(0, lazySegmentTree.getRange(i, j));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user