mapsync

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: MIT Imports: 3 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]) Copy

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

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]) IteratorAsc

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

IteratorDesc traversals elements in the RbTree, it will not stop until to the end of RbTree or the visitor returns false

func (*MapSync[K, V]) IteratorDesc

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

IteratorDesc traversals elements in the RbTree, it will not stop until to the end of RbTree or the visitor returns false

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)

func (*MapSync[K, V]) Size

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

Size returns the size of the rbtree.

func (*MapSync[K, V]) Vals

func (t *MapSync[K, V]) Vals() []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