8000 update · githubcs/Java-Coding-Problems@d670e9f · GitHub
[go: up one dir, main page]

Skip to content

Commit d670e9f

Browse files
committed
update
1 parent 9c2558d commit d670e9f

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

Chapter_05/P100_FindElementInArray/src/modern/challenge/ArrayFinds.java renamed to Chapter_05/P100_FindElementInArray/src/modern/challenge/ArraySearch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import java.util.Comparator;
55
import java.util.stream.IntStream;
66

7-
public final class ArrayFinds {
7+
public final class ArraySearch {
88

9-
private ArrayFinds() {
9+
private ArraySearch() {
1010
throw new AssertionError("Cannot be instantiated");
1111
}
1212

Chapter_05/P100_FindElementInArray/src/modern/challenge/Main.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,37 @@ public static void main(String[] args) {
2626

2727
System.out.println("\nSimple solution for numbers:");
2828
long startTimeV1 = clock.millis();
29-
boolean found1 = ArrayFinds.containsElementV1(numbers.clone(), 1);
29+
boolean found1 = ArraySearch.containsElementV1(numbers.clone(), 1);
3030
displayExecutionTime(clock.millis() - startTimeV1);
3131
System.out.println("The element was found?: " + found1);
3232

3333
System.out.println("\nSolution based on Arrays.binarySearch() for numbers:");
3434
long startTimeV2 = clock.millis();
35-
boolean found2 = ArrayFinds.containsElementV2(numbers.clone(), 1);
35+
boolean found2 = ArraySearch.containsElementV2(numbers.clone(), 1);
3636
displayExecutionTime(clock.millis() - startTimeV2);
3737
System.out.println("The element was found?: " + found2);
3838

3939
System.out.println("\nSolution based on Stream.anyMatch() for numbers:");
4040
long startTimeV3 = clock.millis();
41-
boolean found3 = ArrayFinds.containsElementV3(numbers.clone(), 1);
41+
boolean found3 = ArraySearch.containsElementV3(numbers.clone(), 1);
4242
displayExecutionTime(clock.millis() - startTimeV3);
4343
System.out.println("The element was found?: " + found3);
4444

4545
System.out.println("\nSimple solution for Melon:");
4646
long startTimeV4 = clock.millis();
47-
boolean found4 = ArrayFinds.containsElementObjectV1(melons.clone(), new Melon("Gac", 1200));
47+
boolean found4 = ArraySearch.containsElementObjectV1(melons.clone(), new Melon("Gac", 1200));
4848
displayExecutionTime(clock.millis() - startTimeV4);
4949
System.out.println("The Melon was found?: " + found4);
5050

5151
System.out.println("\nSolution based on Comparator for Melon:");
5252
long startTimeV5 = clock.millis();
53-
boolean found5 = ArrayFinds.containsElementObjectV2(melons.clone(), new Melon("Gac", 1205), byType);
53+
boolean found5 = ArraySearch.containsElementObjectV2(melons.clone(), new Melon("Gac", 1205), byType);
5454
displayExecutionTime(clock.millis() - startTimeV5);
5555
System.out.println("The Melon was found?: " + found5);
5656

5757
System.out.println("\nSolution based on binarySearch() for Melon:");
5858
long startTimeV6 = clock.millis();
59-
boolean found6 = ArrayFinds.containsElementObjectV3(melons.clone(), new Melon("Honeydew", 1200), byWeight);
59+
boolean found6 = ArraySearch.containsElementObjectV3(melons.clone(), new Melon("Honeydew", 1200), byWeight);
6060
displayExecutionTime(clock.millis() - startTimeV6);
6161
System.out.println("The Melon was found?: " + found6);
6262

@@ -65,31 +65,31 @@ public static void main(String[] args) {
6565

6666
System.out.println("\nSimple solution for numbers:");
6767
long startTimeV7 = clock.millis();
68-
int index1 = ArrayFinds.findIndexOfElementV1(numbers.clone(), 7);
68+
int index1 = ArraySearch.findIndexOfElementV1(numbers.clone(), 7);
6969
displayExecutionTime(clock.millis() - startTimeV7);
7070
System.out.println("Found at index (-1 means not found): " + index1);
7171

7272
System.out.println("\nSolution based on filter() for numbers:");
7373
long startTimeV8 = clock.millis();
74-
int index2 = ArrayFinds.findIndexOfElementV2(numbers.clone(), 7);
74+
int index2 = ArraySearch.findIndexOfElementV2(numbers.clone(), 7);
7575
displayExecutionTime(clock.millis() - startTimeV8);
7676
System.out.println("Found at index (-1 means not found): " + index2);
7777

7878
System.out.println("\nSimple solution for Melon:");
7979
long startTimeV9 = clock.millis();
80-
int index3 = ArrayFinds.findIndexOfElementObjectV1(melons.clone(), new Melon("Gac", 1200));
80+
int index3 = ArraySearch.findIndexOfElementObjectV1(melons.clone(), new Melon("Gac", 1200));
8181
displayExecutionTime(clock.millis() - startTimeV9);
8282
System.out.println("Melon found at index (-1 means not found): " + index3);
8383

8484
System.out.println("\nSolution based on Comparator for Melon:");
8585
long startTimeV10 = clock.millis();
86-
int index4 = ArrayFinds.findIndexOfElementObjectV2(melons.clone(), new Melon("Gac", 1205), byType);
86+
int index4 = ArraySearch.findIndexOfElementObjectV2(melons.clone(), new Melon("Gac", 1205), byType);
8787
displayExecutionTime(clock.millis() - startTimeV10);
8888
System.out.println("Melon found at index (-1 means not found): " + index4);
8989

9090
System.out.println("\nSolution based on filter() and Comparator for Melon:");
9191
long startTimeV11 = clock.millis();
92-
int index5 = ArrayFinds.findIndexOfElementObjectV3(melons.clone(), new Melon("Honeydew", 1200), byWeight);
92+
int index5 = ArraySearch.findIndexOfElementObjectV3(melons.clone(), new Melon("Honeydew", 1200), byWeight);
9393
displayExecutionTime(clock.millis() - startTimeV11);
9494
System.out.println("Melon found at index (-1 means not found): " + index5);
9595
}

0 commit comments

Comments
 (0)
0