File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -352,20 +352,20 @@ func Sample[T any](collection []T) T {
352
352
func Samples [T any ](collection []T , count int ) []T {
353
353
size := len (collection )
354
354
355
- cOpy := append ([]T {}, collection ... )
355
+ copy := append ([]T {}, collection ... )
356
356
357
357
results := []T {}
358
358
359
359
for i := 0 ; i < size && i < count ; i ++ {
360
360
copyLength := size - i
361
361
362
362
index := rand .Intn (size - i )
363
- results = append (results , cOpy [index ])
363
+ results = append (results , copy [index ])
364
364
365
365
// Removes element.
366
366
// It is faster to swap with last element and remove it.
367
- cOpy [index ] = cOpy [copyLength - 1 ]
368
- cOpy = cOpy [:copyLength - 1 ]
367
+ copy [index ] = copy [copyLength - 1 ]
368
+ copy = copy [:copyLength - 1 ]
369
369
}
370
370
371
371
return results
You can’t perform that action at this time.
0 commit comments