public final class RandomUtils extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> T |
choice(List<T> tList)
集合随机取值
|
static <T> List<T> |
choice(List<T> tList,
int count)
集合随机取值
|
static <K> K |
choice(Map<K,Integer> originMap)
根据value的数值(权重),返回因权重选中键值对的value
|
static <T> T |
choice(Set<T> tSet)
集合随机取值
|
static <T> Set<T> |
choice(Set<T> tSet,
int count)
集合随机取值
|
static <T> T |
choice(T[] tArray)
数组随机取值
|
static <T> T[] |
choice(T[] tArray,
int count)
数组随机取值
|
static <K,V> K |
choiceK(Map<K,V> kvMap) |
static <K,V> V |
choiceV(Map<K,V> kvMap) |
static int |
even(int bound)
-2 = 1111 1110
最后一位总是被置为0,前面几位不改变
|
static int |
nextInt(int bound) |
static int |
nextInt(int startInclude,
int endExclude) |
static int |
odd(int bound)
1 = 0000 0001
最后一位总是被置为1,前面几位不变
|
public static <K> K choice(Map<K,Integer> originMap)
K - 需要用来比对的keyoriginMap - 初始mappublic static <T> List<T> choice(List<T> tList, int count)
T - 集合类型tList - 集合public static <T> T choice(List<T> tList)
T - 集合类型tList - 集合public static <T> Set<T> choice(Set<T> tSet, int count)
T - 集合类型tSet - 集合public static <T> T choice(Set<T> tSet)
T - 集合类型tSet - 集合public static <T> T[] choice(T[] tArray,
int count)
T - 数组类型tArray - 数据public static <T> T choice(T[] tArray)
T - 数组类型tArray - 数据public static <K,V> V choiceV(Map<K,V> kvMap)
public static <K,V> K choiceK(Map<K,V> kvMap)
public static int odd(int bound)
bound - 数字上届(不包含),必须为正数public static int even(int bound)
bound - 数字上届(不包含),必须为正数public static int nextInt(int bound)
public static int nextInt(int startInclude,
int endExclude)
Copyright © 2020. All rights reserved.