slicex

package
v0.0.0-...-2bc3700 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package slicex defines various functions useful with slices of any type. This is an extension to the slices package in the Go's standard library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[S ~[]E, E any](s S, predicate func(e E) bool) bool

All returns true if predicate returns true for all elements in the slice. All returns true if the slice is empty.

func Any

func Any[S ~[]E, E any](s S, predicate func(e E) bool) bool

Any returns true if predicate returns true for any element in the slice. Any returns false if the slice is empty.

func Delete

func Delete[S ~[]E, E any](s *S, i, j int)

Delete removes the elements s[i:j] from s, modifies s in place. Delete panics if s[i:j] is not a valid slice of s. Delete is O(len(s)-j), so if many items must be deleted, it is better to make a single call deleting them all together than to delete one at a time. Delete might not modify the elements s[len(s)-(j-i):len(s)]. If those elements contain pointers Delete is zeroing those elements so that objects they reference will be garbage collected.

func Map

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

Map returns a new slice whose elements are converted with f from elements in s.

Types

This section is empty.

Jump to

Keyboard shortcuts

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