Discover Packages
tailscale.com
util
slicesx
package
Version:
v1.46.0
Opens a new window with list of versions in this module.
Published: Jul 19, 2023
License: BSD-3-Clause
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 9
Opens a new window with list of known importers.
Documentation
Documentation
¶
Package slicesx contains some helpful generic slice functions.
func Interleave[S ~[]T, T any ](a, b S) S
Interleave combines two slices of the form [a, b, c] and [x, y, z] into a
slice with elements interleaved; i.e. [a, x, b, y, c, z].
func Partition[S ~[]T, T any ](s S, cb func(T) bool ) (trues, falses S)
Partition returns two slices, the first containing the elements of the input
slice for which the callback evaluates to true, the second containing the rest.
This function does not mutate s.
func Shuffle[S ~[]T, T any ](s S)
Shuffle randomly shuffles a slice in-place, similar to rand.Shuffle.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.