Documentation
¶
Overview ¶
Package shuffle provides primitives for shuffling slices and user-defined collections.
As of Go 1.10, the same functionality is now provided by package math/rand, and those implementations should be preferred in new code.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ints ¶
func Ints(a []int)
Ints shuffles a slice of ints.
Example ¶
x := []int{1, 2, 3, 4, 5}
shuffle.Ints(x)
for _, value := range x {
fmt.Println(value)
Output: 1 2 3 4 5
Types ¶
type Interface ¶
type Interface interface {
// Len is the number of elements in the collection.
Len() int
// Swap swaps the elements with indexes i and j.
Swap(i, j int)
}
Interface is a type, typically a collection, that satisfies shuffle.Interface can be shuffled by the routines in this package.
type Shuffler ¶
A Shuffler provides Shuffle
Click to show internal directories.
Click to hide internal directories.