public interface ListADT<E>
extends java.lang.Iterable<E>
Modifier and Type | Method and Description |
---|---|
void |
add(E item)
Add item to the end of the list.
|
void |
add(int pos,
E item)
Add item to the pos index of the list.
|
boolean |
contains(E item)
Returns true iff item is in the List.
|
E |
get(int pos)
Returns a reference to the item at the specified position.
|
boolean |
isEmpty()
Returns true iff the list has no items.
|
E |
remove(int pos)
removes and returns the item at position pos in the List,
moving the items originally in positions pos+1 through size()-1
one place to the left to fill in the gap (error if pos is less
than 0 or greater than or equal to size())
|
int |
size()
Return the number of items in the List.
|
void add(E item)
item
- The item to be added.void add(int pos, E item)
pos
- The index where the item will be placed.item
- The item to be added.boolean contains(E item)
item
- The item to match.int size()
boolean isEmpty()
E get(int pos)
pos
- The index of the desired item.E remove(int pos)
pos
- the index of the item to removejava.lang.IndexOutOfBoundsException
- if pos is less than zero or greater than size - 1