n/**
n
* Uses binary search to find where and if an element
n
* is in a list.
n
* require:
n
* item != null
n
* ensure:
n
* if item == no element of
list
n
* indexOf(item, list) == -1
n
* else
n
* item == list.get(indexOf(item, list)),
n
* and indexOf(item, list) is the smallest
n
* value for which this is true
n
*/
npublic
int
indexOf(Student item,
n StudentList list){
n int i = itemIndex(item, list);
n if (i<list.size() &&
n list.get(i).equals(item))
n
return i;
n else
n
return -1;
n}