slice

package
v2.1.38 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package slices defines various functions useful with slices of any type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

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

Clone returns a copy of the slice. The elements are copied using assignment, so this is a shallow clone.

func Contains

func Contains[S ~[]E, E comparable](s S, v E) bool

Contains reports whether v is present in s.

func ContainsFunc

func ContainsFunc[S ~[]E, E any](s S, f func(E) bool) bool

ContainsFunc reports whether at least one element e of s satisfies f(e).

func Diff

func Diff[S ~[]E, E comparable](s1, s2 S) S

Diff return the difference set of s1 and s2, that is, the set of all elements that belong to s1 but not s2.

func Index

func Index[S ~[]E, E comparable](s S, v E) int

Index returns the index of the first occurrence of v in s, or -1 if not present.

func IndexFunc

func IndexFunc[S ~[]E, E any](s S, f func(E) bool) int

IndexFunc returns the first index i satisfying f(s[i]), or -1 if none do.

func Intersect

func Intersect[S ~[]E, E comparable](s1, s2 S) S

Intersect return the intersection set of s1 and s2, that is, the set of all elements that belong to both s1 and s2.

Types

This section is empty.

Jump to

Keyboard shortcuts

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