|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.util.WeakObserverSet<T>
public class WeakObserverSet<T>
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. |
protected static class |
WeakObserverSet.ObserverRef<T>
Represents a reference to an observer. |
| Field Summary | |
|---|---|
protected boolean |
_dirty
Set when we need to update the snapshot. |
protected LinkedHashSet<WeakObserverSet.ObserverRef<T>> |
_set
The contained set. |
protected WeakObserverSet.ObserverRef<T>[] |
_snap
A snapshot of the 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. |
|
protected static
|
checkedApply(WeakObserverSet.ObserverOp<T> obop,
T obs)
Applies the operation to the observer, catching and logging any exceptions thrown in the process. |
|
boolean |
isEmpty()
Checks whether the set is empty. |
|
static
|
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 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected LinkedHashSet<WeakObserverSet.ObserverRef<T>> _set
protected WeakObserverSet.ObserverRef<T>[] _snap
protected boolean _dirty
| Constructor Detail |
|---|
public WeakObserverSet()
| Method Detail |
|---|
public static <T> WeakObserverSet<T> newSet()
public boolean add(T observer)
public boolean remove(T observer)
public boolean isEmpty()
public void apply(WeakObserverSet.ObserverOp<T> obop)
public String toString()
toString in class Object
protected static <T> boolean checkedApply(WeakObserverSet.ObserverOp<T> obop,
T obs)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||