jmdp.basic
Class StatesSet<S extends State>

java.lang.Object
  extended by jmdp.basic.StatesSet<S>
All Implemented Interfaces:
java.lang.Iterable<S>, States<S>

public class StatesSet<S extends State>
extends java.lang.Object
implements States<S>

This class represents a set of states represented by objects of type S that extends State.

Author:
Andres Sarmiento and German Riano - Universidad de Los Andes
See Also:
Collection

Constructor Summary
StatesSet()
          Creates an empty set of objects S.
StatesSet(java.lang.Iterable<S> stIter)
           
StatesSet(S st)
          Creates a set of States with only one State in it.
StatesSet(S[] st)
          Creates a set of States from a given array of States.
StatesSet(States<S> st)
          Creates a set of objects S from a given set of States.
 
Method Summary
 void add(S s)
          Adds a state to the set.
 java.util.Iterator<S> iterator()
          This method returns a safe way to walk through the states in a particular set.
 void remove(S s)
          Removes an object from the set.
 int size()
          Returns the number of elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatesSet

public StatesSet()
Creates an empty set of objects S.


StatesSet

public StatesSet(States<S> st)
Creates a set of objects S from a given set of States.

Parameters:
st - a set of States of type States.

StatesSet

public StatesSet(java.lang.Iterable<S> stIter)

StatesSet

public StatesSet(S st)
Creates a set of States with only one State in it.

Parameters:
st - set of states of type State.

StatesSet

public StatesSet(S[] st)
Creates a set of States from a given array of States. This constructor organizes the state in a TreeSet.

Parameters:
st - array of states of type State.
Method Detail

iterator

public final java.util.Iterator<S> iterator()
This method returns a safe way to walk through the states in a particular set. Collections and their implementations (Set, List, and Map) have iterators defined by default.

Specified by:
iterator in interface java.lang.Iterable<S extends State>
Specified by:
iterator in interface States<S extends State>
Returns:
iterator over the states.

add

public void add(S s)
Adds a state to the set.

Specified by:
add in interface States<S extends State>
Parameters:
s - state to be added.

remove

public void remove(S s)
Removes an object from the set.

Specified by:
remove in interface States<S extends State>

size

public int size()
Description copied from interface: States
Returns the number of elements.

Specified by:
size in interface States<S extends State>
Returns:
the amount of states in the set.