Documentation
¶
Overview ¶
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-11 13:08:58 * @FilePath: \go-toolbox\pkg\syncx\map.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-11-09 01:15:05 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-11 13:08:58 * @FilePath: \go-toolbox\pkg\syncx\set.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
Index ¶
- func CopyMeta(src, dst map[string]string)
- func MetaMapToString(meta map[string]string) string
- func MetaStringToMap(meta string) map[string]string
- type Map
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) CompareAndDelete(key K, value V) bool
- func (m *Map[K, V]) CompareAndSwap(key K, old, new V) bool
- func (m *Map[K, V]) Delete(key K)
- func (m *Map[K, V]) Equals(key K, value V, cmpFunc func(existing V) bool) bool
- func (m *Map[K, V]) Keys() []K
- func (m *Map[K, V]) Load(key K) (V, bool)
- func (m *Map[K, V]) LoadAndDelete(key K) (V, bool)
- func (m *Map[K, V]) LoadOrStore(key K, new V) (V, bool)
- func (m *Map[K, V]) Range(run func(key K, value V) bool)
- func (m *Map[K, V]) Size() int
- func (m *Map[K, V]) Store(key K, value V)
- func (m *Map[K, V]) Swap(key K, value V) (pre V, ok bool)
- func (m *Map[K, V]) Values() []V
- type Set
- func (s *Set[K]) Add(key K)
- func (s *Set[K]) AddAll(keys ...K)
- func (s *Set[K]) Clear()
- func (s *Set[K]) Delete(key K)
- func (s *Set[K]) DeleteAll(keys ...K)
- func (s *Set[K]) Elements() []K
- func (s *Set[K]) Has(key K) bool
- func (s *Set[K]) HasAll(keys ...K) (existing []K, all bool)
- func (s *Set[K]) IsEmpty() bool
- func (s *Set[K]) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MetaMapToString ¶
MetaMapToString 将 map 转换为 meta 字符串
func MetaStringToMap ¶
MetaStringToMap 将 meta 字符串转换为键值对的 map
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map 是一个线程安全的映射,使用泛型 K 和 V。
func (*Map[K, V]) CompareAndDelete ¶
CompareAndDelete 比较指定键的值,如果相等则删除该键的值。
func (*Map[K, V]) CompareAndSwap ¶
CompareAndSwap 比较指定键的现有值,如果相等则将其替换为新值。
func (*Map[K, V]) LoadAndDelete ¶
LoadAndDelete 方法从 Map 中加载并删除指定键的值
func (*Map[K, V]) LoadOrStore ¶
LoadOrStore 获取指定键的值,如果不存在则存储新值。