Package dsa
Class LinearSearch
- java.lang.Object
-
- dsa.LinearSearch
-
public class LinearSearch extends Object
This library implements linear search.
-
-
Constructor Summary
Constructors Constructor Description LinearSearch()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
indexOf(double[] a, double key)
Returns the index ofkey
in the arraya
, or -1.static int
indexOf(int[] a, int key)
Returns the index ofkey
in the arraya
, or -1.static int
indexOf(Object[] a, Object key)
Returns the index ofkey
in the arraya
, or -1.static void
main(String[] args)
Unit tests the library.
-
-
-
Method Detail
-
indexOf
public static int indexOf(Object[] a, Object key)
Returns the index ofkey
in the arraya
, or -1.- Parameters:
a
- array of objects.key
- search key.- Returns:
- the index of
key
in the arraya
, or -1.
-
indexOf
public static int indexOf(int[] a, int key)
Returns the index ofkey
in the arraya
, or -1.- Parameters:
a
- array of objects.key
- search key.- Returns:
- the index of
key
in the arraya
, or -1.
-
indexOf
public static int indexOf(double[] a, double key)
Returns the index ofkey
in the arraya
, or -1.- Parameters:
a
- array of objects.key
- search key.- Returns:
- the index of
key
in the arraya
, or -1.
-
main
public static void main(String[] args)
Unit tests the library.- Parameters:
args
- the command-line arguments.
-
-