cmp

package
v1.35.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LenSlicePtr

func LenSlicePtr[T any](ts *[]T) int

LenSlicePtr return len(*ts) or 0 in case ts is nil.

func PtrValEqual

func PtrValEqual[T comparable](a, b *T) bool

PtrValEqual returns true if both a and b are nil or their values are equal.

func PtrValEqualFn

func PtrValEqualFn[T any](a, b *T, cmp func(x, y T) bool) bool

PtrValEqualFn return true if both a and b are nil or their values satisfy cmp.

func SliceEqual

func SliceEqual[T comparable](a, b []T) bool

SliceEqual returns true if a and b contain the same elements. A nil slice and empty slice are considered equal.

func SliceEqualUnordered

func SliceEqualUnordered[T any](a, b []T, cmp func(x, y T) bool) bool

SliceEqualUnordered returns true if every element in a can be matched with an element in b, established by cmp. Each element in b can only be matched once. Additionally, the lengths of a and b must match, so each element in b also matches in element in a. If an element in a matches multiple elements in b, then the first available one is matched.

func UnpackPtr

func UnpackPtr[T any](t *T) T

Unpack returns the value that t points to or T's zero value if t is nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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