Documentation
¶
Index ¶
- func Clear[S ~[]T, T any](s S) S
- func Insert[S ~[]T, T any](s S, index int, item T) []T
- func Pop[S ~[]T, T any](sptr *S) T
- func Random[S ~[]T, T any](s S) T
- func Remove[S ~[]T, T comparable](s S, item T) S
- func RemoveAt[S ~[]T, T any](s S, index int, n int) S
- func ShiftLeft[S ~[]T, T any](s S, n int) S
- func Shuffle[S ~[]T, T any](s S)
- func SortLess[S ~[]T, T any](s S, less func(a, b T) bool)
- func Truncate[S ~[]T, T any](s S) S
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Pop ¶
func Pop[S ~[]T, T any](sptr *S) T
Pop removes the last item from the slice and returns it. If the slice is empty, it panics. Internally uses slices.Pop to remove the last item.
func Random ¶
func Random[S ~[]T, T any](s S) T
Random returns a random item from the slice, panics if the slice is empty. Internally uses math/rand.Intn to generate a random index.
func Remove ¶
func Remove[S ~[]T, T comparable](s S, item T) S
Remove removes the first occurrence of the item from the slice.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.