net.datastructures
Interface PositionList<E>

All Superinterfaces:
java.lang.Iterable<E>
All Known Subinterfaces:
Sequence<E>
All Known Implementing Classes:
NodePositionList

public interface PositionList<E>
extends java.lang.Iterable<E>

An interface for positional lists.

Author:
Roberto Tamassia, Michael Goodrich

Method Summary
 void addAfter(Position<E> p, E e)
          Inserts an element after the given node in the list.
 void addBefore(Position<E> p, E e)
          Inserts an element before the given node in the list.
 void addFirst(E e)
          Inserts an element at the front of the list, returning new position.
 void addLast(E e)
          Inserts and element at the back of the list, returning new position.
 Position<E> first()
          Returns the first node in the list.
 boolean isEmpty()
          Returns whether the list is empty.
 java.util.Iterator<E> iterator()
          Returns an iterator of all the elements in the list.
 Position<E> last()
          Returns the last node in the list.
 Position<E> next(Position<E> p)
          Returns the node after a given node in the list.
 java.lang.Iterable<Position<E>> positions()
          Returns an iterable collection of all the nodes in the list.
 Position<E> prev(Position<E> p)
          Returns the node before a given node in the list.
 E remove(Position<E> p)
          Removes a node from the list, returning the element stored there.
 E set(Position<E> p, E e)
          Replaces the element stored at the given node, returning old element.
 int size()
          Returns the number of elements in this list.
 

Method Detail

size

int size()
Returns the number of elements in this list.


isEmpty

boolean isEmpty()
Returns whether the list is empty.


first

Position<E> first()
Returns the first node in the list.


last

Position<E> last()
Returns the last node in the list.


next

Position<E> next(Position<E> p)
                 throws InvalidPositionException,
                        BoundaryViolationException
Returns the node after a given node in the list.

Throws:
InvalidPositionException
BoundaryViolationException

prev

Position<E> prev(Position<E> p)
                 throws InvalidPositionException,
                        BoundaryViolationException
Returns the node before a given node in the list.

Throws:
InvalidPositionException
BoundaryViolationException

addFirst

void addFirst(E e)
Inserts an element at the front of the list, returning new position.


addLast

void addLast(E e)
Inserts and element at the back of the list, returning new position.


addAfter

void addAfter(Position<E> p,
              E e)
              throws InvalidPositionException
Inserts an element after the given node in the list.

Throws:
InvalidPositionException

addBefore

void addBefore(Position<E> p,
               E e)
               throws InvalidPositionException
Inserts an element before the given node in the list.

Throws:
InvalidPositionException

remove

E remove(Position<E> p)
         throws InvalidPositionException
Removes a node from the list, returning the element stored there.

Throws:
InvalidPositionException

set

E set(Position<E> p,
      E e)
      throws InvalidPositionException
Replaces the element stored at the given node, returning old element.

Throws:
InvalidPositionException

positions

java.lang.Iterable<Position<E>> positions()
Returns an iterable collection of all the nodes in the list.


iterator

java.util.Iterator<E> iterator()
Returns an iterator of all the elements in the list.

Specified by:
iterator in interface java.lang.Iterable<E>