Documentation ¶
Index ¶
- func Add[K comparable, V any](m *map[K]V, key K, value V) bool
- func Clean[K comparable, V any](m map[K]V)
- func Each[K comparable, V any](m map[K]V, handler func(K, V))
- func EachEx[K comparable, V any](m map[K]V, handler func(K, V) error) error
- func First[K cmp.Ordered, V any](m map[K]V) (key K, value V, ok bool)
- func FirstKey[K cmp.Ordered, V any](m map[K]V) (firstKey K, ok bool)
- func Get[K comparable, V any](m map[K]V, key K) (V, bool)
- func GetValue[K comparable, V any](m map[K]V, key K) V
- func Keys[M ~map[K]V, K comparable, V any](m M) []K
- func MapToStruct(m map[string]any, v any) error
- func Set[K comparable, V any](m *map[K]V, key K, value V)
- func SortedKeys[K cmp.Ordered, V any](m map[K]V) []K
- func SortedValues[K cmp.Ordered, V any](m map[K]V) []V
- func Values[M ~map[K]V, K comparable, V any](m M) []V
- type Map
- type MapEntry
- type StableMap
- func (m *StableMap[K, V]) Del(key K)
- func (m *StableMap[K, V]) Exists(key K) bool
- func (m *StableMap[K, V]) Get(key K) (V, bool)
- func (m *StableMap[K, V]) GetOrDefault(key K, defaultValue V) V
- func (m *StableMap[K, V]) Keys() []K
- func (m *StableMap[K, V]) Len(key K) int
- func (m *StableMap[K, V]) Set(key K, value V)
- func (m *StableMap[K, V]) Size() int
- func (m *StableMap[K, V]) Values() []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add[K comparable, V any](m *map[K]V, key K, value V) bool
func Clean ¶
func Clean[K comparable, V any](m map[K]V)
func Each ¶
func Each[K comparable, V any](m map[K]V, handler func(K, V))
func Get ¶
func Get[K comparable, V any](m map[K]V, key K) (V, bool)
func GetValue ¶
func GetValue[K comparable, V any](m map[K]V, key K) V
func Keys ¶
func Keys[M ~map[K]V, K comparable, V any](m M) []K
Keys returns the keys of the map m. The keys will be in an indeterminate order.
func Set ¶
func Set[K comparable, V any](m *map[K]V, key K, value V)
func SortedKeys ¶
func SortedValues ¶
func Values ¶
func Values[M ~map[K]V, K comparable, V any](m M) []V
Values returns the values of the map m. The values will be in an indeterminate order.
Types ¶
type Map ¶
type Map[K comparable, V any] interface { Exists(K) bool Get(K) (V, bool) GetOrDefault(K, V) V Set(K, V) Del(K) Keys() []K Values() []V Size() int }
Map
type StableMap ¶
type StableMap[K comparable, V any] struct { // contains filtered or unexported fields }
StableMap 有序map,保持插入顺序; 零值可用
func (*StableMap[K, V]) GetOrDefault ¶
func (m *StableMap[K, V]) GetOrDefault(key K, defaultValue V) V
Click to show internal directories.
Click to hide internal directories.