public interface MyList<E> extends MyCollection<E>
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
E element)
Inserts the specified element at the specified position in this list.
|
E |
get(int index)
Returns the element at the specified position in this list.
|
int |
indexOf(E o)
Returns the index of the first occurrence of the specified element
in this list, or -1 if this list does not contain the element.
|
int |
lastIndexOf(E o)
Returns the index of the last occurrence of the specified element
in this list, or -1 if this list does not contain the element.
|
E |
remove(int index)
Removes the element at the specified position in this list.
|
E |
set(int index,
E element)
Replaces the element at the specified position in this list with the
specified element
|
E get(int index)
index
- index of the element to returnjava.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())E set(int index, E element)
index
- index of the element to replaceelement
- element to be stored at the specified position. Assume not null.java.lang.IndexOutOfBoundsException
- if the index is out of rangevoid add(int index, E element)
index
- index at which the specified element is to be insertedelement
- element to be inserted. Assume not null.java.lang.IndexOutOfBoundsException
- if the index is out of rangeE remove(int index)
index
- the index of the element to be removedjava.lang.IndexOutOfBoundsException
- if the index is out of rangeint indexOf(E o)
o
- element to search for. Assume o is not nullint lastIndexOf(E o)
o
- element to search for. Assume o is not null.