fr.umlv.ji.figures
Class Figure.Collection

java.lang.Object
  |
  +--fr.umlv.ji.figures.Figure.Collection
Direct Known Subclasses:
Disque.Collection
Enclosing class:
Figure

public static class Figure.Collection
extends Object

Collections of Figure.

Collections of Figure can contain any types of Figure and can compute the sum of surfaces of the contained figures.

Collections also provide iterators for enumerating all their elements, or only elements of a given surface.

Collections can not be modified once they are built: figures can not be add or removed from a collection. Mutable figures can be modified without any consequence for the collections they belong to. A collection may contain duplicate elements.


Field Summary
private  Figure[] figs
           
 
Constructor Summary
Figure.Collection(Figure[] f)
           
 
Method Summary
 Iterator iterator()
          Returns an iterator over all the elements in this set.
 Iterator search(double surface)
          Returns an iterator over all the elements in this set whose area is equal to surface.
 double surface()
          Returns the sum of all surfaces of figures in this set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

figs

private Figure[] figs
Constructor Detail

Figure.Collection

public Figure.Collection(Figure[] f)
Method Detail

surface

public double surface()
Returns the sum of all surfaces of figures in this set.

Returns:
the sum of all surfaces of figures in this set.

iterator

public Iterator iterator()
Returns an iterator over all the elements in this set. The elements are returned in the same order as in the array given to the constructor.

Returns:
an iterator over all the elements in this set.

search

public Iterator search(double surface)
Returns an iterator over all the elements in this set whose area is equal to surface. The elements are returned in the same order as in the array given to the constructor.

Parameters:
surface - The surface of the figures the returned iterator has to search for in this set.
Returns:
an iterator over all the elements in this set whose area is equal to surface.
Implementation Notes:
the iterator returned is not fail fast.