Skip to content

Commit 000ad84

Browse files
committed
Adjust field name: min_index->minIndex
1 parent aa931aa commit 000ad84

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/main/java/by/andd3dfx/collections/ContainsDuplicates.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package by.andd3dfx.collections;
22

33
import java.util.HashSet;
4-
import java.util.Set;
54

65
/**
76
* <pre>
@@ -29,7 +28,7 @@
2928
public class ContainsDuplicates {
3029

3130
public boolean usingSet(int[] nums) {
32-
Set<Integer> set = new HashSet<>();
31+
var set = new HashSet<Integer>();
3332
for (int num : nums) {
3433
if (!set.add(num)) {
3534
return true;
@@ -40,18 +39,18 @@ public boolean usingSet(int[] nums) {
4039

4140
public boolean usingSortWithEarlyReturn(int[] nums) {
4241
for (int i = 0; i < nums.length; i++) {
43-
int min_index = i;
42+
int minIndex = i;
4443

4544
for (int j = i + 1; j < nums.length; j++) {
46-
if (nums[j] == nums[min_index]) {
45+
if (nums[j] == nums[minIndex]) {
4746
return true;
4847
}
49-
if (nums[j] < nums[min_index]) {
50-
min_index = j;
48+
if (nums[j] < nums[minIndex]) {
49+
minIndex = j;
5150
}
5251
}
5352

54-
swap(nums, i, min_index);
53+
swap(nums, i, minIndex);
5554
}
5655
return false;
5756
}

src/main/java/by/andd3dfx/sorting/SelectionSort.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ public class SelectionSort {
77

88
public static <T extends Comparable> void apply(T[] array) {
99
for (int i = 0; i < array.length; i++) {
10-
int min_index = i;
10+
int minIndex = i;
1111

1212
for (int j = i + 1; j < array.length; j++) {
13-
if (lessThan(array[j], array[min_index])) min_index = j;
13+
if (lessThan(array[j], array[minIndex])) minIndex = j;
1414
}
1515

16-
swap(array, i, min_index);
16+
swap(array, i, minIndex);
1717
}
1818
}
1919

0 commit comments

Comments
 (0)