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 class
SyncList.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 void
add(int index, java.lang.Object o)
boolean
addAll(int index, java.util.Collection coll)
protected java.util.List
baseList()
boolean
equals(java.lang.Object o)
java.lang.Object
get(int index)
int
hashCode()
int
indexOf(java.lang.Object o)
int
lastIndexOf(java.lang.Object o)
java.util.ListIterator
listIterator()
java.util.ListIterator
listIterator(int index)
java.lang.Object
remove(int index)
java.lang.Object
set(int index, java.lang.Object o)
java.util.List
subList(int fromIndex, int toIndex)
java.util.ListIterator
unprotectedListIterator()
java.util.ListIterator
unprotectedListIterator(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:
hashCode
in interfacejava.util.Collection
- Specified by:
hashCode
in interfacejava.util.List
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in interfacejava.util.Collection
- Specified by:
equals
in interfacejava.util.List
- Overrides:
equals
in classjava.lang.Object
-
get
public java.lang.Object get(int index)
- Specified by:
get
in interfacejava.util.List
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOf
in interfacejava.util.List
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOf
in interfacejava.util.List
-
subList
public java.util.List subList(int fromIndex, int toIndex)
- Specified by:
subList
in interfacejava.util.List
-
set
public java.lang.Object set(int index, java.lang.Object o)
- Specified by:
set
in interfacejava.util.List
-
remove
public java.lang.Object remove(int index)
- Specified by:
remove
in interfacejava.util.List
-
add
public void add(int index, java.lang.Object o)
- Specified by:
add
in interfacejava.util.List
-
addAll
public boolean addAll(int index, java.util.Collection coll)
- Specified by:
addAll
in interfacejava.util.List
-
unprotectedListIterator
public java.util.ListIterator unprotectedListIterator()
-
listIterator
public java.util.ListIterator listIterator()
- Specified by:
listIterator
in interfacejava.util.List
-
unprotectedListIterator
public java.util.ListIterator unprotectedListIterator(int index)
-
listIterator
public java.util.ListIterator listIterator(int index)
- Specified by:
listIterator
in interfacejava.util.List
-
-