java.lang.Object
org.ematgine.utils.concurrent.SyncCollection
org.ematgine.utils.concurrent.SyncSet
- All Implemented Interfaces:
- java.util.Collection, java.lang.Iterable, java.util.Set
- Direct Known Subclasses:
- SyncSortedSet
- public class SyncSet
- extends SyncCollection
- implements java.util.Set
SyncSets wrap Sync-based control around java.util.Sets.
They support two additional reader operations than do
SyncCollection: hashCode and equals.
[ Introduction to this package. ]
|
Constructor Summary |
SyncSet(java.util.Set set,
ReadWriteLock rwl)
Create a new SyncSet protecting the given set,
and using the given ReadWriteLock to control reader and writer methods. |
SyncSet(java.util.Set set,
Sync sync)
Create a new SyncSet protecting the given collection,
and using the given sync to control both reader and writer methods. |
SyncSet(java.util.Set set,
Sync readLock,
Sync writeLock)
Create a new SyncSet protecting the given set,
and using the given pair of locks to control reader and writer methods. |
|
Method Summary |
boolean |
equals(java.lang.Object o)
Compares the specified object to this for equality. |
int |
hashCode()
Returns the hash code for this set. |
| Methods inherited from class org.ematgine.utils.concurrent.SyncCollection |
add, addAll, afterRead, beforeRead, clear, contains, containsAll, isEmpty, iterator, readerSync, remove, removeAll, retainAll, size, syncFailures, toArray, toArray, unprotectedIterator, writerSync |
| Methods inherited from interface java.util.Set |
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
SyncSet
public SyncSet(java.util.Set set,
Sync sync)
- Create a new SyncSet protecting the given collection,
and using the given sync to control both reader and writer methods.
Common, reasonable choices for the sync argument include
Mutex, ReentrantLock, and Semaphores initialized to 1.
SyncSet
public SyncSet(java.util.Set set,
ReadWriteLock rwl)
- Create a new SyncSet protecting the given set,
and using the given ReadWriteLock to control reader and writer methods.
SyncSet
public SyncSet(java.util.Set set,
Sync readLock,
Sync writeLock)
- Create a new SyncSet protecting the given set,
and using the given pair of locks to control reader and writer methods.
hashCode
public int hashCode()
- Description copied from interface:
java.util.Set
- Returns the hash code for this set. In order to satisfy the contract of
equals, this is the sum of the hashcode of all elements in the set.
- Specified by:
hashCode in interface java.util.Set
equals
public boolean equals(java.lang.Object o)
- Description copied from interface:
java.util.Set
- Compares the specified object to this for equality. For sets, the object
must be a set, the two must have the same size, and every element in
one must be in the other.
- Specified by:
equals in interface java.util.Set