public class CollectionUtil extends Object
集合相关工具类,包括数组
| 构造器和说明 |
|---|
CollectionUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> T[] |
append(T[] buffer,
T newElement)
将新元素添加到已有数组中
添加新元素会生成一个新的数组,不影响原数组 |
static <T> String |
join(Iterable<T> collection,
String conjunction)
以 conjunction 为分隔符将集合转换为字符串
|
static <T> String |
join(T[] array,
String conjunction)
以 conjunction 为分隔符将数组转换为字符串
|
static <T> ArrayList<T> |
newArrayList()
新建一个ArrayList
|
static <T,K> HashMap<T,K> |
newHashMap()
新建一个HashMap
|
static <T> HashSet<T> |
newHashSet()
新建一个HashSet
|
static <T> List<T> |
popPart(Stack<T> surplusAlaDatas,
int partSize)
切取部分数据
|
static <T> T[] |
resize(T[] buffer,
int newSize)
生成一个新的重新设置大小的数组
新数组的类型为原数组的类型 |
static <T> T[] |
resize(T[] buffer,
int newSize,
Class<?> componentType)
生成一个新的重新设置大小的数组
|
static List<Map.Entry<Long,Long>> |
sortEntrySetToList(Set<Map.Entry<Long,Long>> set)
将Set排序(根据Entry的值)
|
public static <T> String join(Iterable<T> collection, String conjunction)
以 conjunction 为分隔符将集合转换为字符串
T - 被处理的集合collection - 集合conjunction - 分隔符public static <T> String join(T[] array, String conjunction)
以 conjunction 为分隔符将数组转换为字符串
T - 被处理的集合array - 数组conjunction - 分隔符public static List<Map.Entry<Long,Long>> sortEntrySetToList(Set<Map.Entry<Long,Long>> set)
将Set排序(根据Entry的值)
set - 被排序的Setpublic static <T> List<T> popPart(Stack<T> surplusAlaDatas, int partSize)
切取部分数据
T - 集合元素类型surplusAlaDatas - 原数据partSize - 每部分数据的长度public static <T,K> HashMap<T,K> newHashMap()
新建一个HashMap
public static <T> HashSet<T> newHashSet()
新建一个HashSet
public static <T> ArrayList<T> newArrayList()
新建一个ArrayList
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[] resize(T[] buffer,
int newSize)
生成一个新的重新设置大小的数组
新数组的类型为原数组的类型
buffer - 原数组newSize - 新的数组大小Copyright © 2016. All rights reserved.