public class ConcurrentCyclicSequence<T> extends Object implements Iterable<T>, Iterator<T>
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.| Constructor and Description |
|---|
ConcurrentCyclicSequence()
Create a new empty sequence.
|
ConcurrentCyclicSequence(T... elements)
Create a new empty sequence.
|
| Modifier and Type | Method and Description |
|---|---|
ConcurrentCyclicSequence<T> |
add(T element)
Copy the current sequence, add
element at the tail of this sequence and returns it. |
T |
first() |
boolean |
hasNext() |
int |
index() |
Iterator<T> |
iterator() |
T |
next() |
ConcurrentCyclicSequence<T> |
remove(T element)
Remove the first occurrence of
element in this sequence and returns it. |
int |
size() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorforEachRemaining, removepublic ConcurrentCyclicSequence()
@SafeVarargs public ConcurrentCyclicSequence(T... elements)
public int index()
public T first()
null when the sequence is emptypublic ConcurrentCyclicSequence<T> add(T element)
element at the tail of this sequence and returns it.element - the element to addpublic ConcurrentCyclicSequence<T> remove(T element)
element in this sequence and returns it.
If the sequence does not contains element, this instance is returned instead.element - the element to removepublic boolean hasNext()
public T next()
public int size()
Copyright © 2020. All rights reserved.