slicesx

package
v1.0.0-beta.191 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Last

func Last[T any](s []T, f func(T) bool) (*T, int, bool)

Returns the last element in the slice where the predicate returns true

func Map

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

Map maps elements of a slice from T to M, returning a new slice.

func MapWithErr

func MapWithErr[T any, S any](s []T, f func(T) (S, error)) ([]S, error)

MapWithErr maps elements of a slice from T to M, returning a new slice and a joined error if there are any. If an error is returned from the mapping function, a nil array and the error is returned.

func UniqueGroupBy

func UniqueGroupBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) (map[U]T, bool)

Types

type Diff

type Diff[T comparable, S ~[]T] struct {
	// contains filtered or unexported fields
}

func NewDiff

func NewDiff[T comparable, S ~[]T](base, new S) *Diff[T, S]

func (Diff[T, S]) Additions

func (d Diff[T, S]) Additions() S

func (Diff[T, S]) Changed

func (d Diff[T, S]) Changed() S

func (Diff[T, S]) Has

func (d Diff[T, S]) Has(item T) bool

func (Diff[T, S]) HasChanged

func (d Diff[T, S]) HasChanged() bool

func (Diff[T, S]) InAdditions

func (d Diff[T, S]) InAdditions(item T) bool

func (Diff[T, S]) InRemovals

func (d Diff[T, S]) InRemovals(item T) bool

func (Diff[T, S]) Removals

func (d Diff[T, S]) Removals() S

Jump to

Keyboard shortcuts

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