public interface ListADT<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 at position pos in the List, moving the items originally in
positions pos through size() - 1 one place to the right to make room.
|
boolean |
contains(E item)
Return true iff item is in the List (i.e., there is an item x in the List
such that x.equals(item))
|
E |
get(int pos)
Return the item at position pos in the List.
|
boolean |
isEmpty()
Return true iff the List is empty.
|
E |
remove(int pos)
Remove and return 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.
|
int |
size()
Return the number of items in the List.
|
void add(E item)
item
- the item to addjava.lang.IllegalArgumentException
- if item is nullvoid add(int pos, E item)
pos
- the position at which to add the itemitem
- the item to addjava.lang.IllegalArgumentException
- if item is nulljava.lang.IndexOutOfBoundsException
- if pos is less than 0 or greater
than size()boolean contains(E item)
item
- the item to checkint size()
boolean isEmpty()
E get(int pos)
pos
- the position of the item to returnjava.lang.IndexOutOfBoundsException
- if pos is less than 0 or greater than
or equal to size()E remove(int pos)
pos
- the position at which to remove the itemjava.lang.IndexOutOfBoundsException
- if pos is less than 0 or greater than
or equal to size()