public class CollectionUtil extends Object
Ordering| Constructor and Description |
|---|
CollectionUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends Comparable<?>> |
bottomN(Iterable<T> coll,
int n)
返回Iterable中最小的N个对象, back by guava.
|
static <T> List<T> |
bottomN(Iterable<T> coll,
int n,
Comparator<? super T> comp)
返回Iterable中最小的N个对象, back by guava.
|
static boolean |
elementsEqual(Iterable<?> iterable1,
Iterable<?> iterable2)
两个集合中的所有元素按顺序相等.
|
static <T> T |
getFirst(Collection<T> collection)
取得Collection的第一个元素,如果collection为空返回null.
|
static <T> T |
getLast(Collection<T> collection)
获取Collection的最后一个元素,如果collection为空返回null.
|
static boolean |
isEmpty(Collection<?> collection)
判断是否为空.
|
static boolean |
isNotEmpty(Collection<?> collection)
判断是否不为空.
|
static <T extends Object & Comparable<? super T>> |
max(Collection<? extends T> coll)
返回无序集合中的最大值,使用元素默认排序
|
static <T> T |
max(Collection<? extends T> coll,
Comparator<? super T> comp)
返回无序集合中的最大值
|
static <T extends Object & Comparable<? super T>> |
min(Collection<? extends T> coll)
返回无序集合中的最小值,使用元素默认排序
|
static <T> T |
min(Collection<? extends T> coll,
Comparator<? super T> comp)
返回无序集合中的最小值
|
static <T extends Object & Comparable<? super T>> |
minAndMax(Collection<? extends T> coll)
同时返回无序集合中的最小值和最大值,使用元素默认排序
在返回的Pair中,第一个为最小值,第二个为最大值
|
static <T> Pair<T,T> |
minAndMax(Collection<? extends T> coll,
Comparator<? super T> comp)
返回无序集合中的最小值和最大值
在返回的Pair中,第一个为最小值,第二个为最大值
|
static <T extends Comparable<?>> |
topN(Iterable<T> coll,
int n)
返回Iterable中最大的N个对象, back by guava.
|
static <T> List<T> |
topN(Iterable<T> coll,
int n,
Comparator<? super T> comp)
返回Iterable中最大的N个对象, back by guava.
|
public static boolean isEmpty(Collection<?> collection)
public static boolean isNotEmpty(Collection<?> collection)
public static <T> T getFirst(Collection<T> collection)
public static <T> T getLast(Collection<T> collection)
public static boolean elementsEqual(Iterable<?> iterable1, Iterable<?> iterable2)
public static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> coll)
public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp)
public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll)
public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp)
public static <T extends Object & Comparable<? super T>> Pair<T,T> minAndMax(Collection<? extends T> coll)
public static <T> Pair<T,T> minAndMax(Collection<? extends T> coll, Comparator<? super T> comp)
public static <T extends Comparable<?>> List<T> topN(Iterable<T> coll, int n)
public static <T> List<T> topN(Iterable<T> coll, int n, Comparator<? super T> comp)
public static <T extends Comparable<?>> List<T> bottomN(Iterable<T> coll, int n)
public static <T> List<T> bottomN(Iterable<T> coll, int n, Comparator<? super T> comp)
Copyright © 2018. All rights reserved.