util

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[T comparable](elems []T, v T) bool

Contains iterates the collection returning true if found

Types

type Set

type Set[T constraints.Ordered] map[T]int

Set tracks items added keeping the total number of each individual item added.

func NewSet

func NewSet[T constraints.Ordered]() Set[T]

NewSet returns a Set

func (Set[T]) Add

func (s Set[T]) Add(c T)

Add an item, incrementing the count

func (Set[T]) AddWithValue added in v0.1.8

func (s Set[T]) AddWithValue(c T, n int)

Add an item, incrementing the count

func (Set[T]) Join

func (s Set[T]) Join(x Set[T]) Set[T]

Join returns the superset of two Sets

func (Set[T]) Keys

func (s Set[T]) Keys() []T

Keys returns a slice of keys

func (Set[T]) OrderedKeys

func (s Set[T]) OrderedKeys() []T

OrderedKeys returns the keys ordered in ascending order

func (Set[T]) TopValue added in v0.1.8

func (s Set[T]) TopValue() (T, int)

TopValue returns the key with the highest value and its value

Jump to

Keyboard shortcuts

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