Modifier | Constructor and Description |
---|---|
protected |
Collections() |
Modifier and Type | Method and Description |
---|---|
static void |
compact(Collection<?> c)
去除集合中的null
|
static <E> boolean |
contains(Collection<E> c,
E e)
集合是否包含元素
|
static <E> boolean |
containsAll(Collection<E> c,
Collection<E> e)
集合是否全部包含元素
|
static <E> Set<E> |
diff(Collection<E> c1,
Collection<E> c2)
查询差集
|
static <E> Set<E> |
diff(Collection<E> c1,
Collection<E> c2,
boolean diffAll)
查询差集
|
static <E> Set<E> |
diffAll(Collection<E> c1,
Collection<E> c2)
查询差集 先合并
|
static <E> Collection<E> |
distinct(Collection<E> c,
Function<E,?> keyGetter)
集合去重
|
static void |
exclude(Collection<?> c,
Object... es)
排除集合中指定的值
|
static <E> void |
fill(List<E> list,
E value)
将指定元素装配给集合
|
static <E> void |
fill(List<E> list,
E value,
int start) |
static <E> void |
fill(List<E> list,
E value,
int start,
int end) |
static <E> E |
first(Collection<E> c)
获取第一个元素
|
static <E> void |
forEach(Collection<E> c,
Consumer<? super E> action)
遍历
|
static <T> List<T> |
getDuplicateItems(Collection<T> list)
查询全部重复项
|
static <T> T |
getFirstDuplicateItem(Collection<T> list)
查询第一个重复项
|
static <E> Set<E> |
inter(Collection<E> c1,
Collection<E> c2)
查询交集
|
static boolean |
isAllEmpty(Collection<?>... cs)
集合是否全为空
|
static boolean |
isEmpty(Collection<?> c)
集合是否为空
|
static boolean |
isNoneEmpty(Collection<?>... cs)
集合是否全不为空
|
static boolean |
isNotEmpty(Collection<?> c)
集合是否不为空
|
static String |
join(Collection<?> c)
将集合连接成字符串
|
static String |
join(Collection<?> c,
String delimiter) |
static String |
join(Collection<?> c,
String delimiter,
String open,
String end) |
static <E> E |
last(Collection<E> c)
获取最后一个元素
|
static <T extends Object & Comparable<? super T>> |
max(Collection<? extends T> c)
最大值
|
static <T> T |
max(Collection<? extends T> c,
Comparator<? super T> comp)
最大值
|
static <T extends Object & Comparable<? super T>> |
min(Collection<? extends T> c)
最小值
|
static <T> T |
min(Collection<? extends T> c,
Comparator<? super T> comp)
最小值
|
static <E> Collection<E> |
newSynchronizedCollection(Collection<E> c) |
static int |
size(Collection<?> c)
集合长度
|
static <E> Stream<E> |
stream(Collection<E> c)
获取stream
|
static <E> Set<E> |
union(Collection<E> c1,
Collection<E> c2)
查询并集
|
static <E> Collection<E> |
unmodified(Collection<E> c) |
public static <E> Collection<E> newSynchronizedCollection(Collection<E> c)
public static <E> Collection<E> unmodified(Collection<E> c)
public static String join(Collection<?> c)
c
- 集合public static String join(Collection<?> c, String delimiter)
public static String join(Collection<?> c, String delimiter, String open, String end)
public static <E> Stream<E> stream(Collection<E> c)
E
- Ec
- cpublic static <E> void forEach(Collection<E> c, Consumer<? super E> action)
E
- Ec
- caction
- actionpublic static int size(Collection<?> c)
c
- 集合public static boolean isEmpty(Collection<?> c)
c
- 集合public static boolean isNotEmpty(Collection<?> c)
c
- 集合public static boolean isAllEmpty(Collection<?>... cs)
cs
- 集合public static boolean isNoneEmpty(Collection<?>... cs)
cs
- 集合public static <E> boolean contains(Collection<E> c, E e)
E
- Ec
- ce
- epublic static <E> boolean containsAll(Collection<E> c, Collection<E> e)
E
- Ec
- ce
- epublic static void compact(Collection<?> c)
c
- 集合public static void exclude(Collection<?> c, Object... es)
c
- 集合es
- 排除值 这个值可以为基本类型的元素, 但是不能是基本类型的数组public static <E> Set<E> inter(Collection<E> c1, Collection<E> c2)
E
- 类型c1
- 集合1c2
- 集合2public static <E> Set<E> union(Collection<E> c1, Collection<E> c2)
E
- 类型c1
- 集合1c2
- 集合2public static <E> Set<E> diff(Collection<E> c1, Collection<E> c2)
E
- 类型c1
- 集合1c2
- 集合2public static <E> Set<E> diffAll(Collection<E> c1, Collection<E> c2)
E
- 类型c1
- 集合1c2
- 集合2public static <E> Set<E> diff(Collection<E> c1, Collection<E> c2, boolean diffAll)
E
- 类型c1
- 集合1c2
- 集合2diffAll
- 是否先合并public static <E> void fill(List<E> list, E value)
E
- ignorelist
- 集合value
- 元素public static <E> void fill(List<E> list, E value, int start)
public static <E> void fill(List<E> list, E value, int start, int end)
public static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> c)
T
- 必须实现Comparable接口c
- 集合public static <T> T min(Collection<? extends T> c, Comparator<? super T> comp)
T
- ignorec
- 集合comp
- 排序接口public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> c)
T
- 必须实现Comparable接口c
- 集合public static <T> T max(Collection<? extends T> c, Comparator<? super T> comp)
T
- ignorec
- 集合comp
- 排序接口public static <E> E first(Collection<E> c)
E
- ignorec
- 集合public static <E> E last(Collection<E> c)
E
- ignorec
- 集合public static <E> Collection<E> distinct(Collection<E> c, Function<E,?> keyGetter)
E
- Ec
- ckeyGetter
- keyGetterpublic static <T> T getFirstDuplicateItem(Collection<T> list)
T
- Tlist
- listpublic static <T> List<T> getDuplicateItems(Collection<T> list)
T
- Tlist
- listCopyright © 2024. All rights reserved.