ELEMENTTYPE - The data type of the elements in the list.public interface ICommonsList<ELEMENTTYPE> extends List<ELEMENTTYPE>, ICommonsCollection<ELEMENTTYPE>, ICloneable<ICommonsList<ELEMENTTYPE>>
List interface with extended functionality based on
ICommonsCollection.| Modifier and Type | Method and Description |
|---|---|
default <T> ICommonsList<T> |
createInstance()
Create a new empty list.
|
default ICommonsList<ELEMENTTYPE> |
getAll(Predicate<? super ELEMENTTYPE> aFilter)
Get all elements matching the provided filter.
|
default <DSTTYPE extends ELEMENTTYPE> |
getAllInstanceOf(Class<DSTTYPE> aDstClass)
Get all instances of the provided class that are contained in this list.
|
default <DSTTYPE> ICommonsList<DSTTYPE> |
getAllMapped(Function<? super ELEMENTTYPE,DSTTYPE> aMapper)
Create a new list where all existing elements are mapped with the provided
function.
|
default <DSTTYPE> ICommonsList<DSTTYPE> |
getAllMapped(Predicate<? super ELEMENTTYPE> aFilter,
Function<? super ELEMENTTYPE,DSTTYPE> aMapper)
Create a new list where all elements matching the filter are mapped with
the provided function.
|
default List<ELEMENTTYPE> |
getAsUnmodifiable() |
default ELEMENTTYPE |
getAtIndex(int nIndex,
ELEMENTTYPE aDefault)
Get the element at the specified index or return the provided default value
upon invalid index.
|
default ELEMENTTYPE |
getFirst() |
default ELEMENTTYPE |
getFirst(ELEMENTTYPE aDefault) |
default ELEMENTTYPE |
getLast() |
default ELEMENTTYPE |
getLast(ELEMENTTYPE aDefault) |
default ICommonsList<ELEMENTTYPE> |
getSortedInline(Comparator<? super ELEMENTTYPE> aComparator)
Sort this line without creating a copy.
|
default ELEMENTTYPE |
removeAndReturnElementAtIndex(int nIndex)
Remove the element at the specified index from the passed list.
|
default EChange |
removeAtIndex(int nIndex)
Remove the element at the specified index from the passed list.
|
default ELEMENTTYPE |
removeFirst()
Remove the first element of the list.
|
default ELEMENTTYPE |
removeLast()
Remove the last element of the list.
|
default ICommonsList<ELEMENTTYPE> |
reverse()
Reverse the order of this list.
|
default ELEMENTTYPE |
setFirst(ELEMENTTYPE aNewElement)
Set the first element of this list.
|
default ELEMENTTYPE |
setLast(ELEMENTTYPE aNewElement)
Set the last element of this list.
|
default ICommonsList<ELEMENTTYPE> |
swapItems(int nFirstIndex,
int nSecondIndex)
Swap list items.
|
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArrayaddAll, 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, setAllMappedparallelStream, removeIf, streamcontainsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstIndex, findFirstMapped, findFirstMapped, findLastIndex, forEach, forEachBreakable, forEachByIndex, getCountisEmpty, isNotEmpty, sizegetClone@Nonnull @ReturnsMutableCopy default <T> ICommonsList<T> createInstance()
CommonsArrayList.T - List element typenull.@Nonnull @ReturnsMutableCopy default ICommonsList<ELEMENTTYPE> getAll(@Nullable Predicate<? super ELEMENTTYPE> aFilter)
ICloneable.getClone().aFilter - The filter to be applied. May be null.null copy of this list containing all matching
entries (or all entries if no filter is provided).ICommonsIterable.findAll(Predicate, java.util.function.Consumer)@Nonnull @ReturnsMutableCopy default <DSTTYPE> ICommonsList<DSTTYPE> getAllMapped(@Nonnull Function<? super ELEMENTTYPE,DSTTYPE> aMapper)
DSTTYPE - The destination type to be mapped toaMapper - The mapping function to be executed. May not be null.null list with all mapped elements.getAllMapped(Predicate, Function),
ICommonsIterable.findAllMapped(Function, java.util.function.Consumer)@Nonnull @ReturnsMutableCopy default <DSTTYPE> ICommonsList<DSTTYPE> getAllMapped(@Nullable Predicate<? super ELEMENTTYPE> aFilter, @Nonnull Function<? super ELEMENTTYPE,DSTTYPE> aMapper)
DSTTYPE - The destination type to be mapped toaFilter - The filter to be applied. Maybe null.aMapper - The mapping function to be executed. May not be null.null list with all mapped elements. If no
filter is provided the result is the same as of
getAllMapped(Function).getAllMapped(Function),
ICommonsIterable.findAllMapped(Predicate, Function, java.util.function.Consumer)@Nonnull @ReturnsMutableCopy default <DSTTYPE extends ELEMENTTYPE> ICommonsList<DSTTYPE> getAllInstanceOf(@Nonnull Class<DSTTYPE> aDstClass)
DSTTYPE - The destination type to be casted toaDstClass - The class to search all instances of. May not be null.null.ICommonsIterable.findAllInstanceOf(Class, java.util.function.Consumer)@Nullable default ELEMENTTYPE getFirst()
null if the list is
empty.getFirst(Object),
ICommonsIterable.findFirst(Predicate)@Nullable default ELEMENTTYPE getFirst(@Nullable ELEMENTTYPE aDefault)
aDefault - The default value to be returned if this list is empty. May be
null.getFirst(),
ICommonsIterable.findFirst(Predicate)@Nullable default ELEMENTTYPE getLast()
null if the list is
empty.getLast(Object)@Nullable default ELEMENTTYPE getLast(@Nullable ELEMENTTYPE aDefault)
aDefault - The default value to be returned if this list is empty. May be
null.null if the list is
empty.getLast()@Nullable default ELEMENTTYPE getAtIndex(@Nonnegative int nIndex, @Nullable ELEMENTTYPE aDefault)
ICommonsCollectiongetAtIndex in interface ICommonsCollection<ELEMENTTYPE>nIndex - The index to access. Should be ≥ 0.aDefault - The value to be returned, if the index is out of bounds. May be
null.ICommonsCollection.getAtIndex(int)@Nullable default ELEMENTTYPE setFirst(@Nullable ELEMENTTYPE aNewElement)
aNewElement - The new element at index 0.null.List.set(int, Object)@Nullable default ELEMENTTYPE setLast(@Nullable ELEMENTTYPE aNewElement)
aNewElement - The new element at index size()-1.null.List.set(int, Object)@Nonnull default EChange removeAtIndex(int nIndex)
null and the index is ≥ 0 and <
list.size()nIndex - The index to be removed. May be arbitrary.EChange.CHANGED if removal was successfulremoveAndReturnElementAtIndex(int)@Nullable default ELEMENTTYPE removeAndReturnElementAtIndex(int nIndex)
null and the index is ≥ 0 and <
list.size()nIndex - The index to be removed. May be arbitrary.null if removal failed or the removed element. Note:
the removed element may also be null so it may be
tricky to determine if removal succeeded or not!removeAtIndex(int)@Nullable default ELEMENTTYPE removeFirst()
null if the list is empty or the previously contained
element at index 0.@Nullable default ELEMENTTYPE removeLast()
null if the list is empty or the previously contained
element at index size()-1.@Nonnull @CodingStyleguideUnaware default List<ELEMENTTYPE> getAsUnmodifiable()
getAsUnmodifiable in interface ICommonsCollection<ELEMENTTYPE>null
.Collections@Nonnull default ICommonsList<ELEMENTTYPE> getSortedInline(@Nonnull Comparator<? super ELEMENTTYPE> aComparator)
aComparator - The comparator used for sorting. May not be null.@Nonnull default ICommonsList<ELEMENTTYPE> reverse()
@Nonnull default ICommonsList<ELEMENTTYPE> swapItems(int nFirstIndex, int nSecondIndex)
nFirstIndex - The first index to swap.nSecondIndex - The second index to swap.Copyright © 2014–2019 Philip Helger. All rights reserved.