Add automatic linter (#4214)

This commit is contained in:
acbin
2023-06-09 20:05:14 +08:00
committed by GitHub
parent 00282efd8b
commit 415a04ea7f
188 changed files with 661 additions and 1133 deletions

View File

@@ -66,11 +66,7 @@ class BinarySearch implements SearchAlgorithm {
int size = 100;
int maxElement = 100000;
Integer[] integers = IntStream.generate(() -> r.nextInt(maxElement))
.limit(size)
.sorted()
.boxed()
.toArray(Integer[] ::new);
Integer[] integers = IntStream.generate(() -> r.nextInt(maxElement)).limit(size).sorted().boxed().toArray(Integer[] ::new);
// The element that should be found
int shouldBeFound = integers[r.nextInt(size - 1)];
@@ -78,11 +74,9 @@ class BinarySearch implements SearchAlgorithm {
BinarySearch search = new BinarySearch();
int atIndex = search.find(integers, shouldBeFound);
System.out.printf("Should be found: %d. Found %d at index %d. An array length %d%n",
shouldBeFound, integers[atIndex], atIndex, size);
System.out.printf("Should be found: %d. Found %d at index %d. An array length %d%n", shouldBeFound, integers[atIndex], atIndex, size);
int toCheck = Arrays.binarySearch(integers, shouldBeFound);
System.out.printf(
"Found by system method at an index: %d. Is equal: %b%n", toCheck, toCheck == atIndex);
System.out.printf("Found by system method at an index: %d. Is equal: %b%n", toCheck, toCheck == atIndex);
}
}