jmarkov.basic
Class EventsSet<E extends Event>

java.lang.Object
  extended by jmarkov.basic.EventsSet<E>
Type Parameters:
E - The type of Events in this set.
All Implemented Interfaces:
java.lang.Iterable<E>, Events<E>

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

This class represent a set of Events. The set should be build at the beggining and should not be changed in any way afterwards.

Author:
Germán Riaño. Universidad de los Andes.

Constructor Summary
EventsSet()
          Creates an empty set of Events;
EventsSet(E[] eventArray)
          Creates an empty set of Events;
 
Method Summary
 boolean add(E e)
          Adds the Event e to the set.
 boolean contains(Event e)
          Returns true if the set contains this Event.
 java.util.Iterator<E> iterator()
          This method returns a safe way to walk through the events in a particular set.
 int size()
          Returns the number of elements.
 E[] toEventArray()
          Returns an array with the Events in the set.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventsSet

public EventsSet()
Creates an empty set of Events;


EventsSet

public EventsSet(E[] eventArray)
Creates an empty set of Events;

Parameters:
eventArray - an array representation of the set.
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 boolean add(E e)
Adds the Event e to the set.

Specified by:
add in interface Events<E extends Event>
Parameters:
e - The event to be added.
Returns:
True if the set did not already contained this event.

contains

public boolean contains(Event e)
Returns true if the set contains this Event.

Parameters:
e - The event.
Returns:
whether the set contains this event.

toEventArray

public E[] toEventArray()
Returns an array with the Events in the set.

Returns:
array representation of the set.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

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.