slice

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package slice contains utility functions to manage slices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LongestString added in v0.8.2

func LongestString(slice []string) string

LongestString returns the longest string in a slice of strings.

func Map

func Map[K, V any](s []K, f func(K) V) []V

Map applies a function to each element of a slice and returns a new slice with the results.

func Merge added in v0.10.2

func Merge[K comparable](s1, s2 []K) []K

Merge merges two slices removing duplicates.

func Remove added in v0.10.2

func Remove[K comparable](slice []K, s K) []K

Remove returns a newly created slice that contains all items from slice that are not equal to s.

func Sub added in v0.10.2

func Sub[K comparable](s1, s2 []K) []K

Sub removes elements of s2 from s1.

func ToPointerSlice

func ToPointerSlice[T any](s []T) []*T

ToPointerSlice returns a new slice of pointers to the elements of the input slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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