slice

package
v0.0.0-...-16e1b16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chain

func Chain[T any](s []T) *chain[T]

Chain converts a slice to a Slice chain.

func Clone

func Clone[S ~[]E, E any](s S) *chain[E]

Clone returns a shallow copy of the slice.

func Contains

func Contains[T comparable](s []T, v T) bool

Contains returns true if the slice contains the element.

func ContainsFunc

func ContainsFunc[T any](s []T, f func(elem T) bool) bool

ContainsFunc returns true if the slice contains an element that satisfies the predicate.

func Count

func Count[T comparable](s []T, v T) int

Count returns the number of a given element in the slice.

func Every

func Every[T any](s []T, f func(elem T) bool) bool

Every returns true if all elements satisfy the predicate.

func Filter

func Filter[T any](s []T, f func(elem T) bool) *chain[T]

Filter returns a Slice chain containing only elements that satisfy the predicate.

func Find

func Find[T any](s []T, f func(elem T) bool) (T, bool)

Find returns the first element that satisfies the predicate.

func FindIndex

func FindIndex[T any](s []T, f func(elem T) bool) int

FindIndex returns the index of the first element that satisfies the predicate.

func IndexOf

func IndexOf[T comparable](s []T, v T) int

IndexOf returns the index of the first occurrence of the element in the slice.

func Map

func Map[T any, R any](s []T, f func(elem T) R) *chain[R]

Map returns a Slice chain containing the results of applying the function to each element.

func Pop

func Pop[T any](s []T) (T, *chain[T])

Pop removes and returns the last element of the slice and also returns a Slice chain.

func Push

func Push[T any](s []T, v T) *chain[T]

Push adds an element to the end of the slice and also returns a Slice chain.

func RemoveDuplicates

func RemoveDuplicates[T comparable](s []T) []T

RemoveDuplicates returns a slice with all duplicate elements removed.

func Shift

func Shift[T any](s []T) (T, *chain[T])

Shift removes and returns the first element of the slice and also returns a Slice chain.

func Some

func Some[T any](s []T, f func(elem T) bool) bool

Some returns true if at least one element satisfies the predicate.

func Unshift

func Unshift[T any](s []T, v T) *chain[T]

Unshift adds an element to the beginning of the slice and also returns a Slice chain.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL