slicex

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountFunc

func CountFunc[T any](slice []T, predicate func(T) bool) int

CountFunc returns the number of elements in slice that satisfy the predicate function.

func Equals

func Equals[S1 ~[]E, S2 ~[]E, E comparable](a S1, b S2) bool

Equals checks if two slices are equal both in length and content.

func Fill

func Fill[S ~[]E, E any](slice S, value E)

Fill sets all elements of the slice to the specified value.

func Filter

func Filter[S ~[]E, E any](source S, predicate func(E) bool) S

Filter returns a new slice containing only the elements of the source slice that satisfy the predicate function.

func FilterInPlace

func FilterInPlace[S ~[]E, E any](source *S, predicate func(E) bool)

FilterInPlace modifies the source slice in place to retain only the elements that satisfy the predicate function. This function avoids additional memory allocation while not preserving the order of elements.

func FilterInPlaceStable

func FilterInPlaceStable[S ~[]E, E any](source *S, predicate func(E) bool)

FilterInPlaceStable modifies the source slice in place to retain only the elements that satisfy the predicate function. This function avoids additional memory allocation while preserving the order of elements.

func FilterToIterable

func FilterToIterable[S ~[]E, E any](source S, predicate func(E) bool) iter.Seq[E]

FilterToIterable returns an iterable sequence containing only the elements of the source slice that satisfy the predicate function.

func Transform

func Transform[S1 ~[]E1, S2 ~[]E2, E1, E2 any](source S1, transformer func(E1) E2) S2

Transform applies the transformer function to each element of the source slice and returns a new slice containing the results.

func TransformInPlace

func TransformInPlace[S ~[]E, E any](source S, transformer func(E) E)

TransformInPlace applies the transformer function to each element of the source slice and modifies the source slice in place.

func TransformToIterable

func TransformToIterable[S ~[]E1, E1, E2 any](source S, transformer func(E1) E2) iter.Seq[E2]

TransformToIterable applies the transformer function to each element of the source slice and returns an iterable sequence of the results.

func Unique

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

Unique returns a new slice containing only the unique elements from the source slice, preserving the order of their first occurrence.

func UniqueInPlace

func UniqueInPlace[S ~[]E, E comparable](source *S)

UniqueInPlace modifies the source slice in place to contain only the unique elements, preserving the order of their first occurrence.

Types

This section is empty.

Jump to

Keyboard shortcuts

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