collectionutil

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[E comparable](slice []E, elem E) bool

func CopyMap

func CopyMap[K comparable, V any](m map[K]V) map[K]V

func FlattenUnique

func FlattenUnique[E comparable](slices ...[]E) []E

FlattenUnique appends each unique item in each list, in the order in which it first appears.

Examples:

  • FlattenUnique([]int{1, 2, 3}, []int{4, 3, 4}) => []int{1, 2, 3, 4}
  • FlattenUnique([]int{1, 2, 2}, []int{3, 4}) => []int{1, 2, 3, 4}

func GetOneEntry

func GetOneEntry[K comparable, V any](m map[K]V) (K, V)

GetOneEntry gets an entry from the given map. If the map contains multiple entries, it's undefined which this returns. If the map is empty, this will return the zero value for both the key and map.

func Keys

func Keys[K comparable, V any](m map[K]V) []K

Types

type ExtendingMap

type ExtendingMap[K comparable, V any] map[K]V

func Extend

func Extend[K comparable, V any](m map[K]V) ExtendingMap[K, V]

func (ExtendingMap[K, V]) Into

func (source ExtendingMap[K, V]) Into(target map[K]V)

Jump to

Keyboard shortcuts

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