Documentation ¶
Overview ¶
Package shuffle provides primitives for shuffling slices and user-defined collections.
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
func SortInt64s ¶
func SortInt64s(a []int64)
SortInt64s sorts a slice of int64s in increasing order.
Types ¶
type Int64Slice ¶
type Int64Slice []int64
Int64Slice attaches the methods of Interface to []int64, sorting in increasing order.
func (Int64Slice) Len ¶
func (p Int64Slice) Len() int
func (Int64Slice) Less ¶
func (p Int64Slice) Less(i, j int) bool
func (Int64Slice) Swap ¶
func (p Int64Slice) Swap(i, j int)
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.
Click to show internal directories.
Click to hide internal directories.