public interface PositionalList<E> extends Iterable<E>
Position
Modifier and Type | Method and Description |
---|---|
Position<E> |
addAfter(Position<E> p,
E e)
Inserts an element immediately after the given Position.
|
Position<E> |
addBefore(Position<E> p,
E e)
Inserts an element immediately before the given Position.
|
Position<E> |
addFirst(E e)
Inserts an element at the front of the list.
|
Position<E> |
addLast(E e)
Inserts an element at the back of the list.
|
Position<E> |
after(Position<E> p)
Returns the Position immediately after Position p.
|
Position<E> |
before(Position<E> p)
Returns the Position immediately before Position p.
|
Position<E> |
first()
Returns the first Position in the list.
|
boolean |
isEmpty()
Tests whether the list is empty.
|
Iterator<E> |
iterator()
Returns an iterator of the elements stored in the list.
|
Position<E> |
last()
Returns the last Position in the list.
|
Iterable<Position<E>> |
positions()
Returns the positions of the list in iterable form from first to last.
|
E |
remove(Position<E> p)
Removes the element stored at the given Position and returns it.
|
E |
set(Position<E> p,
E e)
Replaces the element stored at the given Position and returns the replaced element.
|
int |
size()
Returns the number of elements in the list.
|
int size()
boolean isEmpty()
Position<E> first()
Position<E> last()
Position<E> before(Position<E> p) throws IllegalArgumentException
p
- a Position of the listIllegalArgumentException
- if p is not a valid position for this listPosition<E> after(Position<E> p) throws IllegalArgumentException
p
- a Position of the listIllegalArgumentException
- if p is not a valid position for this listPosition<E> addFirst(E e)
e
- the new elementPosition<E> addLast(E e)
e
- the new elementPosition<E> addBefore(Position<E> p, E e) throws IllegalArgumentException
p
- the Position before which the insertion takes placee
- the new elementIllegalArgumentException
- if p is not a valid position for this listPosition<E> addAfter(Position<E> p, E e) throws IllegalArgumentException
p
- the Position after which the insertion takes placee
- the new elementIllegalArgumentException
- if p is not a valid position for this listE set(Position<E> p, E e) throws IllegalArgumentException
p
- the Position of the element to be replacede
- the new elementIllegalArgumentException
- if p is not a valid position for this listE remove(Position<E> p) throws IllegalArgumentException
p
- the Position of the element to be removedIllegalArgumentException
- if p is not a valid position for this list