Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ public class LinearSearch implements SearchAlgorithm {
*
* @param array List to be searched
* @param value Key being searched for
* @return Location of the key
* @return Location of the key, -1 if array is null or empty, or key not found
*/
@Override
public <T extends Comparable<T>> int find(T[] array, T value) {
if (array == null || array.length == 0) {
return -1;
}
for (int i = 0; i < array.length; i++) {
if (array[i].compareTo(value) == 0) {
return i;
Expand Down
Loading