public class DynamicCollection<E>
extends java.util.AbstractCollection<E>
Iterator.next() will obey the result of the previously called
Iterator.hasNext() even though the collection content has been
modified.
This collection is thread-safe with the condition that there is at most one
writing thread at a point in time. There are no restrains on the number of
readers.| Modifier and Type | Class and Description |
|---|---|
protected class |
DynamicCollection.DynamicIterator
Dynamic consistent iterator.
|
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<DynamicCollection.DynamicIterator,java.lang.Object> |
iterators
should have been a list but there is no 'WeakReference'-based
implementation in the JDK
|
protected java.lang.Object |
iteratorsLock
If it interacts with the storage, the *storage* lock needs to be acquired
first
|
protected java.util.List<E> |
storage
this list is not-synchronized by default
|
| Constructor and Description |
|---|
DynamicCollection() |
DynamicCollection(java.util.Collection<? extends E> c) |
DynamicCollection(int size) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E o) |
protected void |
add(int index,
E o) |
boolean |
addAll(java.util.Collection<? extends E> c) |
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
protected int |
indexOf(java.lang.Object o)
Hook used by wrapping collections to determine the position of the object
being removed while iterating.
|
boolean |
isEmpty() |
java.util.Iterator<E> |
iterator() |
protected E |
remove(int index) |
boolean |
remove(java.lang.Object o) |
int |
size() |
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitprotected final java.lang.Object iteratorsLock
protected final java.util.List<E> storage
protected final java.util.Map<DynamicCollection.DynamicIterator,java.lang.Object> iterators
public DynamicCollection()
public DynamicCollection(int size)
public DynamicCollection(java.util.Collection<? extends E> c)
public java.util.Iterator<E> iterator()
public void clear()
public int size()
public boolean add(E o)
public boolean addAll(java.util.Collection<? extends E> c)
public boolean contains(java.lang.Object o)
public boolean containsAll(java.util.Collection<?> c)
public boolean isEmpty()
public boolean remove(java.lang.Object o)
protected E remove(int index)
protected void add(int index,
E o)
public java.lang.Object[] toArray()
public <T> T[] toArray(T[] a)
public java.lang.String toString()
toString in class java.util.AbstractCollection<E>protected int indexOf(java.lang.Object o)
o -