@@ -26,37 +26,37 @@ public static void main(String[] args) {
26
26
27
27
System .out .println ("\n Simple solution for numbers:" );
28
28
long startTimeV1 = clock .millis ();
29
- boolean found1 = ArrayFinds .containsElementV1 (numbers .clone (), 1 );
29
+ boolean found1 = ArraySearch .containsElementV1 (numbers .clone (), 1 );
30
30
displayExecutionTime (clock .millis () - startTimeV1 );
31
31
System .out .println ("The element was found?: " + found1 );
32
32
33
33
System .out .println ("\n Solution based on Arrays.binarySearch() for numbers:" );
34
34
long startTimeV2 = clock .millis ();
35
- boolean found2 = ArrayFinds .containsElementV2 (numbers .clone (), 1 );
35
+ boolean found2 = ArraySearch .containsElementV2 (numbers .clone (), 1 );
36
36
displayExecutionTime (clock .millis () - startTimeV2 );
37
37
System .out .println ("The element was found?: " + found2 );
38
38
39
39
System .out .println ("\n Solution based on Stream.anyMatch() for numbers:" );
40
40
long startTimeV3 = clock .millis ();
41
- boolean found3 = ArrayFinds .containsElementV3 (numbers .clone (), 1 );
41
+ boolean found3 = ArraySearch .containsElementV3 (numbers .clone (), 1 );
42
42
displayExecutionTime (clock .millis () - startTimeV3 );
43
43
System .out .println ("The element was found?: " + found3 );
44
44
45
45
System .out .println ("\n Simple solution for Melon:" );
46
46
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 ));
48
48
displayExecutionTime (clock .millis () - startTimeV4 );
49
49
System .out .println ("The Melon was found?: " + found4 );
50
50
51
51
System .out .println ("\n Solution based on Comparator for Melon:" );
52
52
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 );
54
54
displayExecutionTime (clock .millis () - startTimeV5 );
55
55
System .out .println ("The Melon was found?: " + found5 );
56
56
57
57
System .out .println ("\n Solution based on binarySearch() for Melon:" );
58
58
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 );
60
60
displayExecutionTime (clock .millis () - startTimeV6 );
61
61
System .out .println ("The Melon was found?: " + found6 );
62
62
@@ -65,31 +65,31 @@ public static void main(String[] args) {
65
65
66
66
System .out .println ("\n Simple solution for numbers:" );
67
67
long startTimeV7 = clock .millis ();
68
- int index1 = ArrayFinds .findIndexOfElementV1 (numbers .clone (), 7 );
68
+ int index1 = ArraySearch .findIndexOfElementV1 (numbers .clone (), 7 );
69
69
displayExecutionTime (clock .millis () - startTimeV7 );
70
70
System .out .println ("Found at index (-1 means not found): " + index1 );
71
71
72
72
System .out .println ("\n Solution based on filter() for numbers:" );
73
73
long startTimeV8 = clock .millis ();
74
- int index2 = ArrayFinds .findIndexOfElementV2 (numbers .clone (), 7 );
74
+ int index2 = ArraySearch .findIndexOfElementV2 (numbers .clone (), 7 );
75
75
displayExecutionTime (clock .millis () - startTimeV8 );
76
76
System .out .println ("Found at index (-1 means not found): " + index2 );
77
77
78
78
System .out .println ("\n Simple solution for Melon:" );
79
79
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 ));
81
81
displayExecutionTime (clock .millis () - startTimeV9 );
82
82
System .out .println ("Melon found at index (-1 means not found): " + index3 );
83
83
84
84
System .out .println ("\n Solution based on Comparator for Melon:" );
85
85
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 );
87
87
displayExecutionTime (clock .millis () - startTimeV10 );
88
88
System .out .println ("Melon found at index (-1 means not found): " + index4 );
89
89
90
90
System .out .println ("\n Solution based on filter() and Comparator for Melon:" );
91
91
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 );
93
93
displayExecutionTime (clock .millis () - startTimeV11 );
94
94
System .out .println ("Melon found at index (-1 means not found): " + index5 );
95
95
}
0 commit comments