cocurrent

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GenericSyncMap

type GenericSyncMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

GenericSyncMap 是一个使用 sync.Map 封装的泛型 Map

func NewGenericSyncMap

func NewGenericSyncMap[K comparable, V any]() *GenericSyncMap[K, V]

func NewGenericSyncMapFromMap

func NewGenericSyncMapFromMap[K comparable, V any](m map[K]V) *GenericSyncMap[K, V]

func (*GenericSyncMap[K, V]) Delete

func (gm *GenericSyncMap[K, V]) Delete(key K)

Delete 方法从 Map 中删除键值对

func (*GenericSyncMap[K, V]) Get

func (gm *GenericSyncMap[K, V]) Get(key K) (V, bool)

Get 方法从 Map 中检索值

func (*GenericSyncMap[K, V]) GetOr

func (gm *GenericSyncMap[K, V]) GetOr(k K, dV V) (v V)

func (*GenericSyncMap[K, V]) GetOrElse

func (gm *GenericSyncMap[K, V]) GetOrElse(k K, fn func() V) (v V)

func (*GenericSyncMap[K, V]) Keys

func (gm *GenericSyncMap[K, V]) Keys() []K

Keys 方法返回 Map 中的所有键

func (*GenericSyncMap[K, V]) Range

func (gm *GenericSyncMap[K, V]) Range(f func(key K, value V) bool)

Range 方法遍历 Map 中的所有键值对

func (*GenericSyncMap[K, V]) Set

func (gm *GenericSyncMap[K, V]) Set(key K, value V)

Set 方法将键值对添加到 Map 中

func (*GenericSyncMap[K, V]) Values

func (gm *GenericSyncMap[K, V]) Values() []V

Values 方法返回 Map 中的所有值

type SafeMap

type SafeMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

SafeMap 使用读写锁的线程安全map

func NewSafeMap

func NewSafeMap[K comparable, V any]() *SafeMap[K, V]

NewSafeMap 创建一个线程安全的map

func NewSafeMapFromMap

func NewSafeMapFromMap[K comparable, V any](m map[K]V) *SafeMap[K, V]

NewSafeMapFromMap 将普通map转换为SafeMap

func (*SafeMap[K, V]) Clear

func (s *SafeMap[K, V]) Clear()

func (*SafeMap[K, V]) Delete

func (s *SafeMap[K, V]) Delete(k K)

func (*SafeMap[K, V]) ForEach

func (s *SafeMap[K, V]) ForEach(fn func(K, V) bool)

func (*SafeMap[K, V]) Get

func (s *SafeMap[K, V]) Get(k K) (v V, ok bool)

func (*SafeMap[K, V]) GetOr

func (s *SafeMap[K, V]) GetOr(k K, dV V) (v V)

func (*SafeMap[K, V]) GetOrElse

func (s *SafeMap[K, V]) GetOrElse(k K, fn func() V) (v V)

func (*SafeMap[K, V]) Keys

func (s *SafeMap[K, V]) Keys() []K

Keys 返回 SafeMap 中的所有键

func (*SafeMap[K, V]) Set

func (s *SafeMap[K, V]) Set(k K, v V)

func (*SafeMap[K, V]) Values

func (s *SafeMap[K, V]) Values() []V

Values 返回 SafeMap 中的所有值

Jump to

Keyboard shortcuts

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