Modifier and Type | Method and Description |
---|---|
static <E> void |
replaceAll(List<E> list,
UnaryOperator<E> operator)
Replaces each element of the passed list with the result of applying the
operator to that element.
|
static <E> void |
sort(List<E> list,
Comparator<? super E> c)
Sorts the passed list using the supplied
Comparator to compare
elements. |
static <E> Spliterator<E> |
spliterator(List<E> list)
Creates a
Spliterator over the elements in the passed list. |
public static <E> void sort(List<E> list, Comparator<? super E> c)
Comparator
to compare
elements.
Implementation Requirements:
The default implementation is equivalent to, for the passed list
:
Collections.sort(list, c)
E
- the type of the elements of the list to be sortedlist
- the list that should be sortedc
- the Comparator
used to compare list elements.
A null
value indicates that the elements'
natural ordering should be usedClassCastException
- if the list contains elements that are not
mutually comparable using the specified comparatorUnsupportedOperationException
- if the list's list-iterator does
not support the set
operationIllegalArgumentException
- (optional)
if the comparator is found to violate the Comparator
contractNullPointerException
- if the specified list is nullpublic static <E> void replaceAll(List<E> list, UnaryOperator<E> operator)
Implementation Requirements:
The default implementation is equivalent to, for the passed list
:
final ListIterator<E> li = list.listIterator();
while (li.hasNext()) {
li.set(operator.apply(li.next()));
}
If the list's list-iterator does not support the set
operation
then an UnsupportedOperationException
will be thrown when
replacing the first element.E
- the type of the elements of the list to be replacedlist
- the list whose elements should be replacedoperator
- the operator to apply to each elementUnsupportedOperationException
- if the passed list is unmodifiable.
Implementations may throw this exception if an element
cannot be replaced or if, in general, modification is not
supportedNullPointerException
- if the specified list is null or the specified
operator is null or if the operator result is a null value and the
passed list does not permit null elements (optional)public static <E> Spliterator<E> spliterator(List<E> list)
Spliterator
over the elements in the passed list.
The Spliterator
reports at least Spliterator.SIZED
,
Spliterator.ORDERED
and Spliterator.SUBSIZED
.
Implementation notes:
This implementation delegates to Spliterators.spliterator(java.util.Collection)
so it is effectively the same as calling
Spliterators.spliterator(list);
E
- the type of the elements of the list to be splittedlist
- the list to be splittedSpliterator
over the elements in the passed listCopyright © 2015. All rights reserved.