Documentation
¶
Index ¶
- func Copy[K comparable, V any](m map[K]V) map[K]V
- func Filter[K comparable, V any](m map[K]V, fn func(K, V) bool) map[K]V
- func From[T any, K comparable, V any](arr []T, fn func(T) (K, V)) map[K]V
- func Keys[K comparable, V any](m map[K]V) []K
- func Map[K comparable, U any, V any](m map[K]U, fn func(U) V) map[K]V
- func Values[K comparable, V any](m map[K]V) []V
- type SyncMap
- func (in *SyncMap[K, V]) Data() map[K]V
- func (in *SyncMap[K, V]) Del(key K)
- func (in *SyncMap[K, V]) Get(key K) (V, bool)
- func (in *SyncMap[K, V]) Keys() []K
- func (in *SyncMap[K, V]) Load(m map[K]V)
- func (in *SyncMap[K, V]) Range(f func(K, V))
- func (in *SyncMap[K, V]) Set(key K, val V)
- func (in *SyncMap[K, V]) Values() []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶ added in v1.9.0
func Filter[K comparable, V any](m map[K]V, fn func(K, V) bool) map[K]V
Filter functional filter for map items
func From ¶ added in v1.9.0
func From[T any, K comparable, V any](arr []T, fn func(T) (K, V)) map[K]V
From create a map from array
func Keys ¶
func Keys[K comparable, V any](m map[K]V) []K
Keys return the arr of keys in the given map
func Map ¶
func Map[K comparable, U any, V any](m map[K]U, fn func(U) V) map[K]V
Map functional conversion for map items
func Values ¶
func Values[K comparable, V any](m map[K]V) []V
Values return the arr of values in the given map
Types ¶
type SyncMap ¶
type SyncMap[K comparable, V any] struct { // contains filtered or unexported fields }
SyncMap defines the thread-safe map
func NewSyncMap ¶
func NewSyncMap[K comparable, V any]() *SyncMap[K, V]
NewSyncMap create a new SyncMap
func NewSyncMapFrom ¶
func NewSyncMapFrom[K comparable, V any](in map[K]V) *SyncMap[K, V]
NewSyncMapFrom create a new SyncMap from existing map. The data is copied instead of directly referring to the given map.
func (*SyncMap[K, V]) Data ¶ added in v1.9.0
func (in *SyncMap[K, V]) Data() map[K]V
Data return a full copy of underlying
func (*SyncMap[K, V]) Del ¶
func (in *SyncMap[K, V]) Del(key K)
Del delete the value for the given key
func (*SyncMap[K, V]) Load ¶
func (in *SyncMap[K, V]) Load(m map[K]V)
Load function for reset the underlying map, copies all data from the given map
func (*SyncMap[K, V]) Range ¶
func (in *SyncMap[K, V]) Range(f func(K, V))
Range function for ranging over the map, it uses RLock during ranging
Click to show internal directories.
Click to hide internal directories.