A java.util.Set
that uses an internal CopyOnWriteArrayList
for all of its operations. Thus, it shares the same basic properties:
Sample Usage. The following code sketch uses a copy-on-write set to maintain a set of Handler objects that perform some action upon state updates.
class Handler { void handle(); ...
class X { private final CopyOnWriteArraySethandlers = new CopyOnWriteArraySet (); public void addHandler(Handler h) { handlers.add(h); } private long internalState; private synchronized void changeState() { internalState = ...; } public void update() { changeState(); for (Handler handler : handlers) handler.handle(); } }}
This class is a member of the Java Collections Framework.
extends
<E> | the type of elements held in this collection |
CopyOnWriteArrayList