ch.bfh.algo
Interface Container<E>

Type Parameters:
E - The type of the elements contained in this Container.
All Superinterfaces:
Collection<E>, Iterable<E>
All Known Subinterfaces:
BinaryForest<E>, Forest<E>, GenericBinaryForest<E,P>, GenericContainer<E,P>, GenericForest<E,P>, GenericGraph<E,V,PE,PV>, GenericSequence<E,P>, Graph<E,V>, Sequence<E>
All Known Implementing Classes:
ArraySequence, DefaultBinaryForest, DefaultForest, DefaultGraph, GenericAdjacencyListGraph, GenericArraySequence, GenericBinaryForestGraph, GenericForestGraph, GenericLinkedSequence, LinkedSequence, ObserverSequence

public interface Container<E>
extends Collection<E>

A Container is a Collection of elements. An element can be directly accessed, it is manipulated through its Position in the Container. The additional methods depend all on the Position-based behaviour of the elements of a Container.

Version:
1.0
Author:
Juerg Kraehenbuehl (code) and Emmanuel Benoist, Bernhard Anrig (Javadoc)

Method Summary
 E delete(Position<?> position)
           Deletes the specified position and returns the corresponding element.
 E element(Position<?> position)
           This Container determines if it contains the position and -- if it is found -- the corresponding element is returned.
 boolean encloses(Position<?> position)
           Tests if the specified position is contained in this ch.bfh.algo.Container.
 Position<E> insert(E element)
           Inserts the specified element into this Container.
 Iterator<Position<E>> positionIterator()
           An Iterator over all positions is created.
 E replace(Position<?> position, E element)
           Replaces the element at the specified position with the specified element.
 void swap(Position<?> position0, Position<?> position1)
           
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

insert

Position<E> insert(E element)

Inserts the specified element into this Container.

Parameters:
element - The element to be inserted into this Container.
Returns:
The Position of the inserted element.

element

E element(Position<?> position)
          throws InvalidAccessorException

This Container determines if it contains the position and -- if it is found -- the corresponding element is returned.

Parameters:
position - The position from which the element is to be returned.
Returns:
The element at the position position
Throws:
InvalidAccessorException - if the position does not belong to this Container

replace

E replace(Position<?> position,
          E element)
          throws InvalidAccessorException

Replaces the element at the specified position with the specified element.

Parameters:
position - The Position where the replacement is carried out.
element - The new element at the specified position.
Returns:
The old element (which is being replaced)
Throws:
InvalidAccessorException - if the position does not belong to this Container

encloses

boolean encloses(Position<?> position)

Tests if the specified position is contained in this ch.bfh.algo.Container.

Parameters:
position - This Container determines if it contains the position.
Returns:
True iff the position is contained in this Container, false otherwise

delete

E delete(Position<?> position)
         throws InvalidAccessorException

Deletes the specified position and returns the corresponding element.

Parameters:
position - The Position to be deleted
Returns:
The element contained in the position being deleted
Throws:
InvalidAccessorException - if the position does not belong to this Container

swap

void swap(Position<?> position0,
          Position<?> position1)
          throws InvalidAccessorException
Throws:
InvalidAccessorException

positionIterator

Iterator<Position<E>> positionIterator()

An Iterator over all positions is created.

Returns:
an Iterator over all positions in this ch.bfh.algo.Container