ch.bfh.algo.core
Interface GenericSequence<E,P extends GenericPosition<E,P>>

All Superinterfaces:
Collection<E>, Container<E>, GenericContainer<E,P>, Iterable<E>, List<E>, Sequence<E>
All Known Implementing Classes:
ArraySequence, DefaultBinaryForest, DefaultForest, DefaultGraph, GenericAdjacencyListGraph, GenericArraySequence, GenericBinaryForestGraph, GenericForestGraph, GenericLinkedSequence, LinkedSequence, ObserverSequence

public interface GenericSequence<E,P extends GenericPosition<E,P>>
extends GenericContainer<E,P>, Sequence<E>


Method Summary
 P after(Position<?> position)
          returns the Position that is placed after position in the sequence
 P before(Position<?> position)
          This method returns the position that is placed before the one given as argument in the sequence.
 P first()
          The method first() returns the Position containing the first element of the sequence.
 P insertAfter(Position<?> position, E element)
          This method insert element in the sequence.
 P insertBefore(Position<?> position, E element)
          This method insert element in the sequence.
 P last()
          The method last() returns the Position containing the last element of the sequence.
 P position(int rank)
          The position method returns the Position corresponding to a given rank.
 PositionListIterator<E,P> positionListIterator()
          The positionListIterator method creates and return a ListIterator for the Positions contained in the sequence.
 PositionListIterator<E,P> positionListIterator(int rank)
          The positionListIterator method creates and return a ListIterator for the Positions contained in the sequence.
 
Methods inherited from interface ch.bfh.algo.core.GenericContainer
insert, positionIterator
 
Methods inherited from interface ch.bfh.algo.Container
delete, element, encloses, replace, swap
 
Methods inherited from interface ch.bfh.algo.Sequence
rank
 
Methods inherited from interface ch.bfh.algo.Container
delete, element, encloses, replace, swap
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 

Method Detail

first

P first()
                                     throws EmptySequenceException
Description copied from interface: Sequence
The method first() returns the Position containing the first element of the sequence. It throws an EmptySequenceException if the sequence is empty.

Specified by:
first in interface Sequence<E>
Returns:
the first Position
Throws:
EmptySequenceException - if the sequence is empty.

last

P last()
                                    throws EmptySequenceException
Description copied from interface: Sequence
The method last() returns the Position containing the last element of the sequence. It throws an EmptySequenceException if the sequence is empty.

Specified by:
last in interface Sequence<E>
Returns:
the last Position in the sequence.
Throws:
EmptySequenceException - if the sequence is empty.

before

P before(Position<?> position)
                                      throws InvalidAccessorException,
                                             BoundaryViolationException
Description copied from interface: Sequence
This method returns the position that is placed before the one given as argument in the sequence.

Specified by:
before in interface Sequence<E>
Parameters:
position - Position
Returns:
the Position that is before the given one
Throws:
InvalidAccessorException - if position does not belong to this sequence.
BoundaryViolationException - if the given position is the first one (there is nothing before it in this case).

after

P after(Position<?> position)
                                     throws InvalidAccessorException,
                                            BoundaryViolationException
Description copied from interface: Sequence
returns the Position that is placed after position in the sequence

Specified by:
after in interface Sequence<E>
Parameters:
position - a Position<?>
Returns:
the Position after position
Throws:
InvalidAccessorException - if position does not belong to this sequence.
BoundaryViolationException - if the given position is the last one (there is nothing after it in this case).

insertBefore

P insertBefore(Position<?> position,
               E element)
                                            throws InvalidAccessorException
Description copied from interface: Sequence
This method insert element in the sequence. It creates a new Position that is inserted before position. The new position contains the new element and is returned by the method.

Specified by:
insertBefore in interface Sequence<E>
Parameters:
position - a Position<?>
Returns:
the new Position containing element
Throws:
InvalidAccessorException - if position does not belong to this sequence.

insertAfter

P insertAfter(Position<?> position,
              E element)
                                           throws InvalidAccessorException
Description copied from interface: Sequence
This method insert element in the sequence. It creates a new Position that is inserted after position. The new position contains the new element and is returned by the method.

Specified by:
insertAfter in interface Sequence<E>
Parameters:
position - a Position<?>
Returns:
the new Position containing element
Throws:
InvalidAccessorException - if position does not belong to this sequence.

position

P position(int rank)
                                        throws IndexOutOfBoundsException
Description copied from interface: Sequence
The position method returns the Position corresponding to a given rank. This method is a bridge between the methods of the List interface and the ones of the Sequence.

Specified by:
position in interface Sequence<E>
Parameters:
rank - an int that denotes the index of the researched position in the sequence.
Returns:
the new Position containing element
Throws:
IndexOutOfBoundsException - if rank is smaller than 0 or larger than or equal to the number of elements in the sequence.

positionListIterator

PositionListIterator<E,P> positionListIterator()
Description copied from interface: Sequence
The positionListIterator method creates and return a ListIterator for the Positions contained in the sequence. This method gives the possibility to iterate over all the Positions in the sequence.

Specified by:
positionListIterator in interface Sequence<E>
Returns:
a ListIterator<Position<E>> of all the Positions in the sequence.

positionListIterator

PositionListIterator<E,P> positionListIterator(int rank)
                                                                            throws IndexOutOfBoundsException
Description copied from interface: Sequence
The positionListIterator method creates and return a ListIterator for the Positions contained in the sequence. This iterator is initially placed at the rank given as a parmeter This method gives the possibility to iterate over all the Positions in the sequence.

Specified by:
positionListIterator in interface Sequence<E>
Parameters:
rank - an int denoting the initial position of the pointer of the iterator.
Returns:
a ListIterator<Position<E>> of all the Positions in the sequence.
Throws:
IndexOutOfBoundsException - if rank is smaller than 0 or larger than the number of elements in the sequence.