sliceutil

package
v0.0.0-...-91bea55 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllOf

func AllOf[S ~[]E, E any](slice S, predicate func(E) bool) bool

AllOf returns true if all elements in slice satisfy the predicate function.

func ContainsAll

func ContainsAll[S ~[]E, E comparable](super S, sub S) bool

Contains reports whether all elements in sub are present in super.

func Exclude

func Exclude[S ~[]E, E comparable](set S, excludeElement E) S

Exclude returns a new slice containing elements in set that are not equal to excludeElement.

func Filter

func Filter[T any](slice []T, predicate func(T) bool) []T

Filter returns a new slice containing only elements that satisfy the predicate function. Returns nil if the input slice is empty.

func InplaceTake

func InplaceTake[T any](slice []T, predicate []bool) []T

InplaceTake modifies the slice in place to contain only elements where the corresponding element in predicate is true. Please ensure len(slice) <= len(predicate) before calling this function.

func SliceDeDup

func SliceDeDup[S ~[]E, E cmp.Ordered](s S) S

SliceDeDup removes duplicate elements from a slice.

func SortMapKeyForDeterminism

func SortMapKeyForDeterminism[k cmp.Ordered, v any](m map[k]v) []k

SortMapKeyForDeterminism returns a slice of keys from a map in sorted order.

func SortedMap

func SortedMap[k cmp.Ordered, v any](m map[k]v) iter.Seq2[k, v]

SortedMap returns an iterator that yields key-value pairs from a map in sorted key order

func Subtraction

func Subtraction[S ~[]E, E comparable](a S, b S) S

Subtraction returns a new slice containing elements in a that are not present in b.

func Take

func Take[T any](slice []T, predicate []bool) []T

Take returns a new slice containing elements from slice where the corresponding element in predicate is true. Please ensure len(slice) <= len(predicate) before calling this function.

func UnOrderedSliceEqual

func UnOrderedSliceEqual[S ~[]E, E cmp.Ordered](s1, s2 S) bool

func ValueSortedByMapKey

func ValueSortedByMapKey[k cmp.Ordered, v any](m map[k]v) iter.Seq[v]

ValueSortedByMapKey returns an iterator that yields values from a map in sorted key order.

Types

This section is empty.

Jump to

Keyboard shortcuts

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