blackjackanalyst
Class ObserverList<T>

java.lang.Object
  extended by blackjackanalyst.ObserverList<T>
Type Parameters:
T - the type of observer in the list

public class ObserverList<T>
extends java.lang.Object

A list of observers.

Author:
Michael Parker

Method Summary
 boolean add(T obj)
          Adds the given observer to the list of observers.
 void clear()
          Removes all the observers from the list.
 boolean contains(T obj)
          Returns whether the list contains the given observer.
 boolean isEmpty()
          Returns whether the observer list is empty, meaning its size equals 0.
 java.util.Iterator<T> iterator()
          Returns an iterator over the list of observers.
 boolean remove(T obj)
          Removes the given observer from the list of observers.
 int size()
          Returns the number of observers in the list.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

size

public int size()
Returns the number of observers in the list.

Returns:
the size of the observer list

isEmpty

public boolean isEmpty()
Returns whether the observer list is empty, meaning its size equals 0.

Returns:
true if the observer list is empty, false otherwise

contains

public boolean contains(T obj)
Returns whether the list contains the given observer. If the parameter obj is null, this method returns false.

Parameters:
obj - the observer to query for membership in the list
Returns:
true if the list contains the observer, false otherwise

iterator

public java.util.Iterator<T> iterator()
Returns an iterator over the list of observers.

Returns:
an iterator over the observer list

add

public boolean add(T obj)
Adds the given observer to the list of observers. If the parameter obj is null, this method returns false and the underlying list remains unchanged.

Parameters:
obj - the observer to add to the list
Returns:
true if the observer is added to the list, false otherwise

remove

public boolean remove(T obj)
Removes the given observer from the list of observers. If the parameter obj is null or the list does not contain the observer, this method returns false and the underlying list remains unchanged.

Parameters:
obj - the observer to remove from the list
Returns:
true if the observer is removed from the list, false otherwise

clear

public void clear()
Removes all the observers from the list.