slices

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

Package slices provides generic slice utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[S []E, E any](s S, p ...func(e E) bool) S

Filter removes all elements in the given slice that do not match the given predicates.

NOTE: Providing no predicates results in a no-op.

func Subset

func Subset[S []E, E comparable](a, b S) bool

Subset returns a boolean indicating whether a, is a subset of b.

NOTE: Returns true if a has zero elements since an empty set is a subset of all sets.

func Sum

func Sum[S []E, E constraints.Ordered](s S) E

Sum returns the summation of the elements in the provided slice.

func Union

func Union[S []E, E comparable](a, b S) S

Union returns a slice of elements that are present in both input slices.

NOTE: The returned slice will not contain any duplicates.

Types

This section is empty.

Jump to

Keyboard shortcuts

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