style: include VA_FORMAT_STRING_USES_NEWLINE (#5151)

This commit is contained in:
Piotr Idzik 2024-05-09 17:21:04 +02:00 committed by GitHub
parent 7bff82f175
commit 27c0978851
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 8 additions and 11 deletions

View File

@ -8,9 +8,6 @@
<Match> <Match>
<Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" /> <Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" />
</Match> </Match>
<Match>
<Bug pattern="VA_FORMAT_STRING_USES_NEWLINE" />
</Match>
<Match> <Match>
<Bug pattern="SF_SWITCH_NO_DEFAULT" /> <Bug pattern="SF_SWITCH_NO_DEFAULT" />
</Match> </Match>

View File

@ -213,7 +213,7 @@ public class HashMapCuckooHashing {
public double checkLoadFactor() { public double checkLoadFactor() {
double factor = (double) size / tableSize; double factor = (double) size / tableSize;
if (factor > .7) { if (factor > .7) {
System.out.printf("Load factor is %.2f , rehashing table\n", factor); System.out.printf("Load factor is %.2f , rehashing table%n", factor);
reHashTableIncreasesTableSize(); reHashTableIncreasesTableSize();
} }
return factor; return factor;

View File

@ -54,7 +54,7 @@ public final class MainCuckooHashing {
break; break;
} }
case 6: { case 6: {
System.out.printf("Load factor is: %.2f\n", h.checkLoadFactor()); System.out.printf("Load factor is: %.2f%n", h.checkLoadFactor());
break; break;
} }
case 7: { case 7: {

View File

@ -81,7 +81,7 @@ public final class CreateAndDetectLoop {
System.out.println("Enter the number of elements to be inserted: "); System.out.println("Enter the number of elements to be inserted: ");
int n = sc.nextInt(); int n = sc.nextInt();
System.out.printf("Enter the %d elements: \n", n); System.out.printf("Enter the %d elements: %n", n);
while (n-- > 0) { while (n-- > 0) {
singlyLinkedList.insert(sc.nextInt()); singlyLinkedList.insert(sc.nextInt());
} }

View File

@ -12,7 +12,7 @@ final class TowerOfHanoi {
// Shift function is called in recursion for swapping the n-1 disc from the startPole to // Shift function is called in recursion for swapping the n-1 disc from the startPole to
// the intermediatePole // the intermediatePole
shift(n - 1, startPole, endPole, intermediatePole); shift(n - 1, startPole, endPole, intermediatePole);
System.out.format("Move %d from %s to %s\n", n, startPole, endPole); // Result Printing System.out.format("Move %d from %s to %s%n", n, startPole, endPole); // Result Printing
// Shift function is called in recursion for swapping the n-1 disc from the // Shift function is called in recursion for swapping the n-1 disc from the
// intermediatePole to the endPole // intermediatePole to the endPole
shift(n - 1, intermediatePole, startPole, endPole); shift(n - 1, intermediatePole, startPole, endPole);

View File

@ -78,7 +78,7 @@ public class MonteCarloTreeSearch {
winnerNode = getWinnerNode(rootNode); winnerNode = getWinnerNode(rootNode);
printScores(rootNode); printScores(rootNode);
System.out.format("\nThe optimal node is: %02d\n", rootNode.childNodes.indexOf(winnerNode) + 1); System.out.format("%nThe optimal node is: %02d%n", rootNode.childNodes.indexOf(winnerNode) + 1);
return winnerNode; return winnerNode;
} }

View File

@ -71,13 +71,13 @@ class InsertionSort implements SortAlgorithm {
InsertionSort insertionSort = new InsertionSort(); InsertionSort insertionSort = new InsertionSort();
double insertionTime = measureApproxExecTime(insertionSort::sort, randomArray); double insertionTime = measureApproxExecTime(insertionSort::sort, randomArray);
System.out.printf("Original insertion time: %5.2f sec.\n", insertionTime); System.out.printf("Original insertion time: %5.2f sec.%n", insertionTime);
double insertionSentinelTime = measureApproxExecTime(insertionSort::sentinelSort, copyRandomArray); double insertionSentinelTime = measureApproxExecTime(insertionSort::sentinelSort, copyRandomArray);
System.out.printf("Sentinel insertion time: %5.2f sec.\n", insertionSentinelTime); System.out.printf("Sentinel insertion time: %5.2f sec.%n", insertionSentinelTime);
// ~ 1.5 time sentinel sort is faster, then classical Insertion sort implementation. // ~ 1.5 time sentinel sort is faster, then classical Insertion sort implementation.
System.out.printf("Sentinel insertion is %f3.2 time faster than Original insertion sort\n", insertionTime / insertionSentinelTime); System.out.printf("Sentinel insertion is %f3.2 time faster than Original insertion sort%n", insertionTime / insertionSentinelTime);
} }
private static double measureApproxExecTime(Function<Double[], Double[]> sortAlgorithm, Double[] randomArray) { private static double measureApproxExecTime(Function<Double[], Double[]> sortAlgorithm, Double[] randomArray) {