(population = [], quantity, seed)
| 14452 | } |
| 14453 | } |
| 14454 | static sampleWithoutReplacement(population = [], quantity, seed) { |
| 14455 | const prng = this._getPseudoRandom0to1FloatGenerator(seed) |
| 14456 | const sampled = {} |
| 14457 | const populationSize = population.length |
| 14458 | if (quantity >= populationSize) return population.slice(0) |
| 14459 | const picked = [] |
| 14460 | while (picked.length < quantity) { |
| 14461 | const index = Math.floor(prng() * populationSize) |
| 14462 | if (sampled[index]) continue |
| 14463 | sampled[index] = true |
| 14464 | picked.push(population[index]) |
| 14465 | } |
| 14466 | return picked |
| 14467 | } |
| 14468 | static arrayToMap(arr) { |
| 14469 | const map = {} |
| 14470 | arr.forEach(val => (map[val] = true)) |
nothing calls this directly
no test coverage detected