Documentation ¶
Overview ¶
Package slicesx contains some helpful generic slice functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualSameNil ¶
func EqualSameNil[S ~[]E, E comparable](s1, s2 S) bool
EqualSameNil reports whether two slices are equal: the same length, same nilness (notably when length zero), and all elements equal. If the lengths are different or their nilness differs, Equal returns false. Otherwise, the elements are compared in increasing index order, and the comparison stops at the first unequal pair. Floating point NaNs are not considered equal.
It is identical to the standard library's slices.Equal but adds the matching nilness check.
func Filter ¶
Filter calls fn with each element of the provided src slice, and appends the element to dst if fn returns true.
dst can be nil to allocate a new slice, or set to src[:0] to filter in-place without allocating.
func Interleave ¶
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].
Types ¶
This section is empty.