public final class Lists extends Object
| Constructor and Description |
|---|
Lists() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
add(List<T> list,
T element)
Add element to the given list and get added value as result
|
static <T> T |
get(List<T> list,
int index)
Get element of list at the given position without risk of
ArrayIndexOutOfBoundsException |
static <T> List<T> |
mutableOf(T... elements)
Create mutable list from varargs
|
static <T> List<T> |
reverse(List<T> list)
Reverse the provided list and return its
|
static <T> void |
sort(Comparator<T> comparator,
List<? extends T>... collections)
Sort similar lists using the same comparator
|
static <T> List<T>[] |
split(List<T> list,
T delimiter)
Split list by the given delimiter
|
static <T> List<T> |
subList(List<T> list,
int startIndex)
Returns a view of the portion of the given list
|
static <T> ArrayList<T> |
subList(List<T> list,
int startIndex,
int endIndex)
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex exclusive.
|
public static <T> T add(List<T> list, T element)
T - type of elementlist - the list to useelement - the element to addpublic static <T> List<T> subList(List<T> list, int startIndex)
T - type of listlist - the list to usestartIndex - low endpoint (inclusive) of the subListpublic static <T> ArrayList<T> subList(List<T> list, int startIndex, int endIndex)
T - type of listlist - the list to use as source liststartIndex - the start indexendIndex - the end index@SafeVarargs public static <T> void sort(Comparator<T> comparator, List<? extends T>... collections)
T - type of the listscomparator - the comparator to usecollections - the array of lists to sortpublic static <T> List<T> reverse(List<T> list)
T - type of the listlist - the list to reversepublic static <T> List<T>[] split(List<T> list, T delimiter)
T - type of listlist - the list to splitdelimiter - the object to use as delimiter@SafeVarargs public static <T> List<T> mutableOf(T... elements)
T - type of the listelements - to add to the array@Nullable public static <T> T get(List<T> list, int index)
ArrayIndexOutOfBoundsExceptionT - type of the listlist - the list to processindex - the index of element to getCopyright © 2020. All rights reserved.