Package EDU.oswego.cs.dl.util.concurrent
Class SyncList
- java.lang.Object
-
- EDU.oswego.cs.dl.util.concurrent.SyncCollection
-
- EDU.oswego.cs.dl.util.concurrent.SyncList
-
- All Implemented Interfaces:
java.lang.Iterable,java.util.Collection,java.util.List
public class SyncList extends SyncCollection implements java.util.List
SyncLists wrap Sync-based control around java.util.Lists. They support the following additional reader operations over SyncCollection: hashCode, equals, get, indexOf, lastIndexOf, subList. They support additional writer operations remove(int), set(int), add(int), addAll(int). The corresponding listIterators and are similarly extended.- See Also:
SyncCollection
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classSyncList.SyncCollectionListIterator-
Nested classes/interfaces inherited from class EDU.oswego.cs.dl.util.concurrent.SyncCollection
SyncCollection.SyncCollectionIterator
-
-
Field Summary
-
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.SyncCollection
c_, rd_, syncFailures_, wr_
-
-
Constructor Summary
Constructors Constructor Description SyncList(java.util.List list, ReadWriteLock rwl)Create a new SyncList protecting the given list, and using the given ReadWriteLock to control reader and writer methods.SyncList(java.util.List list, Sync sync)Create a new SyncList protecting the given collection, and using the given sync to control both reader and writer methods.SyncList(java.util.List list, Sync readLock, Sync writeLock)Create a new SyncList protecting the given list, and using the given pair of locks to control reader and writer methods.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, java.lang.Object o)booleanaddAll(int index, java.util.Collection coll)protected java.util.ListbaseList()booleanequals(java.lang.Object o)java.lang.Objectget(int index)inthashCode()intindexOf(java.lang.Object o)intlastIndexOf(java.lang.Object o)java.util.ListIteratorlistIterator()java.util.ListIteratorlistIterator(int index)java.lang.Objectremove(int index)java.lang.Objectset(int index, java.lang.Object o)java.util.ListsubList(int fromIndex, int toIndex)java.util.ListIteratorunprotectedListIterator()java.util.ListIteratorunprotectedListIterator(int index)-
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.SyncCollection
add, addAll, afterRead, beforeRead, clear, contains, containsAll, isEmpty, iterator, readerSync, remove, removeAll, retainAll, size, syncFailures, toArray, toArray, unprotectedIterator, writerSync
-
-
-
-
Constructor Detail
-
SyncList
public SyncList(java.util.List list, Sync sync)Create a new SyncList 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.
-
SyncList
public SyncList(java.util.List list, ReadWriteLock rwl)Create a new SyncList protecting the given list, and using the given ReadWriteLock to control reader and writer methods.
-
-
Method Detail
-
baseList
protected java.util.List baseList()
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Collection- Specified by:
hashCodein interfacejava.util.List- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equalsin interfacejava.util.Collection- Specified by:
equalsin interfacejava.util.List- Overrides:
equalsin classjava.lang.Object
-
get
public java.lang.Object get(int index)
- Specified by:
getin interfacejava.util.List
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOfin interfacejava.util.List
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOfin interfacejava.util.List
-
subList
public java.util.List subList(int fromIndex, int toIndex)- Specified by:
subListin interfacejava.util.List
-
set
public java.lang.Object set(int index, java.lang.Object o)- Specified by:
setin interfacejava.util.List
-
remove
public java.lang.Object remove(int index)
- Specified by:
removein interfacejava.util.List
-
add
public void add(int index, java.lang.Object o)- Specified by:
addin interfacejava.util.List
-
addAll
public boolean addAll(int index, java.util.Collection coll)- Specified by:
addAllin interfacejava.util.List
-
unprotectedListIterator
public java.util.ListIterator unprotectedListIterator()
-
listIterator
public java.util.ListIterator listIterator()
- Specified by:
listIteratorin interfacejava.util.List
-
unprotectedListIterator
public java.util.ListIterator unprotectedListIterator(int index)
-
listIterator
public java.util.ListIterator listIterator(int index)
- Specified by:
listIteratorin interfacejava.util.List
-
-