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 AtomicIntegerprotected final ConcurrentLinkedDeque<E> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection<? extends E> col) booleanaddAll(Collection<? extends E> elements) voidclear()booleanbooleancontainsAll(Collection<?> elements) get(int index) intbooleanisEmpty()iterator()intlastIndexOf(Object element) listIterator(int index) remove(int index) booleanbooleanremoveAll(Collection<?> elements) booleanretainAll(Collection<?> elements) intsize()subList(int from, int to) Object[]toArray()<T> T[]toArray(T[] arr) protected final booleanvalidateIndex(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, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods 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:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>
-
isEmpty
public boolean isEmpty() -
iterator
-
remove
-
removeAll
-
toArray
-
toArray
public <T> T[] toArray(T[] arr) -
retainAll
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<E>
-
listIterator
- Specified by:
listIteratorin interfaceList<E>
-
listIterator
- Specified by:
listIteratorin interfaceList<E>
-
subList
-