|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<T>
edu.rice.cs.plt.collect.DelegatingCollection<T>
edu.rice.cs.plt.collect.DelegatingSet<Runnable1<? super T>>
edu.rice.cs.plt.collect.ListenerSet<T>
public class ListenerSet<T>
A mutable set of listeners. Each listener is a Runnable1 and receives an argument
of type T. In typical usage, a class supporting listeners has some number of
ListenerSet<T> fields and associated getters returning ListenerSet<T>.Sinks
(one for each different kind of event to be responded to). Clients use expressions like
foo.listeners().add(...) to add listeners; the listener class then calls
_listeners.run(...) when an event occurs.
| Nested Class Summary | |
|---|---|
class |
ListenerSet.Sink
A write-only view of the set. |
| Field Summary |
|---|
| Fields inherited from class edu.rice.cs.plt.collect.DelegatingCollection |
|---|
_delegate |
| Constructor Summary | |
|---|---|
ListenerSet()
Create a ListenerSet backed by a CopyOnWriteArraySet (thread-safe and efficient for
frequent traversal, but slow when frequently mutated). |
|
ListenerSet(java.util.Set<Runnable1<? super T>> delegate)
Create a ListenerSet backed by the given set. |
|
| Method Summary | ||
|---|---|---|
static
|
make(java.util.Set<Runnable1<? super T>> delegate)
Call the constructor (allows T to be inferred). |
|
void |
run(T arg)
Pass the given value to each of the listeners in turn. |
|
ListenerSet.Sink |
sink()
Get a write-only sink view of the set. |
|
| Methods inherited from class edu.rice.cs.plt.collect.DelegatingSet |
|---|
equals, hashCode |
| Methods inherited from class edu.rice.cs.plt.collect.DelegatingCollection |
|---|
abstractCollectionAddAll, abstractCollectionClear, abstractCollectionContains, abstractCollectionContainsAll, abstractCollectionIsEmpty, abstractCollectionRemove, abstractCollectionRemoveAll, abstractCollectionRetainAll, abstractCollectionToArray, abstractCollectionToArray, add, addAll, clear, compositeHeight, compositeSize, contains, containsAll, hasFixedSize, isEmpty, isInfinite, isStatic, iterator, remove, removeAll, retainAll, size, size, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
|---|
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Methods inherited from interface edu.rice.cs.plt.lambda.Predicate |
|---|
contains |
| Methods inherited from interface edu.rice.cs.plt.iter.SizedIterable |
|---|
hasFixedSize, isEmpty, isInfinite, isStatic, size, size |
| Constructor Detail |
|---|
public ListenerSet()
CopyOnWriteArraySet (thread-safe and efficient for
frequent traversal, but slow when frequently mutated).
public ListenerSet(java.util.Set<Runnable1<? super T>> delegate)
| Method Detail |
|---|
public void run(T arg)
run in interface Runnable1<T>public ListenerSet.Sink sink()
public static <T> ListenerSet<T> make(java.util.Set<Runnable1<? super T>> delegate)
T to be inferred).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||