datastructures

net.datastructures
Interface List

All Known Subinterfaces:
Sequence
All Known Implementing Classes:
NodeList, NodeSequence

public interface List

An interface for a list.

Author:
Roberto Tamassia, Michael Goodrich

Method Summary
 Iterator elements()
          Returns an iterator of all the elements in the list.
 Position first()
          Returns the first node in the list.
 Position insertAfter(Position p, Object e)
          Inserts an element after the given node in the list.
 Position insertBefore(Position p, Object e)
          Inserts an element before the given node in the list.
 Position insertFirst(Object e)
          Inserts an element at the front of the list.
 Position insertLast(Object e)
          Inserts and element at the back of the list.
 boolean isEmpty()
          Returns whether the list is empty.
 Position last()
          Returns the last node in the list.
 Position next(Position p)
          Returns the node after a given node in the list.
 Iterator positions()
          Returns an iterator of all the nodes in the list.
 Position prev(Position p)
          Returns the node before a given node in the list.
 Object remove(Position p)
          Removes a node from the list.
 Object replace(Position p, Object e)
          Replaces the element stored at the given node.
 int size()
          Returns the number of elements in this list.
 

Method Detail

size

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


isEmpty

public boolean isEmpty()
Returns whether the list is empty.


first

public Position first()
Returns the first node in the list.


last

public Position last()
Returns the last node in the list.


next

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

Throws:
InvalidPositionException
BoundaryViolationException

prev

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

Throws:
InvalidPositionException
BoundaryViolationException

insertFirst

public Position insertFirst(Object e)
Inserts an element at the front of the list.


insertLast

public Position insertLast(Object e)
Inserts and element at the back of the list.


insertAfter

public Position insertAfter(Position p,
                            Object e)
                     throws InvalidPositionException
Inserts an element after the given node in the list.

Throws:
InvalidPositionException

insertBefore

public Position insertBefore(Position p,
                             Object e)
                      throws InvalidPositionException
Inserts an element before the given node in the list.

Throws:
InvalidPositionException

remove

public Object remove(Position p)
              throws InvalidPositionException
Removes a node from the list.

Throws:
InvalidPositionException

replace

public Object replace(Position p,
                      Object e)
               throws InvalidPositionException
Replaces the element stored at the given node.

Throws:
InvalidPositionException

positions

public Iterator positions()
Returns an iterator of all the nodes in the list.


elements

public Iterator elements()
Returns an iterator of all the elements in the list.


datastructures