Documentation ¶
Index ¶
- func Append[S ~[]E, E any](s S, e ...E) S
- func Compact[S ~[]E, E comparable](s S) S
- func CompactFunc[S ~[]E, E any](s S, eq func(E, E) bool) S
- func Concat[S ~[]E, E any](slices ...S) S
- func Delete[S ~[]E, E any](s S, i, j int) S
- func DeleteFunc[S ~[]E, E any](s S, del func(E) bool) S
- func Insert[S ~[]E, E any](s S, i int, v ...E) S
- func Prepend[S ~[]E, E any](s S, e ...E) S
- func Replace[S ~[]E, E any](s S, i, j int, v ...E) S
- func Reverse[S ~[]E, E any](s S) S
- func Sort[S ~[]E, E cmp.Ordered](s S) S
- func SortFunc[S ~[]E, E any](s S, cmp func(a, b E) int) S
- func SortStableFunc[S ~[]E, E any](s S, cmp func(a, b E) int) S
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Append ¶
func Append[S ~[]E, E any](s S, e ...E) S
Append will create a new slice with the elements of s followed by the elements of e. This is a shorthand for a call to Concat(s, e) that allows passing the elements to append as variadic arguments.
func Compact ¶
func Compact[S ~[]E, E comparable](s S) S
Compact is an immutable variant of the standard libraries slices.Compact function. It will replace consecutive runs of equal elements with the first instance.
func CompactFunc ¶
CompactFunc is an immutable variant of the standard libraries slices.CompactFunc function. It will replace consecutive runs of elements for which the eq function returns true with with the first instance.
func Concat ¶
func Concat[S ~[]E, E any](slices ...S) S
Concat is an immutable variant of the stdlibs slices.Concat function. It will create a new slice (with a newly allocated backing array) that stores all elements of the specified slices in the order that they were specified.
func Delete ¶
Delete is an immutable variant of the standard libraries slices.Delete function. It will delete all elements at indexes from i up to but excluding j from the slice. The underlying slice and its backing array will not be modified in any way. When this function returns a non-nil value, the returned slice will be backed by a fresh array and so modifications to the output will not affect the input slice. Note that this will not copy the slice elements so care must still be taken to ensure no modifications to those elements if that is the desired constraint.
func DeleteFunc ¶
DeleteFunc is an immutable variant of the standard libraries slices.DeleteFunc function. This function will return a new slice with all elements of s for which the del function returns false. The underlying slice and its backing array will not be modified.
func Insert ¶
Insert is an immutable variant of the standard libraries slices.Insert function. It will insert the elements of v at index i in the slice s. The original slices will not be modified in any way.
func Prepend ¶
func Prepend[S ~[]E, E any](s S, e ...E) S
Prepend will create a new slice with the elements of e followed by the elements of s. This is a shorthand for a call to Concat(e, s) that allows passing the elements to prepend as variadic arguments.
func Replace ¶
Replace is an immutable variant of the standard libraries slices.Replace function. It will replace the elements represented by s[i:j] with the elements of v.
func Reverse ¶
func Reverse[S ~[]E, E any](s S) S
Reverse is an immutable variant of the standard libraries slices.Reverse function. It will create a new slice with a fresh backing array and populate it with elements from s in reverse order.
func Sort ¶
Sort is an immutable variant of the standard libraries slices.Sort function. It is a small wrapper which will clone the slice and then sort it to ensure that the original is not modified.
func SortFunc ¶
SortFunc is an immutable variant of the standard libraries slices.SortFunc function. It is a small wrapper which will clone the slice and then sort it to ensure that the original is not modified.
func SortStableFunc ¶
SortStableFunc is an immutable variant of the standard libraries slices.SortStableFunc function. It is a small wrapper which will clone the slice and then sort it to ensure that the original is not modified.
Types ¶
This section is empty.