|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectcom.xiaoleilu.hutool.CollectionUtil
public class CollectionUtil
集合相关工具类,包括数组
| 构造方法摘要 | |
|---|---|
CollectionUtil()
|
|
| 方法摘要 | ||
|---|---|---|
static
|
addAll(T[]... arrays)
将多个数组合并在一起 忽略null的数组 |
|
static
|
append(T[] buffer,
T newElement)
将新元素添加到已有数组中 添加新元素会生成一个新的数组,不影响原数组 |
|
static
|
clone(T[] array)
克隆数组 |
|
static
|
isEmpty(Collection<T> collection)
集合是否为空 |
|
static
|
isEmpty(T[] array)
数组是否为空 |
|
static
|
isNotEmpty(Collection<T> collection)
集合是否为非空 |
|
static
|
isNotEmpty(T[] array)
数组是否为非空 |
|
static
|
join(Iterable<T> collection,
String conjunction)
以 conjunction 为分隔符将集合转换为字符串 |
|
static
|
join(T[] array,
String conjunction)
以 conjunction 为分隔符将数组转换为字符串 |
|
static
|
newArray(Class<?> componentType,
int newSize)
新建一个空数组 |
|
static
|
newArrayList()
新建一个ArrayList |
|
static
|
newArrayList(T... values)
新建一个ArrayList |
|
static
|
newHashMap()
新建一个HashMap |
|
static
|
newHashMap(int size)
新建一个HashMap |
|
static
|
newHashSet()
新建一个HashSet |
|
static
|
popPart(Stack<T> surplusAlaDatas,
int partSize)
切取部分数据 |
|
static int[] |
range(int excludedEnd)
生成一个数字列表 自动判定正序反序 |
|
static int[] |
range(int includedStart,
int excludedEnd)
生成一个数字列表 自动判定正序反序 |
|
static int[] |
range(int includedStart,
int excludedEnd,
int step)
生成一个数字列表 自动判定正序反序 |
|
static
|
resize(T[] buffer,
int newSize)
生成一个新的重新设置大小的数组 新数组的类型为原数组的类型 |
|
static
|
resize(T[] buffer,
int newSize,
Class<?> componentType)
生成一个新的重新设置大小的数组 |
|
static List<Map.Entry<Long,Long>> |
sortEntrySetToList(Set<Map.Entry<Long,Long>> set)
将Set排序(根据Entry的值) |
|
static
|
sortPageAll(int pageNo,
int numPerPage,
Comparator<T> comparator,
Collection<T>... colls)
将多个集合排序并显示不同的段落(分页) |
|
static
|
sortPageAll2(int pageNo,
int numPerPage,
Comparator<T> comparator,
Collection<T>... colls)
将多个集合排序并显示不同的段落(分页) |
|
static
|
sub(Collection<T> list,
int start,
int end)
截取集合的部分 |
|
static
|
sub(List<T> list,
int start,
int end)
截取数组的部分 |
|
static
|
zip(Collection<T> keys,
Collection<K> values)
映射键值(参考Python的zip()函数) 例如: keys = [a,b,c,d] values = [1,2,3,4] 则得到的Map是 {a=1, b=2, c=3, d=4} 如果两个数组长度不同,则只对应最短部分 |
|
static Map<String,String> |
zip(String keys,
String values,
String delimiter)
映射键值(参考Python的zip()函数) 例如: keys = a,b,c,d values = 1,2,3,4 delimiter = , 则得到的Map是 {a=1, b=2, c=3, d=4} 如果两个数组长度不同,则只对应最短部分 |
|
static
|
zip(T[] keys,
K[] values)
映射键值(参考Python的zip()函数) 例如: keys = [a,b,c,d] values = [1,2,3,4] 则得到的Map是 {a=1, b=2, c=3, d=4} 如果两个数组长度不同,则只对应最短部分 |
|
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public CollectionUtil()
| 方法详细信息 |
|---|
public static <T> String join(Iterable<T> collection,
String conjunction)
T - 被处理的集合collection - 集合conjunction - 分隔符
public static <T> String join(T[] array,
String conjunction)
T - 被处理的集合array - 数组conjunction - 分隔符
public static <T> List<T> sortPageAll(int pageNo,
int numPerPage,
Comparator<T> comparator,
Collection<T>... colls)
pageNo - 页码numPerPage - 每页的条目数comparator - 比较器colls - 集合数组
public static <T> List<T> sortPageAll2(int pageNo,
int numPerPage,
Comparator<T> comparator,
Collection<T>... colls)
pageNo - 页码numPerPage - 每页的条目数comparator - 比较器colls - 集合数组
public static List<Map.Entry<Long,Long>> sortEntrySetToList(Set<Map.Entry<Long,Long>> set)
set - 被排序的Set
public static <T> List<T> popPart(Stack<T> surplusAlaDatas,
int partSize)
T - 集合元素类型surplusAlaDatas - 原数据partSize - 每部分数据的长度
public static <T,K> HashMap<T,K> newHashMap()
public static <T,K> HashMap<T,K> newHashMap(int size)
size - 初始大小,由于默认负载因子0.75,传入的size会实际初始大小为size / 0.75
public static <T> HashSet<T> newHashSet()
public static <T> ArrayList<T> newArrayList()
public static <T> ArrayList<T> newArrayList(T... values)
public static <T> T[] append(T[] buffer,
T newElement)
buffer - 已有数组newElement - 新元素
public static <T> T[] resize(T[] buffer,
int newSize,
Class<?> componentType)
buffer - 原数组newSize - 新的数组大小componentType - 数组元素类型
public static <T> T[] newArray(Class<?> componentType,
int newSize)
componentType - 元素类型newSize - 大小
public static <T> T[] resize(T[] buffer,
int newSize)
buffer - 原数组newSize - 新的数组大小
public static <T> T[] addAll(T[]... arrays)
arrays - 数组集合
public static <T> T[] clone(T[] array)
array - 被克隆的数组
public static int[] range(int excludedEnd)
excludedEnd - 结束的数字(不包含)
public static int[] range(int includedStart,
int excludedEnd)
includedStart - 开始的数字(包含)excludedEnd - 结束的数字(不包含)
public static int[] range(int includedStart,
int excludedEnd,
int step)
includedStart - 开始的数字(包含)excludedEnd - 结束的数字(不包含)step - 步进
public static <T> List<T> sub(List<T> list,
int start,
int end)
list - 被截取的数组start - 开始位置(包含)end - 结束位置(不包含)
public static <T> List<T> sub(Collection<T> list,
int start,
int end)
list - 被截取的数组start - 开始位置(包含)end - 结束位置(不包含)
public static <T> boolean isEmpty(T[] array)
array - 数组
public static <T> boolean isNotEmpty(T[] array)
array - 数组
public static <T> boolean isEmpty(Collection<T> collection)
collection - 集合
public static <T> boolean isNotEmpty(Collection<T> collection)
collection - 集合
public static <T,K> Map<T,K> zip(T[] keys,
K[] values)
keys - 键列表values - 值列表
public static Map<String,String> zip(String keys,
String values,
String delimiter)
keys - 键列表values - 值列表
public static <T,K> Map<T,K> zip(Collection<T> keys,
Collection<K> values)
keys - 键列表values - 值列表
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||