collections

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

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

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dereference

func Dereference[E any](list []*E) []E

Dereference is a function that dereferences elements of a provided slice of pointers.

func Filter

func Filter[E any](input []E, predicate func(E) bool) []E

Filter returns a new slice which results from applying the provided predicate to the input slice.

func FilterInPlace

func FilterInPlace[E any](list []*E, predicate func(*E) bool) []*E

FilterInPlace modifies a slice using provided predicate function. It returns a sub-slice of the input list that only contains the elements for which the predicate function returns true. Warning: This function modifies the input list!

func MergeMaps

func MergeMaps(map1, map2 map[string]string) (map[string]string, bool)

MergeMaps merges map2 into map1. It returns true if map1 changed.

func MergeMapsSilent

func MergeMapsSilent(map1, map2 map[string]string) map[string]string

MergeMapsSilent merges map2 into map1. It does not indicate if map1 changed.

Types

type DiffCalc

type DiffCalc[E any] struct {
	First    []E
	Identity func(E) string
}

DiffCalc calculates the difference between two slices of objects for which a string-based identity can be defined. The provided identity function should return the smallest unique string representation of the object. Note: For most types one can find a unique string identity, but for some types it might not be possible or practical: one example would be a built-in map[k]v type.

In such cases, the DiffCalc type should not be used.

func (*DiffCalc[E]) NotExistingIn

func (d *DiffCalc[E]) NotExistingIn(second []E) []*E

notExistingIn returns a slice of object that are present in the first slice but not in the second. The returned list is a slice of pointers to the objects in the first slice, to avoid copying the objects.

Jump to

Keyboard shortcuts

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