add indexOf and lastIndexOf methods to java.util.List

This commit is contained in:
Joel Dice
2009-08-04 17:58:31 -06:00
parent 0a7f94abfe
commit 590238bbfc
5 changed files with 49 additions and 5 deletions

View File

@ -73,6 +73,24 @@ public class Arrays {
return false;
}
public int indexOf(Object element) {
for (int i = 0; i < array.length; ++i) {
if (equal(element, array[i])) {
return i;
}
}
return -1;
}
public int lastIndexOf(Object element) {
for (int i = array.length - 1; i >= 0; --i) {
if (equal(element, array[i])) {
return i;
}
}
return -1;
}
public T get(int index) {
return array[index];
}