Class ConcurrentCASList<E>
java.lang.Object
org.eclipse.epsilon.common.concurrent.ConcurrentCASList<E>
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,List<E>
A List implementation intended to be used in places where
an API requires a List but doesn't actually use the indexes - it just needs ordering.
In concurrent environments, Lists are highly inconvenient due to their sequential
nature. This class therefore mimics a list when infact it's actually a
AS A RESULT, USERS SHOULD NOT RELY ON INDEXES! THIS LIST IS SIMPLY A FACADE FOR POORLY DESIGNED / OVERSPECIFIED APIs WITH NO REGARDS FOR CONCURRENCY.
ConcurrentLinkedDeque
.
AS A RESULT, USERS SHOULD NOT RELY ON INDEXES! THIS LIST IS SIMPLY A FACADE FOR POORLY DESIGNED / OVERSPECIFIED APIs WITH NO REGARDS FOR CONCURRENCY.
- Since:
- 1.6
- Author:
- Sina Madani
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicInteger
protected final ConcurrentLinkedDeque<E>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(int index, Collection<? extends E> col) boolean
addAll
(Collection<? extends E> elements) void
clear()
boolean
boolean
containsAll
(Collection<?> elements) get
(int index) int
boolean
isEmpty()
iterator()
int
lastIndexOf
(Object element) listIterator
(int index) remove
(int index) boolean
boolean
removeAll
(Collection<?> elements) boolean
retainAll
(Collection<?> elements) int
size()
subList
(int from, int to) Object[]
toArray()
<T> T[]
toArray
(T[] arr) protected final boolean
validateIndex
(int index) Checks whether index is 0 or the size of the list.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
equals, hashCode, replaceAll, sort, spliterator
-
Field Details
-
deque
-
cachedSize
-
-
Constructor Details
-
ConcurrentCASList
public ConcurrentCASList()
-
-
Method Details
-
validateIndex
protected final boolean validateIndex(int index) Checks whether index is 0 or the size of the list.- Returns:
- true means first, false means last.
- Throws:
UnsupportedOperationException
- if index is not 0 or size().
-
get
-
size
public int size() -
add
-
set
-
remove
-
addAll
-
add
-
addAll
-
clear
public void clear() -
contains
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceList<E>
-
isEmpty
public boolean isEmpty() -
iterator
-
remove
-
removeAll
-
toArray
-
toArray
public <T> T[] toArray(T[] arr) -
retainAll
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<E>
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
-
subList
-