concurrent_map

package
v5.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MapShardSize = 64
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Hashable

type Hashable interface {
	comparable
	Sum() uint64
}

type Map

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

func NewMap

func NewMap[K Hashable, V any]() *Map[K, V]

func NewMapCache

func NewMapCache[K Hashable, V any](size int) *Map[K, V]

NewMapCache returns a cache with a maximum size. Note that, because this it has multiple (MapShardSize) shards, the actual maximum size is MapShardSize*(size / MapShardSize). If size <=0, it's equal to NewMap().

func (*Map[K, V]) Del

func (m *Map[K, V]) Del(key K)

func (*Map[K, V]) Flush

func (m *Map[K, V]) Flush()

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(key K) (V, bool)

func (*Map[K, V]) Len

func (m *Map[K, V]) Len() int

func (*Map[K, V]) RangeDo

func (m *Map[K, V]) RangeDo(f func(k K, v V) (newV V, setV, delV bool, err error)) error

func (*Map[K, V]) Set

func (m *Map[K, V]) Set(key K, v V)

func (*Map[K, V]) TestAndSet

func (m *Map[K, V]) TestAndSet(key K, f func(v V, ok bool) (newV V, setV, delV bool))

type TestAndSetFunc

type TestAndSetFunc[K comparable, V any] func(key K, v V, ok bool) (newV V, setV, deleteV bool)

Jump to

Keyboard shortcuts

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