Documentation ¶
Index ¶
- func Copy[T any](s []T) []T
- func Count[T constraints.Ordered](s []T, item T) int
- func Cut[T constraints.Ordered](s []T, sep T) (before, after []T, found bool)
- func Delete[T any](s []T, i int) []T
- func DeleteFast[T any](s []T, i int) []T
- func DeleteN[T any](s []T, start, n int) []T
- func Filter[T any](s []T, keep func(T) bool) []T
- func Index[T constraints.Ordered](s []T, item T) int
- func Insert[T any](s []T, i int, items ...T) []T
- func LastIndex[T constraints.Ordered](s []T, item T) int
- func Pop[T any](s []T) (T, []T)
- func Remove[T constraints.Ordered](s []T, items ...T) []T
- func Replace[T constraints.Ordered](s []T, old, new T, n int)
- func ReplaceLast[T constraints.Ordered](s []T, old, new T, n int)
- func Reverse[T any](s []T)
- func Sort[T constraints.Ordered](s []T)
- func SortReverse[T constraints.Ordered](s []T)
- func Unique[T constraints.Ordered](s []T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Count ¶
func Count[T constraints.Ordered](s []T, item T) int
Count counts the number of instances of item in s.
func Cut ¶
func Cut[T constraints.Ordered](s []T, sep T) (before, after []T, found bool)
Cut slices s around the first instance of sep, returning the slice before and after sep. The found result reports whether sep is an element of s. If sep is not an element of s, cut returns s, nil, false.
func DeleteFast ¶
DeleteFast removes the item at index i without preserving order.
func DeleteN ¶
DeleteN removes items in s from index start to start + n. If n is -1, then s is truncated at start.
func Index ¶
func Index[T constraints.Ordered](s []T, item T) int
Index returns the index of the first instance of item in s, or -1 if item is not present in s.
func LastIndex ¶
func LastIndex[T constraints.Ordered](s []T, item T) int
LastIndex returns the index of the last instance of item in s, or -1 if item is not present in s.
func Remove ¶
func Remove[T constraints.Ordered](s []T, items ...T) []T
Remove returns a slize with all occurrances of each item removed.
func Replace ¶
func Replace[T constraints.Ordered](s []T, old, new T, n int)
Replace replaces the first n instances of old, in s, with new. If n is -1, then there is no limit on the number of replacements.
func ReplaceLast ¶
func ReplaceLast[T constraints.Ordered](s []T, old, new T, n int)
ReplaceLast replaces the last n instances of old, in s, with new. If n is -1, then there is no limit on the number of replacements.
func SortReverse ¶
func SortReverse[T constraints.Ordered](s []T)
SortReverse sorts s in-place in descending order.
func Unique ¶
func Unique[T constraints.Ordered](s []T) []T
Unique removes duplicate items in s, keeping only the first instance of each.
Types ¶
This section is empty.