Documentation ¶
Index ¶
- func Append[T any](s []T, item ...T) []T
- func Clone[T any](s []T) []T
- func Concat[T any](s ...[]T) []T
- func Contains[T Ordered](s []T, item T) bool
- func Distinct[T Ordered](s []T) []T
- func Every[T any](s []T, test func(item T) bool) bool
- func Filter[T any](s []T, test func(item T) bool) []T
- func Find[T any](s []T, test func(item T) bool) T
- func IndexOf[T Ordered](s []T, item T) int
- func IndexOfFunc[T any](s []T, test func(item T) bool) int
- func Intersection[T Ordered](s ...[]T) []T
- func Map[T any, K any](s []T, m func(item T) K) []K
- func Max[T Ordered](s []T) T
- func MaxFunc[T any](s []T, less func(T, T) bool) T
- func Min[T Ordered](s []T) T
- func MinFunc[T any](s []T, less func(T, T) bool) T
- func Reduce[T any, K any](s []T, f func(prev K, cur T) K) K
- func Reverse[T any](s []T) []T
- func Some[T any](s []T, test func(item T) bool) bool
- func Sort[T Ordered](s []T) []T
- func SortFunc[T any](s []T, less func(a T, b T) bool) []T
- func Splice[T any](s []T, index int, cnt int, item ...T) []T
- func Union[T Ordered](s ...[]T) []T
- func Unshift[T any](s []T, item ...T) []T
- type Ordered
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Append ¶ added in v0.0.2
func Append[T any](s []T, item ...T) []T
Append appends an item to the slice and returns the new slice. The given slice is not changed.
func Concat ¶
func Concat[T any](s ...[]T) []T
Concat combines the contents of all the given slices. The given slices are not changed.
func Distinct ¶ added in v0.0.4
func Distinct[T Ordered](s []T) []T
Distinct creates a new slice that contains all of the distinct items from the given slices without duplicates.
func Filter ¶
Filter creates a new slice that contains items from the given slice that satisfy the given test function and returns it. The given slice is not changed.
func IndexOf ¶
IndexOf finds the index of the first item in the given slice that satisfies the given test function.
func IndexOfFunc ¶ added in v0.0.4
IndexOfFunc finds the index of the first item in the given slice that satisfies the given test function.
func Intersection ¶ added in v0.0.3
func Intersection[T Ordered](s ...[]T) []T
Intersection creates a new slice that contains the intersection of all the given slices. The given slices are not changed. All items in the returned slice are distinct.
func Map ¶
Map creates a new slice with items that are mapped to new values according to the given m function. The given slice is not changed.
func Reduce ¶
Reduce iterates through the given slice, reducing the items to a value according to the given reducer function and returns the reduced value. The given slice is not changed.
func Reverse ¶
func Reverse[T any](s []T) []T
Reverse creates a slice that is the reverse of the provided slice and returns it. The given slice is not changed.
func Sort ¶
func Sort[T Ordered](s []T) []T
Sort creates a new slice that is sorted in ascending order. The given slice is not changed.
func SortFunc ¶
SortFunc creates a new slice that is sorted in ascending order according the the given less func and returns it. The given slice is not changed.
func Splice ¶
Splice creates a new slice that is spliced by removing or replacing existing elements and/or adding new elements in place. The given slice is not changed.