public class DynamicCollection<E> extends 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 Map<DynamicCollection.DynamicIterator,Object> |
iterators
should have been a list but there is no 'WeakReference'-based
implementation in the JDK
|
protected Object |
iteratorsLock
If it interacts with the storage, the *storage* lock needs to be acquired
first
|
protected List<E> |
storage
this list is not-synchronized by default
|
| Constructor and Description |
|---|
DynamicCollection() |
DynamicCollection(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(Collection<? extends E> c) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
protected int |
indexOf(Object o)
Hook used by wrapping collections to determine the position of the object
being removed while iterating.
|
boolean |
isEmpty() |
Iterator<E> |
iterator() |
protected E |
remove(int index) |
boolean |
remove(Object o) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
String |
toString() |
removeAll, retainAllclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitequals, hashCodeprotected final Object iteratorsLock
protected final Map<DynamicCollection.DynamicIterator,Object> iterators
public DynamicCollection()
public DynamicCollection(int size)
public DynamicCollection(Collection<? extends E> c)
public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in class AbstractCollection<E>public void clear()
clear in interface Collection<E>clear in class AbstractCollection<E>public int size()
size in interface Collection<E>size in class AbstractCollection<E>public boolean add(E o)
add in interface Collection<E>add in class AbstractCollection<E>public boolean addAll(Collection<? extends E> c)
addAll in interface Collection<E>addAll in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in class AbstractCollection<E>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>containsAll in class AbstractCollection<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in class AbstractCollection<E>public boolean remove(Object o)
remove in interface Collection<E>remove in class AbstractCollection<E>protected E remove(int index)
protected void add(int index,
E o)
public Object[] toArray()
toArray in interface Collection<E>toArray in class AbstractCollection<E>public <T> T[] toArray(T[] a)
toArray in interface Collection<E>toArray in class AbstractCollection<E>public String toString()
toString in class AbstractCollection<E>protected int indexOf(Object o)
o - Copyright © 2006-2013. All Rights Reserved.