mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-05-07 01:01:09 +08:00
!4 修复随机数组中指定数量的随机元素时,当数量大于3会导致无法随机;随机索引的最大值需要跟随当前剩余数据进行减少
Merge pull request !4 from 陈骢/master
This commit is contained in:
@@ -97,7 +97,7 @@ export class RandomManager {
|
||||
var temp: Array<T> = objects.slice();
|
||||
var result: Array<T> = [];
|
||||
for (let i = 0; i < n; i++) {
|
||||
let index = this.getRandomInt(0, objects.length, n);
|
||||
let index = this.getRandomInt(0, temp.length, 1);
|
||||
result.push(temp.splice(index, 1)[0]);
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user