Class SynchronizedSet<E>
- java.lang.Object
-
- org.apache.pivot.collections.concurrent.SynchronizedSet<E>
-
- Type Parameters:
E- Type of element contained in this set.
- All Implemented Interfaces:
java.lang.Iterable<E>,Collection<E>,Group<E>,Set<E>
public class SynchronizedSet<E> extends java.lang.Object implements Set<E>
Synchronized implementation of theSetinterface.
-
-
Constructor Summary
Constructors Constructor Description SynchronizedSet(Set<E> wrappedSet)Wrap the given set with this synchronized version.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E element)Adds an element to the group.voidclear()Removes all elements from the collection.booleancontains(E element)Tests the existence of an element in the group.java.util.Comparator<E>getComparator()Returns the collection's sort order.intgetCount()ListenerList<SetListener<E>>getSetListeners()booleanisEmpty()Tests the emptiness of the collection.java.util.Iterator<E>iterator()NOTE Callers must manually synchronize on the SynchronizedSet instance to ensure thread safety during iteration.booleanremove(E element)Removes an element from the group.voidsetComparator(java.util.Comparator<E> comparator)Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.
-
-
-
Method Detail
-
add
public boolean add(E element)
Description copied from interface:GroupAdds an element to the group.
-
remove
public boolean remove(E element)
Description copied from interface:GroupRemoves an element from the group.
-
contains
public boolean contains(E element)
Description copied from interface:GroupTests the existence of an element in the group.
-
isEmpty
public boolean isEmpty()
Description copied from interface:CollectionTests the emptiness of the collection.- Specified by:
isEmptyin interfaceCollection<E>- Returns:
trueif the collection contains no elements;false, otherwise.
-
clear
public void clear()
Description copied from interface:CollectionRemoves all elements from the collection.- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>- See Also:
SetListener.setCleared(Set)
-
getCount
public int getCount()
-
getComparator
public java.util.Comparator<E> getComparator()
Description copied from interface:CollectionReturns the collection's sort order.- Specified by:
getComparatorin interfaceCollection<E>- Returns:
- The comparator used to order elements in the collection, or
nullif the sort order is undefined. - See Also:
Collection.setComparator(Comparator)
-
setComparator
public void setComparator(java.util.Comparator<E> comparator)
Description copied from interface:CollectionSets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.Calling this method more than once with the same comparator will re-sort the collection.
- Specified by:
setComparatorin interfaceCollection<E>- Specified by:
setComparatorin interfaceSet<E>- Parameters:
comparator- The comparator used to order elements in the collection, or null if the collection is unsorted.- See Also:
SetListener.setCleared(Set)
-
iterator
public java.util.Iterator<E> iterator()
NOTE Callers must manually synchronize on the SynchronizedSet instance to ensure thread safety during iteration.- Specified by:
iteratorin interfacejava.lang.Iterable<E>
-
getSetListeners
public ListenerList<SetListener<E>> getSetListeners()
- Specified by:
getSetListenersin interfaceSet<E>- Returns:
- The set listener list.
-
-