|
@@ -20,10 +20,10 @@ public class RandomUtil {
|
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 创建副本以避免修改原始列表
|
|
|
|
|
List<T> copyList = new ArrayList<>(originalList);
|
|
List<T> copyList = new ArrayList<>(originalList);
|
|
|
- // 打乱顺序
|
|
|
|
|
- Collections.shuffle(copyList);
|
|
|
|
|
|
|
+ Random random = new Random();
|
|
|
|
|
+ random.setSeed(System.nanoTime() + random.nextLong());
|
|
|
|
|
+ Collections.shuffle(copyList, random);
|
|
|
// 取出前 count 个
|
|
// 取出前 count 个
|
|
|
return copyList.subList(0, Math.min(count, copyList.size()));
|
|
return copyList.subList(0, Math.min(count, copyList.size()));
|
|
|
}
|
|
}
|