Documentation ¶
Index ¶
- func Add[K comparable, V Addable](m map[K]V, key K, value V)
- func Append[K comparable, V Values](m map[K][]V, key K, value V)
- func GetOrCreateRef[K comparable, VP *V, V any](m map[K]VP, key K) VP
- func Inc[K comparable, V Ints](m map[K]V, key K)
- func SetIfMissing[K comparable, V any](m map[K]V, key K, value V)
- type Addable
- type Ints
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add[K comparable, V Addable](m map[K]V, key K, value V)
Add the value to the value at the key, create the key if not exists
func Append ¶
func Append[K comparable, V Values](m map[K][]V, key K, value V)
Append to the []V key, create the key if not exists
func GetOrCreateRef ¶ added in v0.0.2
func GetOrCreateRef[K comparable, VP *V, V any](m map[K]VP, key K) VP
GetOrCreateRef can be used to set a default value of a reference type, and return it for further use
func Inc ¶
func Inc[K comparable, V Ints](m map[K]V, key K)
Inc the value at the key, create the key if not exists. Integer values only
func SetIfMissing ¶
func SetIfMissing[K comparable, V any](m map[K]V, key K, value V)
Types ¶
type Addable ¶ added in v0.0.2
type Addable interface { constraints.Integer | constraints.Float | constraints.Complex | ~string }
type Values ¶
type Values interface { constraints.Integer | constraints.Float | constraints.Complex | ~string | ~bool }
Click to show internal directories.
Click to hide internal directories.