public class Collects extends Object
| 构造器和说明 |
|---|
Collects() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> List<T> |
concat(List<T> list,
T... array) |
static <S,T> List<T> |
convert(List<S> source,
Function<S,T> mapper) |
static <T> List<T> |
duplicate(Collection<T> list) |
static <T,R> List<R> |
duplicate(Collection<T> list,
Function<T,R> mapper)
Returns the duplicates elements for list
|
static <T> List<T> |
filter(List<T> list,
Predicate<T> predicate) |
static <T> T |
get(List<T> list,
int index) |
static <T> T |
get(T[] array,
int index) |
static <T> T |
getFirst(Collection<T> values)
Gets the first element for values
|
static <T> T |
getLast(Collection<T> values)
Gets the last element for values
|
static <T> T[] |
newArray(Class<? extends T[]> newType,
int length) |
static <E> LinkedList<E> |
newLinkedList(E element) |
static List<int[]> |
partition(int[] array,
int size)
Returns consecutive sub array of an array,
each of the same size (the final list may be smaller).
|
static <T> T[] |
toArray(T... args) |
public static <E> LinkedList<E> newLinkedList(E element)
public static <T> T[] toArray(T... args)
public static <T> List<T> duplicate(Collection<T> list)
public static <T,R> List<R> duplicate(Collection<T> list, Function<T,R> mapper)
list - the listpublic static <T> T getFirst(Collection<T> values)
T - the values element typevalues - the valuespublic static <T> T getLast(Collection<T> values)
T - the values element typevalues - the valuespublic static <T> T get(T[] array,
int index)
public static <T> T get(List<T> list, int index)
public static List<int[]> partition(int[] array, int size)
Collects.partition(new int[]{1,1,2,5,3}, 1) -> [1, 1, 2, 5, 3]
Collects.partition(new int[]{1,1,2,5,3}, 3) -> [1, 1]; [2, 5]; [3]
Collects.partition(new int[]{1,1,2,5,3}, 5) -> [1]; [1]; [2]; [5]; [3]
Collects.partition(new int[]{1,1,2,5,3}, 6) -> [1]; [1]; [2]; [5]; [3]
Collects.partition(new int[]{1,1,2,5,3}, 100) -> [1]; [1]; [2]; [5]; [3]
array - the arraysize - the size@SafeVarargs public static <T> List<T> concat(List<T> list, T... array)
public static <T> T[] newArray(Class<? extends T[]> newType, int length)
Copyright © 2023. All rights reserved.