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.| 构造器和说明 |
|---|
ConcurrentCyclicSequence()
Create a new empty sequence.
|
ConcurrentCyclicSequence(T... elements)
Create a new empty sequence.
|
| 限定符和类型 | 方法和说明 |
|---|---|
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() |
void |
remove() |
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, spliteratorforEachRemainingpublic ConcurrentCyclicSequence()
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 int size()
Copyright © 2022. All rights reserved.