jmdp.basic
Class EventsSet<E extends Event>

java.lang.Object
  extended by jmdp.basic.EventsSet<E>
All Implemented Interfaces:
java.lang.Iterable<E>, Events<E>

public class EventsSet<E extends Event>
extends java.lang.Object
implements Events<E>

This class represents a set of events of type E. It uses java.Util.Collections to organize the elements.

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

Constructor Summary
EventsSet()
          Creates an empty set of objects E.
EventsSet(E ev)
          Creates a set of events with only one Event in it.
EventsSet(E[] ev)
          Creates a set of events from a given array of Event.
EventsSet(java.lang.Iterable<E> evIter)
          Creates a set of objects E from a given set that implements Iterable.
 
Method Summary
 void add(E e)
          Adds an event to the set.
 java.util.Iterator<E> iterator()
          This method returns a safe way to walk through the events in a particular set.
 void remove(E e)
          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

EventsSet

public EventsSet()
Creates an empty set of objects E.


EventsSet

public EventsSet(java.lang.Iterable<E> evIter)
Creates a set of objects E from a given set that implements Iterable. Also an object EventCollection or even a Collection or an array Event[].

Parameters:
evIter - An iterator over events.

EventsSet

public EventsSet(E ev)
Creates a set of events with only one Event in it.

Parameters:
ev - an event of type Event.

EventsSet

public EventsSet(E[] ev)
Creates a set of events from a given array of Event.

Parameters:
ev - array of events o of type Event.
Method Detail

iterator

public final java.util.Iterator<E> iterator()
This method returns a safe way to walk through the events 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<E extends Event>
Specified by:
iterator in interface Events<E extends Event>
Returns:
iterator over the events.

add

public void add(E e)
Adds an event to the set.

Specified by:
add in interface Events<E extends Event>
Parameters:
e - event to be added.

remove

public void remove(E e)
Removes an object from the set.


size

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

Specified by:
size in interface Events<E extends Event>
Returns:
the amount of events in the set.