|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.xtext.xbase.lib.ListExtensions
public class ListExtensions
This is an extension library for lists
.
Constructor Summary | |
---|---|
ListExtensions()
|
Method Summary | ||
---|---|---|
static
|
map(java.util.List<T> original,
Functions.Function1<? super T,? extends R> transformation)
Returns a list that performs the given transformation for each element of original when
requested. |
|
static
|
reverse(java.util.List<T> list)
Reverses the order of the elements in the specified list. |
|
static
|
reverseView(java.util.List<T> list)
Provides a reverse view on the given list which is especially useful to traverse a list backwards in a for-each loop. |
|
static
|
sortInplace(java.util.List<T> list)
Sorts the specified list itself into ascending order, according to the natural ordering of its elements. |
|
static
|
sortInplace(java.util.List<T> list,
java.util.Comparator<? super T> comparator)
Sorts the specified list itself according to the order induced by the specified comparator. |
|
static
|
sortInplaceBy(java.util.List<T> list,
Functions.Function1<? super T,C> key)
Sorts the specified list itself according to the order induced by applying a key function to each element which yields a comparable criteria. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ListExtensions()
Method Detail |
---|
public static <T extends java.lang.Comparable<? super T>> java.util.List<T> sortInplace(java.util.List<T> list)
list
- the list to be sorted. May not be null
.
Collections.sort(List)
public static <T> java.util.List<T> sortInplace(java.util.List<T> list, java.util.Comparator<? super T> comparator)
list
- the list to be sorted. May not be null
.comparator
- the comparator to be used. May be null
to indicate that the natural ordering of the
elements should be used.
Collections.sort(List, Comparator)
,
sortInplace(List)
,
#sortInplaceBy(List, Function1)
public static <T,C extends java.lang.Comparable<? super C>> java.util.List<T> sortInplaceBy(java.util.List<T> list, Functions.Function1<? super T,C> key)
list
- the list to be sorted. May not be null
.key
- the key function to-be-used. May not be null
.
Collections.sort(List)
public static <T> java.util.List<T> reverseView(java.util.List<T> list)
list
- the list whose elements should be traversed in reverse. May not be null
.
public static <T> java.util.List<T> reverse(java.util.List<T> list)
list
- the list whose elements are to be reversed.
java.lang.UnsupportedOperationException
- if the specified list or its list-iterator does not support the set method.public static <T,R> java.util.List<R> map(java.util.List<T> original, Functions.Function1<? super T,? extends R> transformation)
transformation
for each element of original
when
requested. The mapping is done lazily. That is, subsequent iterations of the elements in the list will
repeatedly apply the transformation. The returned list is a transformed view of original
; changes to
original
will be reflected in the returned list and vice versa (e.g. invocations of List.remove(int)
).
original
- the original list. May not be null
.transformation
- the transformation. May not be null
.
null
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |