compare

package
v0.8.19 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareMaps added in v0.8.19

func CompareMaps[K Comparable, V Comparable](A, B map[K]V) (OnlyA, OnlyB, Unequal []K)

CompareMaps 使用泛型对比两个 map[K]V 类型的参数 A 和 B - K: map 的键,必须是可比较的类型 - V: map 的值,必须是可比较的类型 返回三个切片:OnlyA、OnlyB 和 Unequal - OnlyA: 仅在 A 中存在的键 - OnlyB: 仅在 B 中存在的键 - Unequal: 两边都存在,但值不相等的键

func CompareSlices added in v0.8.19

func CompareSlices[T Comparable](a, b []T) (OnlyA []T, OnlyB []T)

CompareSlices 使用泛型对比两个切片 A 和 B - T: 切片元素的类型,必须是可比较的类型 返回两个切片:OnlyA 和 OnlyB - OnlyA: 仅在 A 中存在的元素 - OnlyB: 仅在 B 中存在的元素

func StructEqual

func StructEqual[T any](a, b T) bool

StructEqual 比较两个相同类型的结构体,如果它们相等,则返回 true。

Types

type Comparable added in v0.8.19

type Comparable interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64 | ~string
}

Comparable 定义一个约束,限制类型必须是可比较的类型

Jump to

Keyboard shortcuts

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