slices

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package slices contains functions for working with slices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

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

Contains returns true if e is in s.

func Filter

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

Filter returns a new slice containing only those elements for which f(element) is true.

func Map added in v0.25.0

func Map[S ~[]E, E, T any](s S, f func(E) T) []T

Map constructs a new slice containing the elements obtained by invoking the function f on each element of s.

func Remove

func Remove[S ~[]E, E comparable](s S, e E) S

Remove removes e from s.

func Reverse added in v0.22.2

func Reverse[S ~[]E, E comparable](s S)

Reverse reverses a slice's order.

func Unique

func Unique[S ~[]E, E comparable](s S) S

Unique returns the unique elements of s.

func UniqueBy added in v0.22.2

func UniqueBy[S ~[]E, E any, V comparable](s S, by func(E) V) S

UniqueBy returns the unique elements of s using a function to map elements.

Types

This section is empty.

Jump to

Keyboard shortcuts

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