mapsync

package
v1.3.27 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MapSync

type MapSync[K comparable, V any] struct {
	Map  map[K]V
	Lock sync.Locker
}

gosync "sync"

func New

func New[K comparable, V any](opts ...Option) *MapSync[K, V]

New creates a new NewSync

func (*MapSync[K, V]) Clear added in v1.3.13

func (t *MapSync[K, V]) Clear()

func (*MapSync[K, V]) Clone added in v1.3.13

func (t *MapSync[K, V]) Clone(key K) map[K]V

func (*MapSync[K, V]) Contains added in v1.3.13

func (t *MapSync[K, V]) Contains(key K) bool

func (*MapSync[K, V]) Empty

func (t *MapSync[K, V]) Empty() bool

Empty returns true if Tree is empty,otherwise returns false.

func (*MapSync[K, V]) Get

func (t *MapSync[K, V]) Get(key K) (V, bool)

Find finds the first node that the key is equal to the passed key, and returns its value

func (*MapSync[K, V]) GetOrSet added in v1.3.5

func (t *MapSync[K, V]) GetOrSet(key K, value V) (V, bool)

func (*MapSync[K, V]) GetOrSetFunc added in v1.3.7

func (t *MapSync[K, V]) GetOrSetFunc(key K, fn func() V) (V, bool)

func (*MapSync[K, V]) Insert

func (t *MapSync[K, V]) Insert(key K, value V)

Insert inserts a key-value pair into the RbTree.

func (*MapSync[K, V]) Iterator added in v1.3.13

func (t *MapSync[K, V]) Iterator(visitor visitor.KvVisitor[K, V])

func (*MapSync[K, V]) Keys

func (t *MapSync[K, V]) Keys() []K

func (*MapSync[K, V]) LockFunc added in v1.3.5

func (t *MapSync[K, V]) LockFunc(fn func(m map[K]V))

func (*MapSync[K, V]) Remove

func (t *MapSync[K, V]) Remove(key K) (V, bool)

func (*MapSync[K, V]) Set added in v1.3.4

func (t *MapSync[K, V]) Set(key K, value V) V

返回旧值

func (*MapSync[K, V]) SetIfNotExist added in v1.3.14

func (t *MapSync[K, V]) SetIfNotExist(key K, value V) bool

func (*MapSync[K, V]) Size

func (t *MapSync[K, V]) Size() int

Size returns the size of the rbtree.

func (*MapSync[K, V]) String added in v1.3.17

func (t *MapSync[K, V]) String() string

func (*MapSync[K, V]) Values added in v1.3.11

func (t *MapSync[K, V]) Values() []V

type Option

type Option func(option *Options)

Option is a function type used to set Options

func WithGoroutineSafe

func WithGoroutineSafe() Option

WithGoroutineSafe is used to set the set goroutine-safe Note that iterators are not goroutine safe, and it is useless to turn on the setting option here. so don't use iterators in multi goroutines

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options holds the Set's options

Jump to

Keyboard shortcuts

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