Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToMap ¶ added in v0.17.2
func ToMap[K comparable, V any](s []V, key func(V) K) map[K]V
ToMap is a utility function that converts the slice s to a map using key to retrieve map keys.
func ToSlice ¶ added in v0.17.2
func ToSlice[K comparable, V any](m map[K]V) []V
ToSlice is a utility function that converts the map m to a slice of m's values. The returned slices order is undefined.
Types ¶
type Set ¶
type Set[T comparable] map[T]struct{}
Set is a collection that only contains unique elements.
func MapSet ¶
func MapSet[G any, T comparable](c []G, f func(G) T) Set[T]
MapSet converts c to a new set. f is used to extract the value for representing each element of c.
func NewSetFrom ¶
func NewSetFrom[T comparable](elements ...T) Set[T]
NewSetFrom creates a Set from a list of elements.
func (Set[T]) Add ¶
func (s Set[T]) Add(e T)
Add stores a new element in the Set if wasn't contained yet.
Click to show internal directories.
Click to hide internal directories.