The sequence is immutable and modifications are done with copy-on-write using
add(Object) and remove(Object) to return a modified copy of the current instance.
The internal counter uses a volatile index, so it can be incremented concurrently by several threads without locking.
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private final Object[] | |
| private static final Object[] | |
| private final AtomicInteger |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public ConcurrentCyclicSequence | Returns: the resulting sequencethe element to add element)Copy the current sequence, add |
| private int | |
| public T | |
| public boolean | Returns: alwaystrueImplements java. Returns |
| public int | |
| public Iterator | Returns: an iterator starting at the first element of the sequence, the iterator will not throwConcurrentModificationExceptionImplements java. Returns an iterator over elements of type |
| public Iterator | Returns: an iterator starting at the next element of the sequence, the iterator will not throwConcurrentModificationException
|
| public T | Returns: the next element in the sequenceImplements java. Returns the next element in the iteration. |
| public ConcurrentCyclicSequence | Returns: the resulting sequencethe element to remove element)Remove the first occurrence of |
| public int |
| elements | back to summary |
|---|---|
| private final Object[] elements | |
| EMPTY_ARRAY | back to summary |
|---|---|
| private static final Object[] EMPTY_ARRAY | |
| pos | back to summary |
|---|---|
| private final AtomicInteger pos | |
| ConcurrentCyclicSequence | back to summary |
|---|---|
| public ConcurrentCyclicSequence() Create a new empty sequence. | |
| ConcurrentCyclicSequence | back to summary |
|---|---|
| public ConcurrentCyclicSequence(T... elements) Create a new empty sequence.
| |
| ConcurrentCyclicSequence | back to summary |
|---|---|
| private ConcurrentCyclicSequence(int pos, Object[] elements) | |
| add | back to summary |
|---|---|
| public ConcurrentCyclicSequence Copy the current sequence, add
| |
| computeIndex | back to summary |
|---|---|
| private int computeIndex(int p) | |
| first | back to summary |
|---|---|
public T first()
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| index | back to summary |
|---|---|
public int index()
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over elements of type
| |
| iterator | back to summary |
|---|---|
public Iterator
| |
| next | back to summary |
|---|---|
| public T next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| remove | back to summary |
|---|---|
| public ConcurrentCyclicSequence Remove the first occurrence of
If the sequence does not contains
| |
| size | back to summary |
|---|---|
public int size()
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public T |
| cursor | back to summary |
|---|---|
| pack-priv int cursor | |
| start | back to summary |
|---|---|
| pack-priv final int start | |
| Iter | back to summary |
|---|---|
| public Iter(int start) | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public T next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv boolean |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public T |
| next | back to summary |
|---|---|
| pack-priv boolean next | |
| SingletonIter | back to summary |
|---|---|
| private SingletonIter() | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public T next() Implements java. Doc from java. Returns the next element in the iteration.
| |