Class CommonsCopyOnWriteArrayList<ELEMENTTYPE>
java.lang.Object
java.util.concurrent.CopyOnWriteArrayList<ELEMENTTYPE>
com.helger.commons.collection.impl.CommonsCopyOnWriteArrayList<ELEMENTTYPE>
- Type Parameters:
ELEMENTTYPE- List element type
- All Implemented Interfaces:
ICommonsCollection<ELEMENTTYPE>,ICommonsIterable<ELEMENTTYPE>,ICommonsList<ELEMENTTYPE>,ICloneable<ICommonsList<ELEMENTTYPE>>,IHasSize,Serializable,Cloneable,Iterable<ELEMENTTYPE>,Collection<ELEMENTTYPE>,List<ELEMENTTYPE>,RandomAccess,SequencedCollection<ELEMENTTYPE>
public class CommonsCopyOnWriteArrayList<ELEMENTTYPE>
extends CopyOnWriteArrayList<ELEMENTTYPE>
implements ICommonsList<ELEMENTTYPE>
A special
CommonsCopyOnWriteArrayList implementation based on
ICommonsList.- Author:
- Philip Helger
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new empty array list.Create a new array list with an initial capacity of 1 and exactly the provided value, even if it isnull.CommonsCopyOnWriteArrayList(ELEMENTTYPE... aValues) Create a new array list that contains the same elements as the provided array.CommonsCopyOnWriteArrayList(Iterable<? extends ELEMENTTYPE> aValues) Create a new array list with all provided elements.CommonsCopyOnWriteArrayList(Iterable<? extends SRCTYPE> aValues, Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) Create a new array list with all mapped items of the provided iterable.CommonsCopyOnWriteArrayList(Collection<? extends ELEMENTTYPE> aValues) Create a new array list that contains the same elements as the provided collection.CommonsCopyOnWriteArrayList(SRCTYPE[] aValues, Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) Create a new array list that contains mapped elements of the provided array. -
Method Summary
Modifier and TypeMethodDescriptionstatic <ELEMENTTYPE>
CommonsCopyOnWriteArrayList<ELEMENTTYPE> createFiltered(ELEMENTTYPE[] aValues, Predicate<? super ELEMENTTYPE> aFilter) static <ELEMENTTYPE>
CommonsCopyOnWriteArrayList<ELEMENTTYPE> createFiltered(Iterable<? extends ELEMENTTYPE> aValues, Predicate<? super ELEMENTTYPE> aFilter) static <SRCTYPE,ELEMENTTYPE>
CommonsCopyOnWriteArrayList<ELEMENTTYPE> createFiltered(Iterable<? extends SRCTYPE> aValues, Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper, Predicate<? super ELEMENTTYPE> aFilter) Create a new array list that contains a subset of the provided iterable.static <SRCTYPE,ELEMENTTYPE>
CommonsCopyOnWriteArrayList<ELEMENTTYPE> createFiltered(Iterable<? extends SRCTYPE> aValues, Predicate<? super SRCTYPE> aFilter, Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) Create a new array list that contains a subset of the provided iterable.static <SRCTYPE,ELEMENTTYPE>
CommonsCopyOnWriteArrayList<ELEMENTTYPE> createFiltered(SRCTYPE[] aValues, Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper, Predicate<? super ELEMENTTYPE> aFilter) Create a new array list that contains a subset of the provided array.static <SRCTYPE,ELEMENTTYPE>
CommonsCopyOnWriteArrayList<ELEMENTTYPE> createFiltered(SRCTYPE[] aValues, Predicate<? super SRCTYPE> aFilter, Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) Create a new array list that contains a subset of the provided array.<T> CommonsCopyOnWriteArrayList<T> Create a new empty list.getClone()Methods inherited from class java.util.concurrent.CopyOnWriteArrayList
add, add, addAll, addAll, addAllAbsent, addFirst, addIfAbsent, addLast, clear, clone, contains, containsAll, equals, forEach, get, getFirst, getLast, hashCode, indexOf, indexOf, isEmpty, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, replaceAll, retainAll, reversed, set, size, sort, spliterator, subList, toArray, toArray, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface com.helger.commons.collection.impl.ICommonsCollection
addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addIf, addIfNotNull, addObject, getAtIndex, getAtIndex, getAtIndex, getAtIndexMapped, getAtIndexMapped, getAtIndexMapped, getAtIndexMapped, getCopyAsList, getCount, getSorted, iterator2, removeAll, removeObject, set, setAll, setAll, setAllMapped, setAllMappedMethods inherited from interface com.helger.commons.collection.impl.ICommonsIterable
containsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstIndex, findFirstMapped, findFirstMapped, findLastIndex, forEachBreakable, forEachByIndex, forEachThrowing, getCountMethods inherited from interface com.helger.commons.collection.impl.ICommonsList
getAll, getAllInstanceOf, getAllMapped, getAllMapped, getAsUnmodifiable, getAtIndex, getFirst, getFirst, getFirstOrNull, getLast, getLast, getLastOrNull, getSortedInline, removeAndReturnElementAtIndex, removeAtIndex, removeFirst, removeFirstOrNull, removeLast, removeLastOrNull, reverse, setFirst, setLast, swapItemsMethods inherited from interface com.helger.commons.lang.IHasSize
isEmpty, isNotEmpty, sizeMethods inherited from interface java.util.List
add, add, addAll, addAll, addFirst, addLast, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, reversed, set, size, sort, spliterator, subList, toArray, toArray
-
Constructor Details
-
CommonsCopyOnWriteArrayList
public CommonsCopyOnWriteArrayList()Create a new empty array list. -
CommonsCopyOnWriteArrayList
Create a new array list that contains the same elements as the provided collection.- Parameters:
aValues- The collection to copy the elements from. May benull.- See Also:
-
CommonsCopyOnWriteArrayList
Create a new array list with all provided elements.- Parameters:
aValues- The iterable from which the elements are copied from. May benull.- See Also:
-
CommonsCopyOnWriteArrayList
public CommonsCopyOnWriteArrayList(@Nullable Iterable<? extends SRCTYPE> aValues, @Nonnull Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) Create a new array list with all mapped items of the provided iterable.- Type Parameters:
SRCTYPE- source data type- Parameters:
aValues- The iterable from which the elements are copied from. May benull.aMapper- The mapping function to be executed for all provided elements. May not benull.- See Also:
-
CommonsCopyOnWriteArrayList
Create a new array list with an initial capacity of 1 and exactly the provided value, even if it isnull.- Parameters:
aValue- The value to be added. May benull.
-
CommonsCopyOnWriteArrayList
Create a new array list that contains the same elements as the provided array.- Parameters:
aValues- The array to copy the elements from. May benull.- See Also:
-
CommonsCopyOnWriteArrayList
public CommonsCopyOnWriteArrayList(@Nullable SRCTYPE[] aValues, @Nonnull Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) Create a new array list that contains mapped elements of the provided array.- Type Parameters:
SRCTYPE- source data type- Parameters:
aValues- The array to copy the elements from. May benull.aMapper- The mapping function to be executed for all provided elements. May not benull.- See Also:
-
-
Method Details
-
createInstance
Description copied from interface:ICommonsListCreate a new empty list. Overwrite this if you don't want to useCommonsArrayList.- Specified by:
createInstancein interfaceICommonsList<ELEMENTTYPE>- Type Parameters:
T- List element type- Returns:
- A new empty list. Never
null.
-
getClone
- Specified by:
getClonein interfaceICloneable<ELEMENTTYPE>- Returns:
- A 100% deep-copy of the implementing class.
-
createFiltered
@Nonnull @ReturnsMutableCopy public static <ELEMENTTYPE> CommonsCopyOnWriteArrayList<ELEMENTTYPE> createFiltered(@Nullable Iterable<? extends ELEMENTTYPE> aValues, @Nullable Predicate<? super ELEMENTTYPE> aFilter) Create a new array list that contains a subset of the provided iterable.
Note: this method is a static factory method because the compiler sometimes cannot deduce betweenPredicateandFunctionand the mapping case occurs more often.- Type Parameters:
ELEMENTTYPE- data type of the list- Parameters:
aValues- The iterable from which the elements are copied from. May benull.aFilter- The filter to be applied to check if the element should be added or not.- Returns:
- The created array list. Never
null. - Since:
- 9.1.3
- See Also:
-
createFiltered
@Nonnull @ReturnsMutableCopy public static <SRCTYPE,ELEMENTTYPE> CommonsCopyOnWriteArrayList<ELEMENTTYPE> createFiltered(@Nullable Iterable<? extends SRCTYPE> aValues, @Nullable Predicate<? super SRCTYPE> aFilter, @Nonnull Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) Create a new array list that contains a subset of the provided iterable. This method filters the elements before they are mapped.
Note: this method is a static factory method because the compiler sometimes cannot deduce betweenPredicateandFunctionand the mapping case occurs more often.- Type Parameters:
SRCTYPE- source data typeELEMENTTYPE- final data type of the list- Parameters:
aValues- The iterable from which the elements are copied from. May benull.aFilter- The filter to be applied to check if the element should be added or not.aMapper- The mapping function to be executed for all provided elements. May not benull.- Returns:
- The created array list. Never
null. - Since:
- 9.1.3
- See Also:
-
createFiltered
@Nonnull @ReturnsMutableCopy public static <SRCTYPE,ELEMENTTYPE> CommonsCopyOnWriteArrayList<ELEMENTTYPE> createFiltered(@Nullable Iterable<? extends SRCTYPE> aValues, @Nonnull Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper, @Nullable Predicate<? super ELEMENTTYPE> aFilter) Create a new array list that contains a subset of the provided iterable. This method maps the elements before they are filtered.
Note: this method is a static factory method because the compiler sometimes cannot deduce betweenPredicateandFunctionand the mapping case occurs more often.- Type Parameters:
SRCTYPE- source data typeELEMENTTYPE- final data type of the list- Parameters:
aValues- The iterable from which the elements are copied from. May benull.aMapper- The mapping function to be executed for all provided elements. May not benull.aFilter- The filter to be applied on the mapped element to check if the element should be added or not.- Returns:
- The created array list. Never
null. - Since:
- 9.1.3
- See Also:
-
createFiltered
@Nonnull @ReturnsMutableCopy public static <ELEMENTTYPE> CommonsCopyOnWriteArrayList<ELEMENTTYPE> createFiltered(@Nullable ELEMENTTYPE[] aValues, @Nullable Predicate<? super ELEMENTTYPE> aFilter) Create a new array list that contains a subset of the provided array.
Note: this method is a static factory method because the compiler sometimes cannot deduce betweenPredicateandFunctionand the mapping case occurs more often.- Type Parameters:
ELEMENTTYPE- data type of the list- Parameters:
aValues- The array from which the elements are copied from. May benull.aFilter- The filter to be applied to check if the element should be added or not.- Returns:
- The created array list. Never
null. - Since:
- 9.1.3
- See Also:
-
createFiltered
@Nonnull @ReturnsMutableCopy public static <SRCTYPE,ELEMENTTYPE> CommonsCopyOnWriteArrayList<ELEMENTTYPE> createFiltered(@Nullable SRCTYPE[] aValues, @Nullable Predicate<? super SRCTYPE> aFilter, @Nonnull Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) Create a new array list that contains a subset of the provided array. This method filters the elements before they are mapped.
Note: this method is a static factory method because the compiler sometimes cannot deduce betweenPredicateandFunctionand the mapping case occurs more often.- Type Parameters:
SRCTYPE- source data typeELEMENTTYPE- final data type of the list- Parameters:
aValues- The array from which the elements are copied from. May benull.aFilter- The filter to be applied to check if the element should be added or not.aMapper- The mapping function to be executed for all provided elements. May not benull.- Returns:
- The created array list. Never
null. - Since:
- 9.1.3
- See Also:
-
createFiltered
@Nonnull @ReturnsMutableCopy public static <SRCTYPE,ELEMENTTYPE> CommonsCopyOnWriteArrayList<ELEMENTTYPE> createFiltered(@Nullable SRCTYPE[] aValues, @Nonnull Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper, @Nullable Predicate<? super ELEMENTTYPE> aFilter) Create a new array list that contains a subset of the provided array. This method maps the elements before they are filtered.
Note: this method is a static factory method because the compiler sometimes cannot deduce betweenPredicateandFunctionand the mapping case occurs more often.- Type Parameters:
SRCTYPE- source data typeELEMENTTYPE- final data type of the list- Parameters:
aValues- The array from which the elements are copied from. May benull.aMapper- The mapping function to be executed for all provided elements. May not benull.aFilter- The filter to be applied on the mapped element to check if the element should be added or not.- Returns:
- The created array list. Never
null. - Since:
- 9.1.3
- See Also:
-