com.threerings.util
Class WeakObserverSet<T>

java.lang.Object
  extended by com.threerings.util.WeakObserverSet<T>

public class WeakObserverSet<T>
extends Object

Much like WeakObserverList, but provides faster addition and removal in exchange for using additional memory and generating additional garbage (the iterator) on notification.


Nested Class Summary
static interface WeakObserverSet.ObserverOp<T>
          Instances of this interface are used to apply methods to all observers in a set.
 
Constructor Summary
WeakObserverSet()
           
 
Method Summary
 boolean add(T observer)
          Adds an observer to the set.
 void apply(WeakObserverSet.ObserverOp<T> obop)
          Applies the specified operation to all observers in the set.
 boolean isEmpty()
          Checks whether the set is empty.
static
<T> WeakObserverSet<T>
newSet()
          A convenience method for creating an observer set that avoids duplicating the type parameter on the right hand side.
 boolean remove(T observer)
          Removes an observer from the set.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WeakObserverSet

public WeakObserverSet()
Method Detail

newSet

public static <T> WeakObserverSet<T> newSet()
A convenience method for creating an observer set that avoids duplicating the type parameter on the right hand side.


add

public boolean add(T observer)
Adds an observer to the set.


remove

public boolean remove(T observer)
Removes an observer from the set.


isEmpty

public boolean isEmpty()
Checks whether the set is empty.


apply

public void apply(WeakObserverSet.ObserverOp<T> obop)
Applies the specified operation to all observers in the set.


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.